From cb1ab4ea76af17d347cdadcc003d1fe53af12aa7 Mon Sep 17 00:00:00 2001 From: kolban Date: Sun, 15 Oct 2017 12:56:03 -0500 Subject: Fixes for #121 --- library.properties | 2 +- src/BLEAddress.cpp | 3 +++ src/BLEAdvertisedDevice.cpp | 3 +++ src/BLEAdvertising.cpp | 3 +++ src/BLECharacteristic.cpp | 3 +++ src/BLECharacteristicCallbacks.cpp | 3 +++ src/BLECharacteristicMap.cpp | 3 +++ src/BLEClient.cpp | 3 +++ src/BLEDescriptor.cpp | 3 +++ src/BLEDescriptorMap.cpp | 3 +++ src/BLEDevice.cpp | 3 +++ src/BLERemoteCharacteristic.cpp | 3 +++ src/BLERemoteDescriptor.cpp | 3 +++ src/BLERemoteService.cpp | 3 +++ src/BLEScan.cpp | 3 +++ src/BLEServer.cpp | 4 +++- src/BLEService.cpp | 7 ++++++- src/BLEService.h | 6 ++++-- src/BLEValue.cpp | 3 +++ src/FreeRTOS.cpp | 8 ++++++-- src/FreeRTOS.h | 12 ++++++------ 21 files changed, 71 insertions(+), 13 deletions(-) diff --git a/library.properties b/library.properties index 779706d..f473071 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESP32 BLE Arduino -version=0.4.5 +version=0.4.6 author=Neil Kolban maintainer=Neil Kolban sentence=BLE functions for ESP32 diff --git a/src/BLEAddress.cpp b/src/BLEAddress.cpp index d2f7f8b..895feda 100644 --- a/src/BLEAddress.cpp +++ b/src/BLEAddress.cpp @@ -13,6 +13,9 @@ #include #include #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif /** diff --git a/src/BLEAdvertisedDevice.cpp b/src/BLEAdvertisedDevice.cpp index 5074b81..83869cf 100644 --- a/src/BLEAdvertisedDevice.cpp +++ b/src/BLEAdvertisedDevice.cpp @@ -17,6 +17,9 @@ #include #include "BLEAdvertisedDevice.h" #include "BLEUtils.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG="BLEAdvertisedDevice"; BLEAdvertisedDevice::BLEAdvertisedDevice() { diff --git a/src/BLEAdvertising.cpp b/src/BLEAdvertising.cpp index 2647966..e5179a4 100644 --- a/src/BLEAdvertising.cpp +++ b/src/BLEAdvertising.cpp @@ -12,6 +12,9 @@ #include #include "BLEUtils.h" #include "GeneralUtils.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLEAdvertising"; diff --git a/src/BLECharacteristic.cpp b/src/BLECharacteristic.cpp index 284032e..18ba65d 100644 --- a/src/BLECharacteristic.cpp +++ b/src/BLECharacteristic.cpp @@ -18,6 +18,9 @@ #include "BLEUtils.h" #include "BLE2902.h" #include "GeneralUtils.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLECharacteristic"; diff --git a/src/BLECharacteristicCallbacks.cpp b/src/BLECharacteristicCallbacks.cpp index b733865..46905b5 100644 --- a/src/BLECharacteristicCallbacks.cpp +++ b/src/BLECharacteristicCallbacks.cpp @@ -8,6 +8,9 @@ #if defined(CONFIG_BT_ENABLED) #include "BLECharacteristic.h" #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLECharacteristicCallbacks"; diff --git a/src/BLECharacteristicMap.cpp b/src/BLECharacteristicMap.cpp index 6ded0a6..bcf4a75 100644 --- a/src/BLECharacteristicMap.cpp +++ b/src/BLECharacteristicMap.cpp @@ -9,6 +9,9 @@ #include #include #include "BLEService.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif /** diff --git a/src/BLEClient.cpp b/src/BLEClient.cpp index 645c4ae..93f703a 100644 --- a/src/BLEClient.cpp +++ b/src/BLEClient.cpp @@ -18,6 +18,9 @@ #include #include #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif /* * Design diff --git a/src/BLEDescriptor.cpp b/src/BLEDescriptor.cpp index 4a7fda6..8362af0 100644 --- a/src/BLEDescriptor.cpp +++ b/src/BLEDescriptor.cpp @@ -16,6 +16,9 @@ #include "BLEService.h" #include "BLEDescriptor.h" #include "GeneralUtils.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLEDescriptor"; diff --git a/src/BLEDescriptorMap.cpp b/src/BLEDescriptorMap.cpp index b211652..4e372e1 100644 --- a/src/BLEDescriptorMap.cpp +++ b/src/BLEDescriptorMap.cpp @@ -11,6 +11,9 @@ #include "BLECharacteristic.h" #include "BLEDescriptor.h" #include // ESP32 BLE +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif /** * @brief Return the descriptor by UUID. diff --git a/src/BLEDevice.cpp b/src/BLEDevice.cpp index b2777e5..97d02b1 100644 --- a/src/BLEDevice.cpp +++ b/src/BLEDevice.cpp @@ -26,6 +26,9 @@ #include "BLEClient.h" #include "BLEUtils.h" #include "GeneralUtils.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLEDevice"; diff --git a/src/BLERemoteCharacteristic.cpp b/src/BLERemoteCharacteristic.cpp index 2e0fbb0..ba781d2 100644 --- a/src/BLERemoteCharacteristic.cpp +++ b/src/BLERemoteCharacteristic.cpp @@ -18,6 +18,9 @@ #include "BLEUtils.h" #include "GeneralUtils.h" #include "BLERemoteDescriptor.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLERemoteCharacteristic"; // The logging tag for this class. diff --git a/src/BLERemoteDescriptor.cpp b/src/BLERemoteDescriptor.cpp index a606929..7a509f8 100644 --- a/src/BLERemoteDescriptor.cpp +++ b/src/BLERemoteDescriptor.cpp @@ -10,6 +10,9 @@ #include "BLERemoteDescriptor.h" #include "GeneralUtils.h" #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLERemoteDescriptor"; diff --git a/src/BLERemoteService.cpp b/src/BLERemoteService.cpp index c312e94..c0df06c 100644 --- a/src/BLERemoteService.cpp +++ b/src/BLERemoteService.cpp @@ -13,6 +13,9 @@ #include "GeneralUtils.h" #include #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLERemoteService"; diff --git a/src/BLEScan.cpp b/src/BLEScan.cpp index 925c09d..d3157b7 100644 --- a/src/BLEScan.cpp +++ b/src/BLEScan.cpp @@ -17,6 +17,9 @@ #include "BLEScan.h" #include "BLEUtils.h" #include "GeneralUtils.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLEScan"; diff --git a/src/BLEServer.cpp b/src/BLEServer.cpp index 4a8dfd5..0e66ec0 100644 --- a/src/BLEServer.cpp +++ b/src/BLEServer.cpp @@ -20,6 +20,9 @@ #include #include #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG = "BLEServer"; @@ -198,7 +201,6 @@ void BLEServer::handleGATTServerEvent( // - uint16_t app_id case ESP_GATTS_REG_EVT: { m_gatts_if = gatts_if; - m_semaphoreRegisterAppEvt.give(); // Unlock the mutex waiting for the registration of the app. break; } // ESP_GATTS_REG_EVT diff --git a/src/BLEService.cpp b/src/BLEService.cpp index 9e7fa28..669ed26 100644 --- a/src/BLEService.cpp +++ b/src/BLEService.cpp @@ -56,9 +56,14 @@ BLEService::BLEService(BLEUUID uuid, uint32_t numHandles) { * @param [in] gatts_if The handle of the GATT server interface. * @return N/A. */ + void BLEService::executeCreate(BLEServer *pServer) { //ESP_LOGD(LOG_TAG, ">> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: %s", getUUID().toString().c_str()); - getUUID(); // Needed for a weird bug fix + //getUUID(); // Needed for a weird bug fix + //char x[1000]; + //memcpy(x, &m_uuid, sizeof(m_uuid)); + //char x[10]; + //memcpy(x, &deleteMe, 10); m_pServer = pServer; m_semaphoreCreateEvt.take("executeCreate"); // Take the mutex and release at event ESP_GATTS_CREATE_EVT diff --git a/src/BLEService.h b/src/BLEService.h index 9a93aff..19b472e 100644 --- a/src/BLEService.h +++ b/src/BLEService.h @@ -78,10 +78,12 @@ private: uint16_t m_handle; BLECharacteristic* m_lastCreatedCharacteristic; BLEServer* m_pServer; + BLEUUID m_uuid; + char deleteMe[10]; //FreeRTOS::Semaphore m_serializeMutex; FreeRTOS::Semaphore m_semaphoreCreateEvt = FreeRTOS::Semaphore("CreateEvt"); - FreeRTOS::Semaphore m_semaphoreStartEvt = FreeRTOS::Semaphore("StartEvt"); - BLEUUID m_uuid; + FreeRTOS::Semaphore m_semaphoreStartEvt = FreeRTOS::Semaphore("StartEvt"); + uint32_t m_numHandles; uint16_t getHandle(); diff --git a/src/BLEValue.cpp b/src/BLEValue.cpp index d36d207..49818e2 100644 --- a/src/BLEValue.cpp +++ b/src/BLEValue.cpp @@ -10,6 +10,9 @@ #include #include "BLEValue.h" +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-log.h" +#endif static const char* LOG_TAG="BLEValue"; diff --git a/src/FreeRTOS.cpp b/src/FreeRTOS.cpp index dea73bf..3cabd91 100644 --- a/src/FreeRTOS.cpp +++ b/src/FreeRTOS.cpp @@ -4,8 +4,9 @@ * Created on: Feb 24, 2017 * Author: kolban */ -#include -#include +#include // Include the base FreeRTOS definitions +#include // Include the task definitions +#include // Include the semaphore definitions #include #include #include @@ -102,6 +103,9 @@ FreeRTOS::Semaphore::~Semaphore() { */ void FreeRTOS::Semaphore::give() { xSemaphoreGive(m_semaphore); +#ifdef ARDUINO_ARCH_ESP32 + FreeRTOS::sleep(10); +#endif ESP_LOGV(LOG_TAG, "Semaphore giving: %s", toString().c_str()); m_owner = ""; } // Semaphore::give diff --git a/src/FreeRTOS.h b/src/FreeRTOS.h index 320f4cc..edaa9df 100644 --- a/src/FreeRTOS.h +++ b/src/FreeRTOS.h @@ -10,9 +10,9 @@ #include #include -#include -#include -#include +#include // Include the base FreeRTOS definitions +#include // Include the task definitions +#include // Include the semaphore definitions /** @@ -40,9 +40,9 @@ public: std::string toString(); private: SemaphoreHandle_t m_semaphore; - std::string m_name; - std::string m_owner; - uint32_t m_value; + std::string m_name; + std::string m_owner; + uint32_t m_value; }; }; -- cgit v1.2.3