this is using the mbed os version 5-13-1
Revision 44:df8adb3bc797, committed 2017-11-01
- Comitter:
- mbed_official
- Date:
- Wed Nov 01 15:31:06 2017 +0000
- Parent:
- 43:3249e80f65ba
- Child:
- 45:5df58b883c5e
- 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
| readme.md | Show annotated file Show diff for this revision Revisions of this file |
| source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/readme.md Wed Oct 11 10:00:42 2017 +0100
+++ b/readme.md Wed Nov 01 15:31:06 2017 +0000
@@ -13,7 +13,7 @@
## Requirements
-The sample application can be seen on any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install :
+The sample application can be seen on any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install:
- [nRF Master Control Panel](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp) for Android.
@@ -72,20 +72,20 @@

- **figure 6** Write characteristic pannel using Master Control Panel 4.0.5
+ **figure 6** Write characteristic panel using Master Control Panel 4.0.5
- * `0x00`: LED ON
+ * `0x00`: LED ON/OFF (board dependant)

- **figure 6** Write characteristic pannel to set the LED on using Master Control Panel 4.0.5
+ **figure 6** Write characteristic panel to set the LED on using Master Control Panel 4.0.5
- * `0x01`: LED OFF
+ * `0x01`: LED OFF/ON (board dependant)

- **figure 6** Write characteristic pannel to set the LED off using Master Control Panel 4.0.5
+ **figure 6** Write characteristic panel to set the LED off using Master Control Panel 4.0.5
1. Toggle the LED characteristic value and see the LED turn ON or turn OFF according to the value you set.
--- a/source/main.cpp Wed Oct 11 10:00:42 2017 +0100
+++ b/source/main.cpp Wed Nov 01 15:31:06 2017 +0000
@@ -60,6 +60,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]);
+}
+
/**
* Callback triggered when the ble initialization process has finished
*/
@@ -92,6 +105,8 @@
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.gap().setAdvertisingInterval(1000); /* 1000ms. */
ble.gap().startAdvertising();
+
+ printMacAddress();
}
void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {