This example demonstrates using the GattClient API to control BLE client devices. The canonical source for this example lives at https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_LEDBlinker

Revision:
12:059c7b7fb18a
Parent:
4:9a6b0d5ea664
Child:
28:64621b6587e1
--- a/source/main.cpp	Wed Oct 05 05:16:07 2016 +0100
+++ b/source/main.cpp	Mon Oct 24 11:15:41 2016 +0100
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <mbed-events/events.h>
+#include <events/mbed_events.h>
 #include <mbed.h>
 #include "ble/BLE.h"
 #include "ble/DiscoveredCharacteristic.h"
@@ -95,7 +95,7 @@
     printf("terminated SD for handle %u\r\n", connectionHandle);
     if (triggerLedCharacteristic) {
         triggerLedCharacteristic = false;
-        eventQueue.post(updateLedCharacteristic);
+        eventQueue.call(updateLedCharacteristic);
     }
 }
 
@@ -168,21 +168,19 @@
 
 void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
     BLE &ble = BLE::Instance();
-    eventQueue.post(Callback<void()>(&ble, &BLE::processEvents));
+    eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
 }
 
 int main()
 {
     triggerLedCharacteristic = false;
-    eventQueue.post_every(500, periodicCallback);
+    eventQueue.call_every(500, periodicCallback);
 
     BLE &ble = BLE::Instance();
     ble.onEventsToProcess(scheduleBleEventsProcessing);
     ble.init(bleInitComplete);
 
-    while (true) {
-        eventQueue.dispatch();
-    }
+    eventQueue.dispatch_forever();
 
     return 0;
 }