diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/BLE_client/BLE_client.ino | 16 | ||||
-rw-r--r-- | examples/BLE_notify/BLE_notify.ino | 2 | ||||
-rw-r--r-- | examples/BLE_scan/BLE_scan.ino | 2 | ||||
-rw-r--r-- | examples/BLE_server/BLE_server.ino | 2 | ||||
-rw-r--r-- | examples/BLE_uart/BLE_uart.ino | 2 | ||||
-rw-r--r-- | examples/BLE_write/BLE_write.ino | 2 |
6 files changed, 16 insertions, 10 deletions
diff --git a/examples/BLE_client/BLE_client.ino b/examples/BLE_client/BLE_client.ino index 3fc5efa..c0b6163 100644 --- a/examples/BLE_client/BLE_client.ino +++ b/examples/BLE_client/BLE_client.ino @@ -26,7 +26,7 @@ static void notifyCallback( Serial.println(length); } -void connectToServer(BLEAddress pAddress) { +bool connectToServer(BLEAddress pAddress) { Serial.print("Forming a connection to "); Serial.println(pAddress.toString().c_str()); @@ -42,8 +42,9 @@ void connectToServer(BLEAddress pAddress) { if (pRemoteService == nullptr) { Serial.print("Failed to find our service UUID: "); Serial.println(serviceUUID.toString().c_str()); - return; + return false; } + Serial.println(" - Found our service"); // Obtain a reference to the characteristic in the service of the remote BLE server. @@ -51,8 +52,9 @@ void connectToServer(BLEAddress pAddress) { if (pRemoteCharacteristic == nullptr) { Serial.print("Failed to find our characteristic UUID: "); Serial.println(charUUID.toString().c_str()); - return; + return false; } + Serial.println(" - Found our characteristic"); // Read the value of the characteristic. std::string value = pRemoteCharacteristic->readValue(); @@ -109,9 +111,13 @@ void loop() { // BLE Server with which we wish to connect. Now we connect to it. Once we are // connected we set the connected flag to be true. if (doConnect == true) { - connectToServer(*pServerAddress); + if (connectToServer(*pServerAddress)) { + Serial.println("We are now connected to the BLE Server."); + connected = true; + } else { + Serial.println("We have failed to connect to the server; there is nothin more we will do."); + } doConnect = false; - connected = true; } // If we are connected to a peer BLE Server, update the characteristic each time we are reached diff --git a/examples/BLE_notify/BLE_notify.ino b/examples/BLE_notify/BLE_notify.ino index f2539f7..44506c2 100644 --- a/examples/BLE_notify/BLE_notify.ino +++ b/examples/BLE_notify/BLE_notify.ino @@ -1,6 +1,6 @@ /* Video: https://www.youtube.com/watch?v=oCMOYS71NIU - Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleNotify.cpp + Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp Ported to Arduino ESP32 by Evandro Copercini Create a BLE server that, once we receive a connection, will send periodic notifications. diff --git a/examples/BLE_scan/BLE_scan.ino b/examples/BLE_scan/BLE_scan.ino index a884062..ef7d892 100644 --- a/examples/BLE_scan/BLE_scan.ino +++ b/examples/BLE_scan/BLE_scan.ino @@ -1,5 +1,5 @@ /* - Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleScan.cpp + Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp Ported to Arduino ESP32 by Evandro Copercini */ diff --git a/examples/BLE_server/BLE_server.ino b/examples/BLE_server/BLE_server.ino index c70c935..45ebf99 100644 --- a/examples/BLE_server/BLE_server.ino +++ b/examples/BLE_server/BLE_server.ino @@ -1,5 +1,5 @@ /* - Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleServer.cpp + 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 */ diff --git a/examples/BLE_uart/BLE_uart.ino b/examples/BLE_uart/BLE_uart.ino index 444ba6b..a8ab2d7 100644 --- a/examples/BLE_uart/BLE_uart.ino +++ b/examples/BLE_uart/BLE_uart.ino @@ -1,6 +1,6 @@ /* Video: https://www.youtube.com/watch?v=oCMOYS71NIU - Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleNotify.cpp + Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp Ported to Arduino ESP32 by Evandro Copercini Create a BLE server that, once we receive a connection, will send periodic notifications. diff --git a/examples/BLE_write/BLE_write.ino b/examples/BLE_write/BLE_write.ino index 0573669..ed5ebc6 100644 --- a/examples/BLE_write/BLE_write.ino +++ b/examples/BLE_write/BLE_write.ino @@ -1,5 +1,5 @@ /* - Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleWrite.cpp + Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleWrite.cpp Ported to Arduino ESP32 by Evandro Copercini */ |