Skip to content

Commit

Permalink
Merge pull request nkolban#807 from chegewara/master
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
chegewara committed Feb 8, 2019
2 parents 107704b + 43491c7 commit bf4fbde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cpp_utils/BLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ void BLECharacteristic::handleGATTServerEvent(
m_value.addPart(param->write.value, param->write.len);
m_writeEvt = true;
} else {
setValue(param->write.value, param->write.len);
if (m_pCallbacks != nullptr && param->write.is_prep != true) {
m_pCallbacks->onWrite(this); // Invoke the onWrite callback handler.
}
setValue(param->write.value, param->write.len);
}

ESP_LOGD(LOG_TAG, " - Response to write event: New value: handle: %.2x, uuid: %s",
Expand Down Expand Up @@ -503,7 +503,11 @@ void BLECharacteristic::notify(bool is_notification) {
// Test to see if we have a 0x2902 descriptor. If we do, then check to see if notification is enabled
// and, if not, prevent the notification.

BLE2902 *p2902 = (BLE2902*)getDescriptorByUUID((uint16_t)0x2902);
BLE2902* p2902 = (BLE2902*)getDescriptorByUUID((uint16_t)0x2902);
if(p2902 == nullptr){
ESP_LOGE(LOG_TAG, "Characteristic without 0x2902 descriptor");
return;
}
if(is_notification) {
if (p2902 != nullptr && !p2902->getNotifications()) {
ESP_LOGD(LOG_TAG, "<< notifications disabled; ignoring");
Expand Down Expand Up @@ -537,7 +541,6 @@ void BLECharacteristic::notify(bool is_notification) {
if(!is_notification)
m_semaphoreConfEvt.wait("indicate");
}
delete(p2902);
ESP_LOGD(LOG_TAG, "<< notify");
} // Notify

Expand Down
2 changes: 2 additions & 0 deletions cpp_utils/tests/BLETests/Arduino/BLE_client/BLE_client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ bool connectToServer(BLEAddress pAddress) {
Serial.println(value.c_str());

pRemoteCharacteristic->registerForNotify(notifyCallback);

return true;
}
/**
* Scan for BLE servers and find the first one that advertises the service we are looking for.
Expand Down

0 comments on commit bf4fbde

Please sign in to comment.