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:
45:9fe6d1e21b8a
Parent:
28:64621b6587e1
Child:
75:1a8d19363522
--- a/source/main.cpp	Wed Oct 11 10:00:47 2017 +0100
+++ b/source/main.cpp	Wed Nov 01 15:31:13 2017 +0000
@@ -135,6 +135,19 @@
    /* Initialization error handling should go here */
 }
 
+void printMacAddress()
+{
+    /* Print out device MAC address to the console*/
+    Gap::AddressType_t addr_type;
+    Gap::Address_t address;
+    BLE::Instance().gap().getAddress(&addr_type, address);
+    printf("DEVICE MAC ADDRESS: ");
+    for (int i = 5; i >= 1; i--){
+        printf("%02x:", address[i]);
+    }
+    printf("%02x\r\n", address[0]);
+}
+
 void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
 {
     BLE&        ble   = params->ble;
@@ -162,6 +175,8 @@
     // This means that the device will scan continuously.
     ble.gap().setScanParams(400, 400);
     ble.gap().startScan(advertisementCallback);
+
+    printMacAddress();
 }
 
 void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {