8000 Merge pull request #807 from chegewara/master · mariansoban/esp32-snippets@bf4fbde · GitHub
[go: up one dir, main page]

Skip to content

Commit bf4fbde

Browse files
authored
Merge pull request nkolban#807 from chegewara/master
Minor fixes
2 parents 107704b + 43491c7 commit bf4fbde

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-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

cpp_utils/tests/BLETests/Arduino/BLE_client/BLE_client.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ bool connectToServer(BLEAddress pAddress) {
6262
Serial.println(value.c_str());
6363

6464
pRemoteCharacteristic->registerForNotify(notifyCallback);
65+
66+
return true;
6567
}
6668
/**
6769
* Scan for BLE servers and find the first one that advertises the service we are looking for.

0 commit comments

Comments
 (0)
0