ESP_IOT v2.5
IOT ESP Coding
BLEClientNetworking.h
Go to the documentation of this file.
1//
2// BLEClientNetworking.hpp
3// M5Stick
4//
5// Created by Scott Moody on 1/20/22.
6//
7
8#ifndef BLEClientNetworking_h
9#define BLEClientNetworking_h
10#include "../../Defines.h"
11
12//! https://esp32.com/viewtopic.php?t=2291
13/*!< Scan interval. This is defined as the time interval from
14 when the Controller started its last LE scan until it begins the subsequent LE scan.
15 Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
16 Time = N * 0.625 msec
17 Time Range: 2.5 msec to 10.24 seconds*/
18/** Set scan interval (how often) and window (how long) in milliseconds */
19
20/*!< Scan window. The duration of the LE scan. LE_Scan_Window
21 shall be less than or equal to LE_Scan_Interval
22 Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
23 Time = N * 0.625 msec
24 Time Range: 2.5 msec to 10240 msec */
25#define PSCAN_INTERVAL 45
26#define PSCAN_WINDOW 15
27#define PSCAN_TIME 0 /* scan forever*/
28
29//from example..
30//#define PSCAN_INTERVAL 1349
31//#define PSCAN_WINDOW 449
32
33
34//#include <stdio.h>
35
36//!These are the legacy PetTutor known addresses..
37//#define SERVICE_UUID PT_SERVICE_UUID //Pet Tutor feeder service for feed
38//#define CHARACTERISTIC_UUID PT_CHARACTERISTIC_UUID //Pet Tutor feeder characteristic
39
40
41#define BLE_CLIENT_CALLBACK_ONREAD 0
42#define BLE_CLIENT_CALLBACK_ONWRITE 1
43//!the BLE code wants to blink the light
44#define BLE_CLIENT_CALLBACK_BLINK_LIGHT 2
45//!used to send a string message back (which might be sent to MQTT for example)
46#define BLE_CLIENT_CALLBACK_STATUS_MESSAGE 3
47#define BLE_CLIENT_MAX_CALLBACKS 4
48
49
50//!the 'setup' for this module BLEClientNetworking. Here the service name is added (and potentially more later)
51void setup_BLEClientNetworking(char *serviceName, char *serviceUUID, char *characteristicUUID);
52
53//!the loop()
55
56//!FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() ..
57//!send the feed command
59
60//!FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() ..
61//!send the feed command
62void sendCommandBLEClient(String cmdString);
63
64//!send a string of 13 or less characters.
65void sendCommandBLEClient_13orLess(String cmdString);
66
67//! returns whether connected over BLE as a client to a server(like a ESP feeder)
68boolean isConnectedBLEClient();
69
70//! returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect
71boolean useBLEClient();
72
73//! try to disconnect..
75
76//! an address or name to skip (for at least 1 time)
77void skipNameOrAddress_BLEClientNetworking(char *nameOrAddress);
78
79#endif /* BLEClientNetworking_h */
void loop_BLEClientNetworking()
the loop()
void sendCommandBLEClient(String cmdString)
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
void sendFeedCommandBLEClient()
sends the "feed" command over bluetooth to the connected device..
boolean useBLEClient()
returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect
void setup_BLEClientNetworking(char *serviceName, char *serviceUUID, char *characteristicUUID)
the 'setup' for this module BLEClientNetworking. Here the service name is added (and potentially more...
void disconnect_BLEClientNetworking()
try to disconnect..
void skipNameOrAddress_BLEClientNetworking(char *nameOrAddress)
an address or name to skip (for at least 1 time)
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 or less characters.