8000 Fix #803 · rabikkk/esp32-snippets@43491c7 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit 43491c7

Browse files
committed
1 parent 8fac333 commit 43491c7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cpp_utils/BLECharacteristic.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
0