Skip to content

Commit e215aa9

Browse files
committed
Fixes for #121
1 parent e978c60 commit e215aa9

8 files changed

+37
-13
lines changed

cpp_utils/ArduinoBLE.md

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ And here you will find the `ESP32_BLE.zip` that is build from the latest source.
2323
## Installing a new version
2424
If you have previously installed a version of the Arduino BLE Support and need to install a new one, follow the steps above to build yourself a new instance of the `ESP32_BLE.zip` that is ready for installation. I recommend removing the old one before installing the new one. To remove the old one, find the directory where the Arduino IDE stores your libraries (on Linux this is commonly `$HOME/Arduino`). In there you will find a directory called `libraries` and, if you have previously installed the BLE support, you will find a directory called `ESP32_BLE`. Remove that directory.
2525

26+
## Replacing the version that comes with Arduino-ESP32
27+
From October 2017 onwards, a build of the BLE libraries is supplied with the Arduino-ESP32 distribition which means that you should just be able to use the function without performing any additional steps. The intent is to keep the BLE libraries in this project completely in synch with the Arduino-ESP32 distribution. However, there may be times when a bug fix is needed which you may wish to try before an official distribution in Arduino-ESP32. That should be extremely rare. However, just in case it is needed, here is the recipe:
28+
29+
1. Go to `<ArduinoIDE>/hardware/espressif/esp32/libraries`
30+
2. Delete the directory called `BLE`
31+
3. Go to your `<Arduino>/libraries` folder
32+
4. Extract the `ESP32_BLE.zip` file there
33+
2634
## Switching on debugging
2735
The BLE support contains extensive internal diagnostics which can be switched on by editing the file called `sdkconfig.h` and finding the lines which read:
2836

cpp_utils/Arduino_ESP32_BLE.library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP32 BLE Arduino
2-
version=0.4.2
2+
version=0.4.3
33
author=Neil Kolban <[email protected]>
44
maintainer=Neil Kolban <[email protected]>
55
sentence=BLE functions for ESP32

cpp_utils/BLEServer.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ void BLEServer::handleGATTServerEvent(
201201
// - uint16_t app_id
202202
case ESP_GATTS_REG_EVT: {
203203
m_gatts_if = gatts_if;
204-
205204
m_semaphoreRegisterAppEvt.give(); // Unlock the mutex waiting for the registration of the app.
206205
break;
207206
} // ESP_GATTS_REG_EVT

cpp_utils/BLEService.cpp

+6-1
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

cpp_utils/BLEService.h

+4-2
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();

cpp_utils/FreeRTOS.cpp

+6-2
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

cpp_utils/FreeRTOS.h

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

cpp_utils/Makefile.arduino

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ BLE_FILES= \
5151
GeneralUtils.h \
5252
GeneralUtils.cpp
5353

54+
ARDUINO_LIBS=$(HOME)/Arduino/libraries
5455

5556
build_ble:
5657
rm -rf Arduino/ESP32_BLE
@@ -64,3 +65,8 @@ build_ble:
6465
rm -rf Arduino/ESP32_BLE
6566
@echo "---------------------------------------"
6667
@echo "ESP32_BLE.zip Arduino library now built"
68+
69+
install: build_ble
70+
rm -rf ${ARDUINO_LIBS}/ESP32_BLE
71+
unzip Arduino/ESP32_BLE.zip -d $(ARDUINO_LIBS)
72+

0 commit comments

Comments
 (0)