Skip to content

Commit 342b9cf

Browse files
authored
Fix handling of registerForNotify in BLERemoteCharacteristic.cpp (#4063)
1 parent 11d071b commit 342b9cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: libraries/BLE/src/BLERemoteCharacteristic.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
467467
uint8_t val[] = {0x01, 0x00};
468468
if(!notifications) val[0] = 0x02;
469469
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
470-
desc->writeValue(val, 2);
470+
if (desc != nullptr)
471+
desc->writeValue(val, 2);
471472
} // End Register
472473
else { // If we weren't passed a callback function, then this is an unregistration.
473474
esp_err_t errRc = ::esp_ble_gattc_unregister_for_notify(
@@ -482,7 +483,8 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
482483

483484
uint8_t val[] = {0x00, 0x00};
484485
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
485-
desc->writeValue(val, 2);
486+
if (desc != nullptr)
487+
desc->writeValue(val, 2);
486488
} // End Unregister
487489

488490
m_semaphoreRegForNotifyEvt.wait("registerForNotify");

0 commit comments

Comments
 (0)