diff options
Diffstat (limited to 'sensor/patchedBLE/examples/BLE_server/BLE_server.ino')
-rw-r--r-- | sensor/patchedBLE/examples/BLE_server/BLE_server.ino | 12 |
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!"); } |