update BLE library for ESP32 env compatibility

with the last version of ESP32 arduino env it is not possible to compile on ESP32, we get "missing gatt_api.h" ERROR. So as to avoid that we need to use the last version of the nkolban library for BLE 0.4.16
This commit is contained in:
Florian committed 2018-06-30 15:24:47 +02:00
1 parent 1dd68ab078
commit 42be3fe0f2
48 files changed
+2970 -426

No files matched your search

@@ -23,8 +23,10 @@
#include <BLEUtils.h>
#include <BLE2902.h>
BLECharacteristic *pCharacteristic;
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint8_t value = 0;
// See the following for generating UUIDs:
@@ -53,7 +55,7 @@ void setup() {
BLEDevice::init("MyESP32");
// Create the BLE Server
BLEServer *pServer = BLEDevice::createServer();
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
// Create the BLE Service
@@ -81,13 +83,23 @@ void setup() {
}
void loop() {
if (deviceConnected) {
Serial.printf("*** NOTIFY: %d ***\n", value);
pCharacteristic->setValue(&value, 1);
pCharacteristic->notify();
//pCharacteristic->indicate();
value++;
}
delay(2000);
// notify changed value
if (deviceConnected) {
pCharacteristic->setValue(&value, 1);
pCharacteristic->notify();
value++;
delay(10); // bluetooth stack will go into congestion, if too many packets are sent
}
// disconnecting
if (!deviceConnected && oldDeviceConnected) {
delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising
Serial.println("start advertising");
oldDeviceConnected = deviceConnected;
}
// connecting
if (deviceConnected && !oldDeviceConnected) {
// do stuff here on connecting
oldDeviceConnected = deviceConnected;
}
}