@@ -475,7 +475,7 @@ void BLERemoteCharacteristic::registerForNotify(
475
475
BLERemoteCharacteristic* pBLERemoteCharacteristic,
476
476
uint8_t * pData,
477
477
size_t length,
478
- bool isNotify)) {
478
+ bool isNotify), bool notifications ) {
479
479
ESP_LOGD (LOG_TAG, " >> registerForNotify(): %s" , toString ().c_str ());
480
480
481
481
m_notifyCallback = notifyCallback; // Save the notification callback.
@@ -492,6 +492,12 @@ void BLERemoteCharacteristic::registerForNotify(
492
492
if (errRc != ESP_OK) {
493
493
ESP_LOGE (LOG_TAG, " esp_ble_gattc_register_for_notify: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
494
494
}
495
+
496
+ uint8_t val[] = {0x01 , 0x00 };
497
+ if (!notifications)
498
+ val[0 ] = 0x02 ;
499
+ BLERemoteDescriptor *desc = getDescriptorByUUID (" 0x2902" );
500
+ desc->writeValue (val, 2 );
495
501
} // End Register
496
502
else { // If we weren't passed a callback function, then this is an unregistration.
497
503
esp_err_t errRc = ::esp_ble_gattc_unregister_for_notify (
@@ -503,6 +509,10 @@ void BLERemoteCharacteristic::registerForNotify(
503
509
if (errRc != ESP_OK) {
504
510
ESP_LOGE (LOG_TAG, " esp_ble_gattc_unregister_for_notify: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
505
511
}
512
+
513
+ uint8_t val[] = {0x00 , 0x00 };
514
+ BLERemoteDescriptor *desc = getDescriptorByUUID (" 0x2902" );
515
+ desc->writeValue (val, 2 );
506
516
} // End Unregister
507
517
508
518
m_semaphoreRegForNotifyEvt.wait (" registerForNotify" );
0 commit comments