summaryrefslogtreecommitdiff
path: root/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-08-03 12:23:17 +0100
committerdakkar <dakkar@thenautilus.net>2018-08-03 12:23:17 +0100
commitbb00c2da73b6ab8837f50c9f889ee151f8abc036 (patch)
tree3922eb826386260568ccaa1da7056c141f752a97 /sensor/patchedBLE/examples/BLE_server/BLE_server.ino
parentdon't print from callback, there's races (diff)
parentUpload of 0.4.16 (diff)
downloadthermostat-bb00c2da73b6ab8837f50c9f889ee151f8abc036.tar.gz
thermostat-bb00c2da73b6ab8837f50c9f889ee151f8abc036.tar.bz2
thermostat-bb00c2da73b6ab8837f50c9f889ee151f8abc036.zip
Add 'sensor/patchedBLE/' from commit '7951347ed68313d75c367e1f2cce763cb56d1eb2'
git-subtree-dir: sensor/patchedBLE git-subtree-mainline: 27e209cf58abeda1dc110777f99a98804a13fdbf git-subtree-split: 7951347ed68313d75c367e1f2cce763cb56d1eb2
Diffstat (limited to 'sensor/patchedBLE/examples/BLE_server/BLE_server.ino')
-rw-r--r--sensor/patchedBLE/examples/BLE_server/BLE_server.ino39
1 files changed, 39 insertions, 0 deletions
diff --git a/sensor/patchedBLE/examples/BLE_server/BLE_server.ino b/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
new file mode 100644
index 0000000..38224a6
--- /dev/null
+++ b/sensor/patchedBLE/examples/BLE_server/BLE_server.ino
@@ -0,0 +1,39 @@
+/*
+ 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
+*/
+
+#include <BLEDevice.h>
+#include <BLEUtils.h>
+#include <BLEServer.h>
+
+// See the following for generating UUIDs:
+// https://www.uuidgenerator.net/
+
+#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
+#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
+
+void setup() {
+ Serial.begin(115200);
+ Serial.println("Starting BLE work!");
+
+ BLEDevice::init("MyESP32");
+ BLEServer *pServer = BLEDevice::createServer();
+ BLEService *pService = pServer->createService(SERVICE_UUID);
+ BLECharacteristic *pCharacteristic = pService->createCharacteristic(
+ CHARACTERISTIC_UUID,
+ BLECharacteristic::PROPERTY_READ |
+ BLECharacteristic::PROPERTY_WRITE
+ );
+
+ pCharacteristic->setValue("Hello World says Neil");
+ pService->start();
+ BLEAdvertising *pAdvertising = pServer->getAdvertising();
+ pAdvertising->start();
+ Serial.println("Characteristic defined! Now you can read it in your phone!");
+}
+
+void loop() {
+ // put your main code here, to run repeatedly:
+ delay(2000);
+} \ No newline at end of file