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#ifdef M5UNIFIED
28#define PSCAN_TIME 10000 // 5 sec
29//! 6.17.26 shortened time. 0 DOESN"T WORK FOR SURE
30//#define PSCAN_TIME 1000 // 1 sec .. seems to work
31
32#else
33#define PSCAN_TIME 0 /* scan forever*/
34#endif
35
36//from example..
37//#define PSCAN_INTERVAL 1349
38//#define PSCAN_WINDOW 449
39
40
41//#include <stdio.h>
42
43//!These are the legacy PetTutor known addresses..
44//#define SERVICE_UUID PT_SERVICE_UUID //Pet Tutor feeder service for feed
45//#define CHARACTERISTIC_UUID PT_CHARACTERISTIC_UUID //Pet Tutor feeder characteristic
46
47
48#define BLE_CLIENT_CALLBACK_ONREAD 0
49#define BLE_CLIENT_CALLBACK_ONWRITE 1
50//!the BLE code wants to blink the light
51#define BLE_CLIENT_CALLBACK_BLINK_LIGHT 2
52//!used to send a string message back (which might be sent to MQTT for example)
53#define BLE_CLIENT_CALLBACK_STATUS_MESSAGE 3
54#define BLE_CLIENT_MAX_CALLBACKS 4
55
56
57//!the 'setup' for this module BLEClientNetworking. Here the service name is added (and potentially more later)
58void setup_BLEClientNetworking(char *serviceName, char *serviceUUID, char *characteristicUUID);
59
60//!the loop()
62
63//!FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() ..
64//!send the feed command
66
67//!FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() ..
68//!send the feed command
69void sendCommandBLEClient(String cmdString);
70
71//!send a string of 13 or less characters.
72void sendCommandBLEClient_13orLess(String cmdString);
73
74//! returns whether connected over BLE as a client to a server(like a ESP feeder)
75boolean isConnectedBLEClient();
76
77//! returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect
78boolean useBLEClient();
79
80//! try to disconnect..
82
83//! an address or name to skip (for at least 1 time)
84void skipNameOrAddress_BLEClientNetworking(char *nameOrAddress);
85
86#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.