summaryrefslogtreecommitdiff
path: root/src/BLEService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BLEService.cpp')
-rw-r--r--src/BLEService.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/BLEService.cpp b/src/BLEService.cpp
index 669ed26..32bcc57 100644
--- a/src/BLEService.cpp
+++ b/src/BLEService.cpp
@@ -22,6 +22,10 @@
#include "BLEUtils.h"
#include "GeneralUtils.h"
+#ifdef ARDUINO_ARCH_ESP32
+#include "esp32-hal-log.h"
+#endif
+
#define NULL_HANDLE (0xffff)
static const char* LOG_TAG = "BLEService"; // Tag for logging.
@@ -189,12 +193,12 @@ void BLEService::addCharacteristic(BLECharacteristic* pCharacteristic) {
// Check that we don't add the same characteristic twice.
if (m_characteristicMap.getByUUID(pCharacteristic->getUUID()) != nullptr) {
ESP_LOGE(LOG_TAG, "<< Attempt to add a characteristic but we already have one with this UUID");
- return;
+ //return;
}
// Remember this characteristic in our map of characteristics. At this point, we can lookup by UUID
// but not by handle. The handle is allocated to us on the ESP_GATTS_ADD_CHAR_EVT.
- m_characteristicMap.setByUUID(pCharacteristic->getUUID(), pCharacteristic);
+ m_characteristicMap.setByUUID(pCharacteristic, pCharacteristic->getUUID());
ESP_LOGD(LOG_TAG, "<< addCharacteristic()");
} // addCharacteristic
@@ -245,7 +249,7 @@ void BLEService::handleGATTServerEvent(
// for that characteristic.
case ESP_GATTS_ADD_CHAR_EVT: {
if (m_handle == param->add_char.service_handle) {
- BLECharacteristic *pCharacteristic = getCharacteristic(BLEUUID(param->add_char.char_uuid));
+ BLECharacteristic *pCharacteristic = getLastCreatedCharacteristic();
if (pCharacteristic == nullptr) {
ESP_LOGE(LOG_TAG, "Expected to find characteristic with UUID: %s, but didnt!",
BLEUUID(param->add_char.char_uuid).toString().c_str());