@@ -453,7 +453,7 @@ std::string BLERemoteCharacteristic::readValue() {
453
453
* unregistering a notification.
454
454
* @return N/A.
455
455
*/
456
- void BLERemoteCharacteristic::registerForNotify (notify_callback notifyCallback, bool notifications) {
456
+ void BLERemoteCharacteristic::registerForNotify (notify_callback notifyCallback, bool notifications, bool descriptorRequiresRegistration ) {
457
457
log_v (" >> registerForNotify(): %s" , toString ().c_str ());
458
458
459
459
m_notifyCallback = notifyCallback; // Save the notification callback.
@@ -474,7 +474,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
474
474
uint8_t val[] = {0x01 , 0x00 };
475
475
if (!notifications) val[0 ] = 0x02 ;
476
476
BLERemoteDescriptor* desc = getDescriptor (BLEUUID ((uint16_t )0x2902 ));
477
- if (desc != nullptr )
477
+ if (desc != nullptr && descriptorRequiresRegistration )
478
478
desc->writeValue (val, 2 , true );
479
479
} // End Register
480
480
else { // If we weren't passed a callback function, then this is an unregistration.
@@ -490,7 +490,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
490
490
491
491
uint8_t val[] = {0x00 , 0x00 };
492
492
BLERemoteDescriptor* desc = getDescriptor ((uint16_t )0x2902 );
493
- if (desc != nullptr )
493
+ if (desc != nullptr && descriptorRequiresRegistration )
494
494
desc->writeValue (val, 2 , true );
495
495
} // End Unregister
496
496
0 commit comments