ESP_IOT v2.5
IOT ESP Coding
BLEServerNetworking.cpp
Go to the documentation of this file.
1/**
2* \link BLEServerNetworking
3*/
4//
5// BLENetworking.cpp
6// M5Stick
7//
8// Created by Scott Moody on 1/19/22.
9//
10
11#include "BLEServerNetworking.h"
12#include <NimBLEDevice.h>
13#include "../../Defines.h"
14#define pettutorApproach
15//https://h2zero.github.io/esp-nimble-cpp/class_nim_b_l_e_device.html
16//!the BLE Server
17static NimBLEServer* _pBLEServer;
18NimBLECharacteristic* _pCharacteristic;
19
20//!device name
22
24
25//!need to device way to change these ...
26//#define SERVICE_UUID "B0E6A4BF-CCCC-FFFF-330C-0000000000F0" //Pet Tutor feeder service for feed
27//#define CHARACTERISTIC_UUID "B0E6A4BF-CCCC-FFFF-330C-0000000000F1" //Pet Tutor feeder characteristic
30
31#define MAX_MESSAGE 600
33
34
35//! retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc)
37{
39}
40
41//!NOT CALLED...
42//!sets the device name in the advertising
43void setBLEServerDeviceName(char *deviceName)
44{
45 _pCharacteristic->setValue(deviceName);
46
47 //save the deviceName
48 _deviceName_BLEServer = deviceName;
49}
50
51/** None of these are required as they will be handled by the library with defaults. **
52 ** Remove as you see fit for your needs */
53class BLEServeNetworkingCallbacks : public NimBLEServerCallbacks
54{
55 void onConnect(NimBLEServer* pServer)
56 {
57 SerialInfo.println("Client connected");
58 SerialInfo.println("Multi-connect support: start advertising");
59 NimBLEDevice::startAdvertising();
60 };
61 /** Alternative onConnect() method to extract details of the connection.
62 See: src/ble_gap.h for the details of the ble_gap_conn_desc struct.
63 */
64 void onConnect(NimBLEServer* pServer, ble_gap_conn_desc* desc)
65 {
66 SerialInfo.print("Client address: ");
67 SerialInfo.println(NimBLEAddress(desc->peer_ota_addr).toString().c_str());
68 /** We can use the connection handle here to ask for different connection parameters.
69 Args: connection handle, min connection interval, max connection interval
70 latency, supervision timeout.
71 Units; Min/Max Intervals: 1.25 millisecond increments.
72 Latency: number of intervals allowed to skip.
73 Timeout: 10 millisecond increments, try for 5x interval time for best results.
74 */
75 //GOOD:
76 pServer->updateConnParams(desc->conn_handle, 24, 48, 0, 60);
77
78 //try:
79 //pServer->updateConnParams(desc->conn_handle, 100, 200, 10, 160);
80
81 };
82 void onDisconnect(NimBLEServer* pServer)
83 {
84 SerialInfo.println("Client disconnected - start advertising");
85 NimBLEDevice::startAdvertising();
86 };
87 void onMTUChange(uint16_t MTU, ble_gap_conn_desc* desc)
88 {
89 SerialInfo.printf("MTU updated: %u for connection ID: %u\n", MTU, desc->conn_handle);
90 };
91
92 /********************* Security handled here **********************
93 ****** Note: these are the same return values as defaults ********/
94 uint32_t onPassKeyRequest()
95 {
96 SerialDebug.println("Server Passkey Request");
97 /** This should return a random 6 digit number for security
98 or make your own static passkey as done here.
99 */
100 return 123456;
101 };
102
103 bool onConfirmPIN(uint32_t pass_key)
104 {
105 SerialDebug.print("The passkey YES/NO number: "); SerialDebug.println(pass_key);
106 /** Return false if passkeys don't match. */
107 return true;
108 };
109
110 void onAuthenticationComplete(ble_gap_conn_desc* desc)
111 {
112 /** Check that encryption was successful, if not we disconnect the client */
113 if (!desc->sec_state.encrypted)
114 {
115 NimBLEDevice::getServer()->disconnect(desc->conn_handle);
116 SerialDebug.println("Encrypt connection failed - disconnecting client");
117 return;
118 }
119 SerialDebug.println("Starting BLE work!");
120 };
121};
122
123/** Handler class for characteristic actions */
124//!Note: the onRead and onWrite are from the perspective of the client. So onRead is the client calling this server, over BLE, and reading a value. The onWrite is the client writing to this server (sending a BLE message). This is where JSON or raw values are used.
125class BLEServerNetworkingCharacteristicCallbacks : public NimBLECharacteristicCallbacks
126{
127 //!called when wanting to "read" from this server
128 void onRead(NimBLECharacteristic* pCharacteristic)
129 {
130 SerialDebug.print(pCharacteristic->getUUID().toString().c_str());
131 SerialDebug.print(": onRead(), value: ");
132 // SerialDebug.print(_fullJSONString);
133 SerialDebug.println(pCharacteristic->getValue().c_str());
134 };
135
136 //!called when writing to the server.
137 void onWrite(NimBLECharacteristic* pCharacteristic)
138 {
139 SerialDebug.print(pCharacteristic->getUUID().toString().c_str());
140 SerialDebug.print(": onWrite(), value: ");
141// SerialDebug.println(pCharacteristic->getValue().c_str());
142// std::string rxValue = pCharacteristic->getValue().c_str();
143 //??
144 // ProcessClientCmd(rxValue[0]); //?? client sent a command now see what it is
145 // pCharacteristic->setValue(0x01); //?? This is the acknowlege(ACK) back to client. Later this should be contigent on a feed completed
146 /*******************************MQTT*************************************/
147 std::string value = pCharacteristic->getValue();
148 SerialDebug.println(value.c_str());
149
150 if (value.length() > 0) {
151 SerialDebug.println("*********");
152 SerialDebug.printf("New value: %d - \n", value.length());
153
154 //create a string 'ascii' from the values
155 for (int i = 0; i < value.length(); i++)
156 {
157 _asciiMessage[i] = value[i];
158 _asciiMessage[i + 1] = 0;
159 if (i >= value.length())
160 break;
161 }
162 //reply right away .. see what happens..
163 //sendBLEMessageACKMessage();
164 //pCharacteristic->setValue(0x01); //?? This is the acknowlege(ACK) back to client. Later this should be contigent on a feed completed
165 SerialDebug.println(pCharacteristic->getUUID().toString().c_str());
166
167#ifdef TRY_LATER
168 //try .. #85
169 // if (value.compare("_ESP_32"==0))
170 {SerialInfo.println("pChar->setValue(_ESP_32)");
171 //send it back...
172 pCharacteristic->setValue((char*)"_ESP_32");
173 }
174#endif
175 //call the callback specified from the caller (eg. NimBLE_PetTutor_Server .. or others)
176 // (*_callbackFunction)(rxValue);
178
179#ifdef ESP_M5
180 SerialDebug.println("*** performing an M5 specific command from BLE trigger");
181 // do something ..
183
184 M5.Beep.beep();
185
186 //!Increment the screen color 0..n cache for getting the screen color 0..max (max provided by sender)
187 //!This is implemented by incrementScreenColor_mainModule() since it knows the MAX value of colors
189
190#ifdef ESP_M5_CAMERA
191 //!take a picture
192 takePicture_CameraModule();
193#endif // camera
194#endif
195#ifdef NOT_NOW_MQTT_NETWORKING
196 //This should be a 'register' command..
197
198 // will return true if the message was JSON and was processes, false otherwise.
199 if (processJSONMessage(ascii))
200 {
201 //processed by the MQTTNetworking code..
202 pCharacteristic->setValue(0x01); //?? This is the acknowlege(ACK) back to client. Later this should be contigent on a feed completed
203 }
204 else
205 {
206 //perform feed...
207 SerialInfo.println("Perform FEED");
208
209 //std::string rxValue = pCharacteristic->getValue().c_str(); //??
210 //stepperModule_ProcessClientCmd(rxValue[0]); //?? client sent a command now see what it is
212 pCharacteristic->setValue(0x01); //?? This is the acknowlege(ACK) back to client. Later this should be contigent on a feed completed
213
214#ifdef ESP_M5
215
216//#ifdef TEST_M5_TO_M5
217 // do something ..
218 showText_displayModule("BLE FEED");
219
220 //!Increment the screen color 0..n cache for getting the screen color 0..max (max provided by sender)
221 //!This is implemented by incrementScreenColor_mainModule() since it knows the MAX value of colors
223
224//#endif
225#endif
226 }
227 SerialDebug.println("*********");
228
229#endif
230 }
231
232 /*******************************MQTT*************************************/
233
234 };
235
236 /** Called before notification or indication is sent,
237 the value can be changed here before sending if desired.
238 */
239 void onNotify(NimBLECharacteristic * pCharacteristic)
240 {
241 SerialDebug.println("Sending notification to clients");
242 };
243
244
245 /** The status returned in status is defined in NimBLECharacteristic.h.
246 The value returned in code is the NimBLE host return code.
247 */
248 void onStatus(NimBLECharacteristic * pCharacteristic, Status status, int code)
249 {
250#if (SERIAL_DEBUG_DEBUG)
251 String str = ("Notification/Indication status code: ");
252 str += status;
253 str += ", return code: ";
254 str += code;
255 str += ", ";
256 str += NimBLEUtils::returnCodeToString(code);
257 SerialDebug.println(str);
258#endif //serial_debug_debug
259 };
260
261 void onSubscribe(NimBLECharacteristic * pCharacteristic, ble_gap_conn_desc * desc, uint16_t subValue)
262 {
263#if (SERIAL_DEBUG_DEBUG)
264
265 String str = "Client ID: ";
266 str += desc->conn_handle;
267 str += " Address: ";
268 str += std::string(NimBLEAddress(desc->peer_ota_addr)).c_str();
269 if (subValue == 0) {
270 str += " Unsubscribed to ";
271 }
272 else if (subValue == 1) {
273 str += " Subscribed to notfications for ";
274 }
275 else if (subValue == 2) {
276 str += " Subscribed to indications for ";
277 }
278 else if (subValue == 3) {
279 str += " Subscribed to notifications and indications for ";
280 }
281 str += std::string(pCharacteristic->getUUID()).c_str();
282
283 SerialDebug.println(str);
284#endif //serial_debug_debug
285 };
286};
287
288/** Handler class for descriptor actions */
289class BLEServerNetworkingDescriptorCallbacks : public NimBLEDescriptorCallbacks
290{
291 void onWrite(NimBLEDescriptor* pDescriptor)
292 {
293#if (SERIAL_DEBUG_DEBUG)
294
295#define VERSION_1_4_1
296#ifdef VERSION_1_4_1
297 SerialDebug.print("Descriptor written value:");
298 SerialDebug.println(pDescriptor->getValue());
299#else
300 std::string dscVal((char*)pDescriptor->getValue(), pDescriptor->getLength());
301 SerialDebug.print("Descriptor written value:");
302 SerialDebug.println(dscVal.c_str());
303#endif
304
305#endif
306 };
307
308 void onRead(NimBLEDescriptor* pDescriptor)
309 {
310 SerialDebug.print(pDescriptor->getUUID().toString().c_str());
311 SerialDebug.println("Descriptor read");
312 SerialDebug.printf(" DeviceName = %s\n", _deviceName_BLEServer?_deviceName_BLEServer:"nil");
313 };
314};
315
316
317/** Define callback instances globally to use for multiple Charateristics \ Descriptors */
318//static DescriptorCallbacks dscCallbacks;
319//static CharacteristicCallbacks chrCallbacks;
320
321
322/** Define callback instances globally to use for multiple Charateristics \ Descriptors */
323static BLEServerNetworkingDescriptorCallbacks _descriptorBLEServerCallbacks;
324static BLEServerNetworkingCharacteristicCallbacks _characteristicBLEServerCallbacks;
325
326//!the 'loop' for this module BLEServerNetworking.
328{
329
330 // SerialDebug.printf("# Clients: %d \n\r", pServer->getConnectedCount()); // nimconfig.h can change the max clients allowed(up to 9). default is 3 wha
331#ifdef originalApproach
332 if (_pBLEServer->getConnectedCount()) {
333 NimBLEService* pSvc = pServer->getServiceByUUID("BAAD");
334 if (pSvc) {
335 NimBLECharacteristic* pChr = pSvc->getCharacteristic("F00D");
336 if (pChr) {
337 pChr->notify(true);
338 }
339 }
340 }
341#endif
342#ifdef pettutorApproach
343 if (_pBLEServer->getConnectedCount()) {
344 NimBLEService* pSvc = _pBLEServer->getServiceByUUID(_SERVICE_UUID);
345 if (pSvc) {
346 NimBLECharacteristic* pChr = pSvc->getCharacteristic(_CHARACTERISTIC_UUID);
347 if (pChr) {
348 pChr->notify(true);
349 }
350 }
351 }
352#endif
353}
354//!the 'setup' for this module BLEServerNetworking. Here the service name is added (and potentially more later)
355void setup_BLEServerNetworking(char *serviceName, char * deviceName, char *serviceUUID, char *characteristicUUID)
356{
357
358 _SERVICE_UUID = serviceUUID;
359 _CHARACTERISTIC_UUID = characteristicUUID;
360
361 SerialMin.printf("setupBLEServerNetworking(%s,%s,%s,%s)\n", serviceName?serviceName:"NULL", deviceName?deviceName:"NULL", serviceUUID?serviceUUID:"NULL", characteristicUUID?characteristicUUID:"NULL");
362
363 char *storedDeviceName = deviceName_mainModule();
364 SerialTemp.print("Stored DeviceName = ");
365 SerialTemp.println(storedDeviceName);
366 if (strcmp(serviceName, "PTClicker")==0)
367 {
368 //! currently not using the option, just doing it...
369 sprintf(_serviceName_BLEServer, "%s:%s", serviceName, storedDeviceName);
370 }
371 else
372 {
373#ifdef FORCE_USE_BLE_SERVER_DEVICE_NAME
374 if (true)
375#else
377#endif
378 {
379 sprintf(_serviceName_BLEServer, "%s:%s", serviceName, storedDeviceName);
380 }
381 else
382 {
383 strcpy(_serviceName_BLEServer, serviceName);
384 }
385 }
386 SerialMin.print("Setting BLE serviceName: ");
387 SerialMin.println(_serviceName_BLEServer);
388
389 /** sets device name */
390 //??original NimBLEDevice::init("NimBLE-Arduino");
391 // NimBLEDevice::init("PTFeeder");
392 //NimBLEDevice::init(serviceName);
393 NimBLEDevice::init(_serviceName_BLEServer);
394
395 /** Optional: set the transmit power, default is 3db */
396 NimBLEDevice::setPower(ESP_PWR_LVL_P9); /** +9db */
397
398 /** Set the IO capabilities of the device, each option will trigger a different pairing method.
399 BLE_HS_IO_DISPLAY_ONLY - Passkey pairing
400 BLE_HS_IO_DISPLAY_YESNO - Numeric comparison pairing
401 BLE_HS_IO_NO_INPUT_OUTPUT - DEFAULT setting - just works pairing
402 */
403 //NimBLEDevice::setSecurityIOCap(BLE_HS_IO_DISPLAY_ONLY); // use passkey
404 //NimBLEDevice::setSecurityIOCap(BLE_HS_IO_DISPLAY_YESNO); //use numeric comparison
405
406 /** 2 different ways to set security - both calls achieve the same result.
407 no bonding, no man in the middle protection, secure connections.
408
409 These are the default values, only shown here for demonstration.
410 */
411 //NimBLEDevice::setSecurityAuth(false, false, true);
412 NimBLEDevice::setSecurityAuth(/*BLE_SM_PAIR_AUTHREQ_BOND | BLE_SM_PAIR_AUTHREQ_MITM |*/ BLE_SM_PAIR_AUTHREQ_SC);
413 //** NOTE: DEAD is a hex string .. and BEEF is too, so they are not really strings but UUID's in HEX.
414
415 _pBLEServer = NimBLEDevice::createServer();
416 _pBLEServer->setCallbacks(new BLEServerCallbacks());
417 /****************** DEAD service BEEF characteristic 2904notify,R/W/W_ENC(pairing REQUIRED!) ********************/
418 NimBLEService* pDeadService = _pBLEServer->createService("DEAD");
419 //?? NimBLEService* pDeadService = pServer->createService(SERVICE_UUID);
420 NimBLECharacteristic* pBeefCharacteristic = pDeadService->createCharacteristic(
421 "BEEF",
422 //?? NimBLECharacteristic * pBeefCharacteristic = pDeadService->createCharacteristic(
423 //?? CHARACTERISTIC_UUID,
424 NIMBLE_PROPERTY::READ |
425 NIMBLE_PROPERTY::WRITE |
426 /** Require a secure connection for read and write access */
427 NIMBLE_PROPERTY::READ_ENC | // only allow reading if paired / encrypted
428 NIMBLE_PROPERTY::WRITE_ENC // only allow writing if paired / encrypted
429 );
430 //NOTE: IS THIS RIGHT? vs the other characteristic?? 5.19.22
431 //assign to global: It's the Food charactestic..
432#ifdef OLD_BLE_NO_ACK_APPROACH
433 _pCharacteristic = pBeefCharacteristic;
434#endif
435
436
437
438 /*******************************MQTT*************************************/
439 //#ifdef MQTT_NETWORKING
440 pBeefCharacteristic->setValue(deviceName);
441
442 //#else
443 // pBeefCharacteristic->setValue("Burger");
444 //#endif
445 /*******************************MQTT*************************************/
446
447 pBeefCharacteristic->setCallbacks(&_characteristicBLEServerCallbacks);
448
449 /** 2904 descriptors are a special case, when createDescriptor is called with
450 0x2904 a NimBLE2904 class is created with the correct properties and sizes.
451 However we must cast the returned reference to the correct type as the method
452 only returns a pointer to the base NimBLEDescriptor class.
453 */
454 NimBLE2904* pBeef2904 = (NimBLE2904*)pBeefCharacteristic->createDescriptor("2904");
455 pBeef2904->setFormat(NimBLE2904::FORMAT_UTF8);
456 pBeef2904->setCallbacks(&_descriptorBLEServerCallbacks);
457
458 /******** BAAD service F00D characteristic R/W/N C01D Descriptor ********************************/
459#ifdef originalApproach
460 NimBLEService* pBaadService = pServer->createService("BAAD");
461 NimBLECharacteristic* pFoodCharacteristic = pBaadService->createCharacteristic(
462 "F00D",
463 NIMBLE_PROPERTY::READ |
464 NIMBLE_PROPERTY::WRITE |
465 NIMBLE_PROPERTY::NOTIFY
466 );
467#endif
468#ifdef pettutorApproach
469 NimBLEService* pBaadService = _pBLEServer->createService(_SERVICE_UUID);
470 NimBLECharacteristic* pFoodCharacteristic = pBaadService->createCharacteristic(
472 NIMBLE_PROPERTY::READ |
473 NIMBLE_PROPERTY::WRITE // |
474 // NIMBLE_PROPERTY::NOTIFY
475 );
476#endif
477
478#ifdef originalApproach
479 pFoodCharacteristic->setValue("Fries");
480#endif
481
482 pFoodCharacteristic->setCallbacks(&_characteristicBLEServerCallbacks);
483
484 /** Note a 0x2902 descriptor MUST NOT be created as NimBLE will create one automatically
485 if notification or indication properties are assigned to a characteristic.
486 */
487
488#ifdef originalApproach
489 /** Custom descriptor: Arguments are UUID, Properties, max length in bytes of the value */
490 NimBLEDescriptor* pC01Ddsc = pFoodCharacteristic->createDescriptor(
491 "C01D",
492 NIMBLE_PROPERTY::READ |
493 NIMBLE_PROPERTY::WRITE |
494 NIMBLE_PROPERTY::WRITE_ENC, // only allow writing if paired / encrypted
495 20
496 );
497 pC01Ddsc->setValue("Send it back!");
498 pC01Ddsc->setCallbacks(&dscCallbacks);
499#endif
500#ifdef pettutorApproach
501 /** Custom descriptor: Arguments are UUID, Properties, max length in bytes of the value */
502 NimBLEDescriptor* pPetTutordsc = pFoodCharacteristic->createDescriptor(
503 "C01D", //the UUID is 0xC01D
504 NIMBLE_PROPERTY::READ |
505 NIMBLE_PROPERTY::WRITE |
506 20
507 );
508 pPetTutordsc->setValue("feed s/a/j type u/m ");
509 pPetTutordsc->setCallbacks(&_descriptorBLEServerCallbacks);
510#endif
511
512#ifdef CURRENT_BLE_ACK_APPROACH
513 //THIS IS RIGHT characteristic
514 _pCharacteristic = pFoodCharacteristic;
515 // end setup of services and characteristics
516#endif
517
518//#define TRY_THIRD_SERVICE_WITH_NAME
519#ifdef TRY_THIRD_SERVICE_WITH_NAME
520#define DEVICE_NAME_UUID "53636F74-7479426F79" //ScottyBoy
521#define DEVICE_NAME_SERVICE "6E616D65" //name
522 /****************** DEAD service BEEF characteristic 2904notify,R/W/W_ENC(pairing REQUIRED!) ********************/
523 NimBLEService* pNameService = _pBLEServer->createService(DEVICE_NAME_SERVICE);
524 //?? NimBLEService* pDeadService = pServer->createService(SERVICE_UUID);
525 NimBLECharacteristic* pNameCharacteristic = pNameService->createCharacteristic(
526 DEVICE_NAME_UUID,
527 //?? NimBLECharacteristic * pBeefCharacteristic = pDeadService->createCharacteristic(
528 //?? CHARACTERISTIC_UUID,
529 NIMBLE_PROPERTY::READ |
530 NIMBLE_PROPERTY::WRITE |
531 /** Require a secure connection for read and write access */
532 NIMBLE_PROPERTY::READ_ENC | // only allow reading if paired / encrypted
533 NIMBLE_PROPERTY::WRITE_ENC // only allow writing if paired / encrypted
534 );
535
536
537 /*******************************MQTT*************************************/
538 //#ifdef MQTT_NETWORKING
539 pNameCharacteristic->setValue(deviceName);
540
541 //#else
542 // pBeefCharacteristic->setValue("Burger");
543 //#endif
544 /*******************************MQTT*************************************/
545
546 pNameCharacteristic->setCallbacks(&_characteristicBLEServerCallbacks);
547
548 /** 2904 descriptors are a special case, when createDescriptor is called with
549 0x2904 a NimBLE2904 class is created with the correct properties and sizes.
550 However we must cast the returned reference to the correct type as the method
551 only returns a pointer to the base NimBLEDescriptor class.
552 */
553 NimBLE2904* pName2904 = (NimBLE2904*)pNameCharacteristic->createDescriptor("2904");
554 pName2904->setFormat(NimBLE2904::FORMAT_UTF8);
555 pName2904->setCallbacks(&_descriptorBLEServerCallbacks);
556 pNameService->start();
557
558#endif
559
560 /** Start the services when finished creating all Characteristics and Descriptors */
561 pDeadService->start();
562 pBaadService->start();
563
564 NimBLEAdvertising* pAdvertising = NimBLEDevice::getAdvertising();
565 /** Add the services to the advertisment data **/
566 pAdvertising->addServiceUUID(pDeadService->getUUID());
567 pAdvertising->addServiceUUID(pBaadService->getUUID());
568 /** If your device is battery powered you may consider setting scan response
569 to false as it will extend battery life at the expense of less data sent.
570 */
571#ifdef TRY_THIRD_SERVICE_WITH_NAME
572 pAdvertising->addServiceUUID(pNameService->getUUID());
573
574#endif
575 pAdvertising->setScanResponse(true);
576 pAdvertising->start();
577 //try the user supplied local name: Local Name == ScottyBoy in Advertisment
578// char *storedDeviceName = deviceName_mainModule();
579// SerialTemp.print("Stored DeviceName = ");
580// SerialTemp.println(storedDeviceName);
581 //!setName shows up ad LocalName in Punchthrough Scanner, but
582 // pAdvertising->setName(storedDeviceName);
583
584
585 SerialInfo.println("Advertising Started");
586}
587
588
589//!send ACK over bluetooth, this right now is 0x01
591{
592 SerialTemp.printf("%d sendBLEMessageACKMessage._pCharacteristic\n", _pCharacteristic);
593 _pCharacteristic->setValue(0x01); //?? This is the acknowlege(ACK) back to client. Later this should be contigent on a feed completed
594}
595
596
void setBLEServerDeviceName(char *deviceName)
sets the device name
void loop_BLEServerNetworking()
the 'loop' for this module BLEServerNetworking.
#define MAX_MESSAGE
void sendBLEMessageACKMessage()
send ACK over bluetooth, this right now is 0x01
char _asciiMessage[MAX_MESSAGE]
char * getServiceName_BLEServerNetworking()
retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc)
char * _CHARACTERISTIC_UUID
char _serviceName_BLEServer[50]
NimBLECharacteristic * _pCharacteristic
char * _SERVICE_UUID
need to device way to change these ...
char * _deviceName_BLEServer
device name
void setup_BLEServerNetworking(char *serviceName, char *deviceName, char *serviceUUID, char *characteristicUUID)
the 'setup' for this module BLEServerNetworking. Here the service name is added (and potentially more...
#define BLE_SERVER_CALLBACK_ONWRITE
void addToTextMessages_displayModule(String text)
void incrementScreenColor_displayModule()
void showText_displayModule(String text)
char * deviceName_mainModule()
gets the device name
Definition: MainModule.cpp:607
#define CALLBACKS_BLE_SERVER
Definition: MainModule.cpp:224
void processClientCommandChar_mainModule(char cmd)
single character version of processClientCommand (since many used that already)
void callCallbackMain(int callbacksModuleId, int callbackType, char *message)
performs the indirect callback based on the callbackType
Definition: MainModule.cpp:333
boolean getPreferenceBoolean_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
#define PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
Note: the onRead and onWrite are from the perspective of the client. So onRead is the client calling ...