ESP_IOT v2.5
IOT ESP Coding
BLEClientNetworking.h File Reference
#include "../../Defines.h"
Include dependency graph for BLEClientNetworking.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PSCAN_INTERVAL   45
 https://esp32.com/viewtopic.php?t=2291 More...
 
#define PSCAN_WINDOW   15
 
#define PSCAN_TIME   0 /* scan forever*/
 
#define BLE_CLIENT_CALLBACK_ONREAD   0
 These are the legacy PetTutor known addresses.. More...
 
#define BLE_CLIENT_CALLBACK_ONWRITE   1
 
#define BLE_CLIENT_CALLBACK_BLINK_LIGHT   2
 the BLE code wants to blink the light More...
 
#define BLE_CLIENT_CALLBACK_STATUS_MESSAGE   3
 used to send a string message back (which might be sent to MQTT for example) More...
 
#define BLE_CLIENT_MAX_CALLBACKS   4
 

Functions

void setup_BLEClientNetworking (char *serviceName, char *serviceUUID, char *characteristicUUID)
 the 'setup' for this module BLEClientNetworking. Here the service name is added (and potentially more later) More...
 
void loop_BLEClientNetworking ()
 the loop() More...
 
void sendFeedCommandBLEClient ()
 sends the "feed" command over bluetooth to the connected device.. More...
 
void sendCommandBLEClient (String cmdString)
 
void sendCommandBLEClient_13orLess (String cmdString)
 send a string of 13 or less characters. More...
 
boolean isConnectedBLEClient ()
 returns whether connected over BLE as a client to a server(like a ESP feeder) More...
 
boolean useBLEClient ()
 returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect More...
 
void disconnect_BLEClientNetworking ()
 try to disconnect.. More...
 
void skipNameOrAddress_BLEClientNetworking (char *nameOrAddress)
 an address or name to skip (for at least 1 time) More...
 

Macro Definition Documentation

◆ BLE_CLIENT_CALLBACK_BLINK_LIGHT

#define BLE_CLIENT_CALLBACK_BLINK_LIGHT   2

the BLE code wants to blink the light

Definition at line 44 of file BLEClientNetworking.h.

◆ BLE_CLIENT_CALLBACK_ONREAD

#define BLE_CLIENT_CALLBACK_ONREAD   0

These are the legacy PetTutor known addresses..

Definition at line 41 of file BLEClientNetworking.h.

◆ BLE_CLIENT_CALLBACK_ONWRITE

#define BLE_CLIENT_CALLBACK_ONWRITE   1

Definition at line 42 of file BLEClientNetworking.h.

◆ BLE_CLIENT_CALLBACK_STATUS_MESSAGE

#define BLE_CLIENT_CALLBACK_STATUS_MESSAGE   3

used to send a string message back (which might be sent to MQTT for example)

Definition at line 46 of file BLEClientNetworking.h.

◆ BLE_CLIENT_MAX_CALLBACKS

#define BLE_CLIENT_MAX_CALLBACKS   4

Definition at line 47 of file BLEClientNetworking.h.

◆ PSCAN_INTERVAL

#define PSCAN_INTERVAL   45

https://esp32.com/viewtopic.php?t=2291

< Scan interval. This is defined as the time interval from when the Controller started its last LE scan until it begins the subsequent LE scan. Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms) Time = N * 0.625 msec Time Range: 2.5 msec to 10.24 seconds Set scan interval (how often) and window (how long) in milliseconds

< Scan window. The duration of the LE scan. LE_Scan_Window shall be less than or equal to LE_Scan_Interval Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms) Time = N * 0.625 msec Time Range: 2.5 msec to 10240 msec

Definition at line 25 of file BLEClientNetworking.h.

◆ PSCAN_TIME

#define PSCAN_TIME   0 /* scan forever*/

Definition at line 27 of file BLEClientNetworking.h.

◆ PSCAN_WINDOW

#define PSCAN_WINDOW   15

Definition at line 26 of file BLEClientNetworking.h.

Function Documentation

◆ disconnect_BLEClientNetworking()

void disconnect_BLEClientNetworking ( )

try to disconnect..

force saying it's disconnected

Definition at line 1007 of file BLEClientNetworking.cpp.

Here is the caller graph for this function:

◆ isConnectedBLEClient()

boolean isConnectedBLEClient ( )

returns whether connected over BLE as a client to a server(like a ESP feeder)

Definition at line 738 of file BLEClientNetworking.cpp.

Here is the caller graph for this function:

◆ loop_BLEClientNetworking()

void loop_BLEClientNetworking ( )

the loop()

a specialy display for now.. 1 = C connected BLE

try 4.22.22

note: https://github.com/espressif/esp-idf/issues/5105 Might address the error I see:

Definition at line 1025 of file BLEClientNetworking.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendCommandBLEClient()

void sendCommandBLEClient ( String  cmdString)

FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() .. send the feed command

FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() .. send the feed command NOTE: if we are a gateway (gen3) then this won't work, as it's not talking back..

if GEN3 then this handshaking will not work.. so just send the cmd, if longer than 1 character, it hangs .. so don't send

Definition at line 829 of file BLEClientNetworking.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendCommandBLEClient_13orLess()

void sendCommandBLEClient_13orLess ( String  cmdString)

send a string of 13 or less characters.

send a string of 13 or less characters.

FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() .. send the feed command

if (FeedFlag == true) flag is set in button_task Set the characteristic's value to be the array of bytes that is actually a string. this sets a value to the GATT which is the trigger value for the BLE server feeder

delay

check for the acknowledge from the server which is 0x01

Definition at line 877 of file BLEClientNetworking.cpp.

Here is the caller graph for this function:

◆ sendFeedCommandBLEClient()

void sendFeedCommandBLEClient ( )

sends the "feed" command over bluetooth to the connected device..

FOR NOW THIS IS HERE.. but it should be more generic. eg: sendBluetoothCommand() .. send the feed command

Definition at line 751 of file BLEClientNetworking.cpp.

Here is the caller graph for this function:

◆ setup_BLEClientNetworking()

void setup_BLEClientNetworking ( char *  serviceName,
char *  serviceUUID,
char *  characteristicUUID 
)

the 'setup' for this module BLEClientNetworking. Here the service name is added (and potentially more later)

the 'setup' for this module BLEClientNetworking. Here the service name is added (and potentially more later)

address to skip (for a number of times) .. how about 1 for now..

start the bluetooth discovery..

Initialize NimBLE, no device name spcified as we are not advertising

Set the IO capabilities of the device, each option will trigger a different pairing method. BLE_HS_IO_KEYBOARD_ONLY - Passkey pairing BLE_HS_IO_DISPLAY_YESNO - Numeric comparison pairing BLE_HS_IO_NO_INPUT_OUTPUT - DEFAULT setting - just works pairing

2 different ways to set security - both calls achieve the same result. no bonding, no man in the middle protection, secure connections.

These are the default values, only shown here for demonstration.

Optional: set the transmit power, default is 3db

+9db

Optional: set any devices you don't want to get advertisments from

create new scan

create a callback that gets called when advertisers are found

Set scan interval (how often) and window (how long) in milliseconds

Active scan will gather scan response data from advertisers but will use more energy from both devices

Start scanning for advertisers for the scan time specified (in seconds) 0 = forever Optional callback for when scanning stops.

Definition at line 940 of file BLEClientNetworking.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipNameOrAddress_BLEClientNetworking()

void skipNameOrAddress_BLEClientNetworking ( char *  nameOrAddress)

an address or name to skip (for at least 1 time)

Definition at line 56 of file BLEClientNetworking.cpp.

Here is the caller graph for this function:

◆ useBLEClient()

boolean useBLEClient ( )

returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect

Definition at line 44 of file BLEClientNetworking.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: