Test
Revision 43:fb2855f7754b, committed 2017-11-01
- Comitter:
- mbed_official
- Date:
- Wed Nov 01 15:30:57 2017 +0000
- Parent:
- 42:31c7229588e5
- Child:
- 44:3815660cfeaa
- Commit message:
- Merge pull request #112 from marcbonnici/master
Add MAC address printouts to examples
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble
Changed in this revision
| source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/main.cpp Wed Oct 11 10:00:36 2017 +0100
+++ b/source/main.cpp Wed Nov 01 15:30:57 2017 +0000
@@ -64,6 +64,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;
@@ -91,6 +104,8 @@
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.gap().setAdvertisingInterval(1000); /* 1000ms */
ble.gap().startAdvertising();
+
+ printMacAddress();
}
void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {