@@ -289,10 +289,10 @@ void BLECharacteristic::handleGATTServerEvent(
289289 m_value.addPart (param->write .value , param->write .len );
290290 m_writeEvt = true ;
291291 } else {
292+ setValue (param->write .value , param->write .len );
292293 if (m_pCallbacks != nullptr && param->write .is_prep != true ) {
293294 m_pCallbacks->onWrite (this ); // Invoke the onWrite callback handler.
294295 }
295- setValue (param->write .value , param->write .len );
296296 }
297297
298298 ESP_LOGD (LOG_TAG, " - Response to write event: New value: handle: %.2x, uuid: %s" ,
@@ -503,7 +503,11 @@ void BLECharacteristic::notify(bool is_notification) {
503503 // Test to see if we have a 0x2902 descriptor. If we do, then check to see if notification is enabled
504504 // and, if not, prevent the notification.
505505
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+ }
507511 if (is_notification) {
508512 if (p2902 != nullptr && !p2902->getNotifications ()) {
509513 ESP_LOGD (LOG_TAG, " << notifications disabled; ignoring" );
@@ -537,7 +541,6 @@ void BLECharacteristic::notify(bool is_notification) {
537541 if (!is_notification)
538542 m_semaphoreConfEvt.wait (" indicate" );
539543 }
540- delete (p2902);
541544 ESP_LOGD (LOG_TAG, " << notify" );
542545} // Notify
543546
0 commit comments