|
ESP_IOT v2.5
IOT ESP Coding
|

Go to the source code of this file.
Classes | |
| class | ClientCallbacks |
| class | ScanCallbacks |
Macros | |
| #define | NEW_WAY |
Functions | |
| void | scanEndedCB_BLEClient (NimBLEScanResults results) |
| NOTE: this is called all the time... 4.22.22 –even if the "scan-stop" invoked. More... | |
| boolean | useBLEClient () |
| returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect More... | |
| void | skipNameOrAddress_BLEClientNetworking (char *nameOrAddress) |
| an address or name to skip (for at least 1 time) More... | |
| void | stopSkip_BLEClientNetworking () |
| stops the skip after found something.. More... | |
| boolean | containsSkipAddress (String deviceInfo) |
| helper for skip, checking if an actuall address in the skip name or address More... | |
| void | notifyCB (NimBLERemoteCharacteristic *pRemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify) |
| bool | connectToServer_BLEClient () |
| boolean | isConnectedBLEClient () |
| returns whether connected over BLE as a client to a server(like a ESP feeder) More... | |
| void | sendFeedCommandBLEClient () |
| sends the "feed" command over bluetooth to the connected device.. More... | |
| void | sendCommandBLEClient_13orLess (String cmdString) |
| send a string of 13 characters or less More... | |
| void | sendCommandBLEClient (String cmdString) |
| void | setup_BLEClientNetworking (char *serviceName, char *serviceUUID, char *characteristicUUID) |
| the setup() and loop() passing the serviceName to look for.. More... | |
| void | disconnect_BLEClientNetworking () |
| try to disconnect.. More... | |
| void | loop_BLEClientNetworking () |
| the loop() More... | |
Variables | |
| NimBLEClient * | _pClient = nullptr |
| int | _skipAddressCount = 0 |
| skip logic More... | |
| int | _maxSkipAddressCount = 4 |
| char | _skipNameOrAddress_BLEClientNetworking [50] |
| address to skip (for a number of times) .. how about 1 for now.. More... | |
| ClientCallbacks | _clientCB_BLEClient |
| ScanCallbacks | _scanCallbacks |
| #define NEW_WAY |
| bool connectToServer_BLEClient | ( | ) |
Handles the provisioning of clients and connects / interfaces with the server
6.6.26
Special case when we already know this device, we send false as the second argument in connect() to prevent refreshing the service database. This saves considerable time and power.
We don't already have a client that knows this device, we will check for a client that is disconnected that we can use.
No client to reuse? Create a new one.
6.6.26
create a new client
set callback
Set initial connection parameters: These settings are 15ms interval, 0 latency, 120ms timout. These settings are safe for 3 clients to connect reliably, can go faster if you have less connections. Timeout should be a multiple of the interval, minimum is 100ms. Min interval: 12 * 1.25ms = 15, Max interval: 12 * 1.25ms = 15, 0 latency, 51 * 10ms = 510ms timeout
[in] minInterval The minimum connection interval in 1.25ms units. [in] maxInterval The maximum connection interval in 1.25ms units. [in] latency The number of packets allowed to skip (extends max interval). [in] timeout The timeout time in 10ms units before disconnecting. [in] scanInterval The scan interval to use when attempting to connect in 0.625ms units. [in] scanWindow The scan window to use when attempting to connect in 0.625ms units.
6.8.26 set to 150 (from 51)
Set how long we are willing to wait for the connection to complete (seconds), default is 3000. (was 5)
Created a client but failed to connect, don't need to keep it as it has no data
not connected
6.6.26
Now we can read/write/subscribe the charateristics of the services we are interested in
**** THATS WHY THE DEAD is there .. only our new ones have that.. This was added 2022 - for this specific reason
Try to get our new service == DEAD (for now.. this is not in the GEN3)
THIS IS A new ESP32 feeder
called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
THIS IS A new ESP32 feeder
called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
make sure it's not null
make sure it's not null
registerForNotify() has been deprecated and replaced with subscribe() / unsubscribe(). Subscribe parameter defaults are: notifications=true, notifyCallback=nullptr, response=false. Unsubscribe parameter defaults are: response=false.
Disconnect if subscribe failed
Send false as first argument to subscribe to indications instead of notifications
Disconnect if subscribe failed
make sure it's not null
make sure it's not null
Disconnect if write failed
registerForNotify() has been deprecated and replaced with subscribe() / unsubscribe(). Subscribe parameter defaults are: notifications=true, notifyCallback=nullptr, response=false. Unsubscribe parameter defaults are: response=false.
Disconnect if subscribe failed
Send false as first argument to subscribe to indications instead of notifications
Disconnect if subscribe failed
Definition at line 477 of file BLEClientNetworking.cpp.
| boolean containsSkipAddress | ( | String | deviceInfo | ) |
helper for skip, checking if an actuall address in the skip name or address
Definition at line 78 of file BLEClientNetworking.cpp.

| void disconnect_BLEClientNetworking | ( | ) |
try to disconnect..
force saying it's disconnected
Definition at line 1224 of file BLEClientNetworking.cpp.

| boolean isConnectedBLEClient | ( | ) |
returns whether connected over BLE as a client to a server(like a ESP feeder)
Definition at line 859 of file BLEClientNetworking.cpp.

| void loop_BLEClientNetworking | ( | ) |
the loop()
a specialy display for now.. 1 = C connected BLE
try 4.22.22
6.6.25
scan more ..
note: https://github.com/espressif/esp-idf/issues/5105 Might address the error I see:
Definition at line 1242 of file BLEClientNetworking.cpp.


| void notifyCB | ( | NimBLERemoteCharacteristic * | pRemoteCharacteristic, |
| uint8_t * | pData, | ||
| size_t | length, | ||
| bool | isNotify | ||
| ) |
Notification / Indication receiving handler callback
Definition at line 442 of file BLEClientNetworking.cpp.
| void scanEndedCB_BLEClient | ( | NimBLEScanResults | results | ) |
NOTE: this is called all the time... 4.22.22 –even if the "scan-stop" invoked.
Callback to process the results of the last scan or restart it
Definition at line 466 of file BLEClientNetworking.cpp.
| void sendCommandBLEClient | ( | String | cmdString | ) |
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 950 of file BLEClientNetworking.cpp.


| void sendCommandBLEClient_13orLess | ( | String | cmdString | ) |
send a string of 13 characters or less
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 998 of file BLEClientNetworking.cpp.

| 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 872 of file BLEClientNetworking.cpp.

| void setup_BLEClientNetworking | ( | char * | serviceName, |
| char * | serviceUUID, | ||
| char * | characteristicUUID | ||
| ) |
the setup() and loop() passing the serviceName to look for..
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
6.6.25
Set the callbacks to call when scan events occur, no duplicates
Set scan interval (how often) and window (how long) in milliseconds
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.
6.6.25
Start scanning for advertisers
Definition at line 1062 of file BLEClientNetworking.cpp.

| void skipNameOrAddress_BLEClientNetworking | ( | char * | nameOrAddress | ) |
an address or name to skip (for at least 1 time)
Definition at line 63 of file BLEClientNetworking.cpp.

| void stopSkip_BLEClientNetworking | ( | ) |
stops the skip after found something..
Definition at line 72 of file BLEClientNetworking.cpp.
| boolean useBLEClient | ( | ) |
returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect
Definition at line 51 of file BLEClientNetworking.cpp.


| ClientCallbacks _clientCB_BLEClient |
| int _maxSkipAddressCount = 4 |
Definition at line 59 of file BLEClientNetworking.cpp.
| NimBLEClient* _pClient = nullptr |
scan time in milliseconds, 0 = scan forever
Definition at line 48 of file BLEClientNetworking.cpp.
| ScanCallbacks _scanCallbacks |
| int _skipAddressCount = 0 |
skip logic
Definition at line 58 of file BLEClientNetworking.cpp.
| char _skipNameOrAddress_BLEClientNetworking[50] |
address to skip (for a number of times) .. how about 1 for now..
Definition at line 61 of file BLEClientNetworking.cpp.