@@ -289,10 +289,10 @@ void BLECharacteristic::handleGATTServerEvent(
289
289
m_value.addPart (param->write .value , param->write .len );
290
290
m_writeEvt = true ;
291
291
} else {
292
+ setValue (param->write .value , param->write .len );
292
293
if (m_pCallbacks != nullptr && param->write .is_prep != true ) {
293
294
m_pCallbacks->onWrite (this ); // Invoke the onWrite callback handler.
294
295
}
295
- setValue (param->write .value , param->write .len );
296
296
}
297
297
298
298
ESP_LOGD (LOG_TAG, " - Response to write event: New value: handle: %.2x, uuid: %s" ,
@@ -503,7 +503,11 @@ void BLECharacteristic::notify(bool is_notification) {
503
503
// Test to see if we have a 0x2902 descriptor. If we do, then check to see if notification is enabled
504
504
// and, if not, prevent the notification.
505
505
506
- BLE2902 *p2902 = (BLE2902*)getDescriptorByUUID ((uint16_t )0x2902 );
506
+ BLE2902* p2902 = (BLE2902*)getDescriptorByUUID ((uint16_t )0x2902 );
507
+ if (p2902 == nullptr ){
508
+ ESP_LOGE (LOG_TAG, " Characteristic without 0x2902 descriptor" );
509
+ return ;
510
+ }
507
511
if (is_notification) {
508
512
if (p2902 != nullptr && !p2902->getNotifications ()) {
509
513
ESP_LOGD (LOG_TAG, " << notifications disabled; ignoring" );
@@ -537,7 +541,6 @@ void BLECharacteristic::notify(bool is_notification) {
537
541
if (!is_notification)
538
542
m_semaphoreConfEvt.wait (" indicate" );
539
543
}
540
- delete (p2902);
541
544
ESP_LOGD (LOG_TAG, " << notify" );
542
545
} // Notify
543
546
0 commit comments