Fix handling of registerForNotify in BLERemoteCharacteristic.cpp (#4063)

This commit is contained in:
buxtronix 2020-09-30 22:20:28 +10:00 committed by GitHub
parent 11d071b1c8
commit 342b9cf2d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -467,7 +467,8 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
uint8_t val[] = {0x01, 0x00}; uint8_t val[] = {0x01, 0x00};
if(!notifications) val[0] = 0x02; if(!notifications) val[0] = 0x02;
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902)); BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
desc->writeValue(val, 2); if (desc != nullptr)
desc->writeValue(val, 2);
} // End Register } // End Register
else { // If we weren't passed a callback function, then this is an unregistration. else { // If we weren't passed a callback function, then this is an unregistration.
esp_err_t errRc = ::esp_ble_gattc_unregister_for_notify( esp_err_t errRc = ::esp_ble_gattc_unregister_for_notify(
@ -482,7 +483,8 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
uint8_t val[] = {0x00, 0x00}; uint8_t val[] = {0x00, 0x00};
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902); BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
desc->writeValue(val, 2); if (desc != nullptr)
desc->writeValue(val, 2);
} // End Unregister } // End Unregister
m_semaphoreRegForNotifyEvt.wait("registerForNotify"); m_semaphoreRegForNotifyEvt.wait("registerForNotify");