@@ -453,7 +453,7 @@ std::string BLERemoteCharacteristic::readValue() {
453453 * unregistering a notification.
454454 * @return N/A.
455455 */
456- void BLERemoteCharacteristic::registerForNotify (notify_callback notifyCallback, bool notifications) {
456+ void BLERemoteCharacteristic::registerForNotify (notify_callback notifyCallback, bool notifications, bool descriptorRequiresRegistration ) {
457457 log_v (" >> registerForNotify(): %s" , toString ().c_str ());
458458
459459 m_notifyCallback = notifyCallback; // Save the notification callback.
@@ -474,7 +474,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
474474 uint8_t val[] = {0x01 , 0x00 };
475475 if (!notifications) val[0 ] = 0x02 ;
476476 BLERemoteDescriptor* desc = getDescriptor (BLEUUID ((uint16_t )0x2902 ));
477- if (desc != nullptr )
477+ if (desc != nullptr && descriptorRequiresRegistration )
478478 desc->writeValue (val, 2 , true );
479479 } // End Register
480480 else { // If we weren't passed a callback function, then this is an unregistration.
@@ -490,7 +490,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
490490
491491 uint8_t val[] = {0x00 , 0x00 };
492492 BLERemoteDescriptor* desc = getDescriptor ((uint16_t )0x2902 );
493- if (desc != nullptr )
493+ if (desc != nullptr && descriptorRequiresRegistration )
494494 desc->writeValue (val, 2 , true );
495495 } // End Unregister
496496
0 commit comments