summaryrefslogtreecommitdiff
path: root/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2019-02-22 12:39:08 +0000
committerdakkar <dakkar@thenautilus.net>2019-02-22 12:39:08 +0000
commit67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97 (patch)
tree0f5b064f03372305369a41b10e157aa89552e2f0 /sensor/patchedBLE/examples/BLE_server/BLE_server.ino
parentuni-init BLE before sleeping (diff)
parentMerge pull request #23 from tatsutaigu/master (diff)
downloadthermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.tar.gz
thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.tar.bz2
thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.zip
Merge commit 'b232e7f5f0e87f36afbc2f4e03a2c49c48dd47bc'
Diffstat (limited to 'sensor/patchedBLE/examples/BLE_server/BLE_server.ino')
-rw-r--r--sensor/patchedBLE/examples/BLE_server/BLE_server.ino12
1 files changed, 9 insertions, 3 deletions
diff --git a/sensor/patchedBLE/examples/BLE_server/BLE_server.ino b/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
index 38224a6..3f9176a 100644
--- a/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
+++ b/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
@@ -1,6 +1,7 @@
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
Ported to Arduino ESP32 by Evandro Copercini
+ updates by chegewara
*/
#include <BLEDevice.h>
@@ -17,7 +18,7 @@ void setup() {
Serial.begin(115200);
Serial.println("Starting BLE work!");
- BLEDevice::init("MyESP32");
+ BLEDevice::init("Long name works now");
BLEServer *pServer = BLEDevice::createServer();
BLEService *pService = pServer->createService(SERVICE_UUID);
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
@@ -28,8 +29,13 @@ void setup() {
pCharacteristic->setValue("Hello World says Neil");
pService->start();
- BLEAdvertising *pAdvertising = pServer->getAdvertising();
- pAdvertising->start();
+ // BLEAdvertising *pAdvertising = pServer->getAdvertising(); // this still is working for backward compatibility
+ BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
+ pAdvertising->addServiceUUID(SERVICE_UUID);
+ pAdvertising->setScanResponse(true);
+ pAdvertising->setMinPreferred(0x06); // functions that help with iPhone connections issue
+ pAdvertising->setMinPreferred(0x12);
+ BLEDevice::startAdvertising();
Serial.println("Characteristic defined! Now you can read it in your phone!");
}