Skip to content

Commit cb1ab4e

Browse files
committed
Fixes for #121
1 parent 5074976 commit cb1ab4e

21 files changed

+71
-13
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP32 BLE Arduino
2-
version=0.4.5
2+
version=0.4.6
33
author=Neil Kolban <[email protected]>
44
maintainer=Neil Kolban <[email protected]>
55
sentence=BLE functions for ESP32

src/BLEAddress.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <iomanip>
1414
#include <string.h>
1515
#include <stdio.h>
16+
#ifdef ARDUINO_ARCH_ESP32
17+
#include "esp32-hal-log.h"
18+
#endif
1619

1720

1821
/**

src/BLEAdvertisedDevice.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <sstream>
1818
#include "BLEAdvertisedDevice.h"
1919
#include "BLEUtils.h"
20+
#ifdef ARDUINO_ARCH_ESP32
21+
#include "esp32-hal-log.h"
22+
#endif
2023
static const char* LOG_TAG="BLEAdvertisedDevice";
2124

2225
BLEAdvertisedDevice::BLEAdvertisedDevice() {

src/BLEAdvertising.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <esp_err.h>
1313
#include "BLEUtils.h"
1414
#include "GeneralUtils.h"
15+
#ifdef ARDUINO_ARCH_ESP32
16+
#include "esp32-hal-log.h"
17+
#endif
1518

1619
static const char* LOG_TAG = "BLEAdvertising";
1720

src/BLECharacteristic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "BLEUtils.h"
1919
#include "BLE2902.h"
2020
#include "GeneralUtils.h"
21+
#ifdef ARDUINO_ARCH_ESP32
22+
#include "esp32-hal-log.h"
23+
#endif
2124

2225
static const char* LOG_TAG = "BLECharacteristic";
2326

src/BLECharacteristicCallbacks.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#if defined(CONFIG_BT_ENABLED)
99
#include "BLECharacteristic.h"
1010
#include <esp_log.h>
11+
#ifdef ARDUINO_ARCH_ESP32
12+
#include "esp32-hal-log.h"
13+
#endif
1114
static const char* LOG_TAG = "BLECharacteristicCallbacks";
1215

1316

src/BLECharacteristicMap.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include <sstream>
1010
#include <iomanip>
1111
#include "BLEService.h"
12+
#ifdef ARDUINO_ARCH_ESP32
13+
#include "esp32-hal-log.h"
14+
#endif
1215

1316

1417
/**

src/BLEClient.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include <string>
1919
#include <sstream>
2020
#include <unordered_set>
21+
#ifdef ARDUINO_ARCH_ESP32
22+
#include "esp32-hal-log.h"
23+
#endif
2124

2225
/*
2326
* Design

src/BLEDescriptor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "BLEService.h"
1717
#include "BLEDescriptor.h"
1818
#include "GeneralUtils.h"
19+
#ifdef ARDUINO_ARCH_ESP32
20+
#include "esp32-hal-log.h"
21+
#endif
1922

2023
static const char* LOG_TAG = "BLEDescriptor";
2124

src/BLEDescriptorMap.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include "BLECharacteristic.h"
1212
#include "BLEDescriptor.h"
1313
#include <esp_gatts_api.h> // ESP32 BLE
14+
#ifdef ARDUINO_ARCH_ESP32
15+
#include "esp32-hal-log.h"
16+
#endif
1417

1518
/**
1619
* @brief Return the descriptor by UUID.

src/BLEDevice.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include "BLEClient.h"
2727
#include "BLEUtils.h"
2828
#include "GeneralUtils.h"
29+
#ifdef ARDUINO_ARCH_ESP32
30+
#include "esp32-hal-log.h"
31+
#endif
2932

3033
static const char* LOG_TAG = "BLEDevice";
3134

src/BLERemoteCharacteristic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "BLEUtils.h"
1919
#include "GeneralUtils.h"
2020
#include "BLERemoteDescriptor.h"
21+
#ifdef ARDUINO_ARCH_ESP32
22+
#include "esp32-hal-log.h"
23+
#endif
2124

2225

2326
static const char* LOG_TAG = "BLERemoteCharacteristic"; // The logging tag for this class.

src/BLERemoteDescriptor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "BLERemoteDescriptor.h"
1111
#include "GeneralUtils.h"
1212
#include <esp_log.h>
13+
#ifdef ARDUINO_ARCH_ESP32
14+
#include "esp32-hal-log.h"
15+
#endif
1316

1417
static const char* LOG_TAG = "BLERemoteDescriptor";
1518

src/BLERemoteService.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "GeneralUtils.h"
1414
#include <esp_log.h>
1515
#include <esp_err.h>
16+
#ifdef ARDUINO_ARCH_ESP32
17+
#include "esp32-hal-log.h"
18+
#endif
1619

1720
static const char* LOG_TAG = "BLERemoteService";
1821

src/BLEScan.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include "BLEScan.h"
1818
#include "BLEUtils.h"
1919
#include "GeneralUtils.h"
20+
#ifdef ARDUINO_ARCH_ESP32
21+
#include "esp32-hal-log.h"
22+
#endif
2023

2124
static const char* LOG_TAG = "BLEScan";
2225

src/BLEServer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include <string>
2121
#include <gatt_api.h>
2222
#include <unordered_set>
23+
#ifdef ARDUINO_ARCH_ESP32
24+
#include "esp32-hal-log.h"
25+
#endif
2326

2427
static const char* LOG_TAG = "BLEServer";
2528

@@ -198,7 +201,6 @@ void BLEServer::handleGATTServerEvent(
198201
// - uint16_t app_id
199202
case ESP_GATTS_REG_EVT: {
200203
m_gatts_if = gatts_if;
201-
202204
m_semaphoreRegisterAppEvt.give(); // Unlock the mutex waiting for the registration of the app.
203205
break;
204206
} // ESP_GATTS_REG_EVT

src/BLEService.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ BLEService::BLEService(BLEUUID uuid, uint32_t numHandles) {
5656
* @param [in] gatts_if The handle of the GATT server interface.
5757
* @return N/A.
5858
*/
59+
5960
void BLEService::executeCreate(BLEServer *pServer) {
6061
//ESP_LOGD(LOG_TAG, ">> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: %s", getUUID().toString().c_str());
61-
getUUID(); // Needed for a weird bug fix
62+
//getUUID(); // Needed for a weird bug fix
63+
//char x[1000];
64+
//memcpy(x, &m_uuid, sizeof(m_uuid));
65+
//char x[10];
66+
//memcpy(x, &deleteMe, 10);
6267
m_pServer = pServer;
6368
m_semaphoreCreateEvt.take("executeCreate"); // Take the mutex and release at event ESP_GATTS_CREATE_EVT
6469

src/BLEService.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ class BLEService {
7878
uint16_t m_handle;
7979
BLECharacteristic* m_lastCreatedCharacteristic;
8080
BLEServer* m_pServer;
81+
BLEUUID m_uuid;
82+
char deleteMe[10];
8183
//FreeRTOS::Semaphore m_serializeMutex;
8284
FreeRTOS::Semaphore m_semaphoreCreateEvt = FreeRTOS::Semaphore("CreateEvt");
83-
FreeRTOS::Semaphore m_semaphoreStartEvt = FreeRTOS::Semaphore("StartEvt");
84-
BLEUUID m_uuid;
85+
FreeRTOS::Semaphore m_semaphoreStartEvt = FreeRTOS::Semaphore("StartEvt");
86+
8587
uint32_t m_numHandles;
8688

8789
uint16_t getHandle();

src/BLEValue.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <esp_log.h>
1111

1212
#include "BLEValue.h"
13+
#ifdef ARDUINO_ARCH_ESP32
14+
#include "esp32-hal-log.h"
15+
#endif
1316

1417
static const char* LOG_TAG="BLEValue";
1518

src/FreeRTOS.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* Created on: Feb 24, 2017
55
* Author: kolban
66
*/
7-
#include <freertos/FreeRTOS.h>
8-
#include <freertos/task.h>
7+
#include <freertos/FreeRTOS.h> // Include the base FreeRTOS definitions
8+
#include <freertos/task.h> // Include the task definitions
9+
#include <freertos/semphr.h> // Include the semaphore definitions
910
#include <string>
1011
#include <sstream>
1112
#include <iomanip>
@@ -102,6 +103,9 @@ FreeRTOS::Semaphore::~Semaphore() {
102103
*/
103104
void FreeRTOS::Semaphore::give() {
104105
xSemaphoreGive(m_semaphore);
106+
#ifdef ARDUINO_ARCH_ESP32
107+
FreeRTOS::sleep(10);
108+
#endif
105109
ESP_LOGV(LOG_TAG, "Semaphore giving: %s", toString().c_str());
106110
m_owner = "<N/A>";
107111
} // Semaphore::give

src/FreeRTOS.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include <stdint.h>
1111
#include <string>
1212

13-
#include <freertos/FreeRTOS.h>
14-
#include <freertos/task.h>
15-
#include <freertos/semphr.h>
13+
#include <freertos/FreeRTOS.h> // Include the base FreeRTOS definitions
14+
#include <freertos/task.h> // Include the task definitions
15+
#include <freertos/semphr.h> // Include the semaphore definitions
1616

1717

1818
/**
@@ -40,9 +40,9 @@ class FreeRTOS {
4040
std::string toString();
4141
private:
4242
SemaphoreHandle_t m_semaphore;
43-
std::string m_name;
44-
std::string m_owner;
45-
uint32_t m_value;
43+
std::string m_name;
44+
std::string m_owner;
45+
uint32_t m_value;
4646
};
4747
};
4848

0 commit comments

Comments
 (0)