This is an extremely simple consumer of the BLEDevice API. The aim is to demonstrate the smallest program that is sensibly detected on a device. Be careful with the name! iOS caches device names, and so you can't necessarily guarantee how long you'll be stuck with the first one you choose first time iOS sees your board.
Dependencies: BLE_API mbed nRF51822
Revision 1:db5fcf988f53, committed 2015-01-28
- Comitter:
- JonnyA
- Date:
- Wed Jan 28 01:01:47 2015 +0000
- Parent:
- 0:e2b2b6bdb2dc
- Commit message:
- The default advertising period seems too slow for the name to show up fast.; ; As that's the sole point of this example, let's decrease the interval
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e2b2b6bdb2dc -r db5fcf988f53 main.cpp --- a/main.cpp Wed Jan 28 00:50:59 2015 +0000 +++ b/main.cpp Wed Jan 28 01:01:47 2015 +0000 @@ -25,9 +25,13 @@ { ble.init(); - /* Setup advertising. */ + /* Setup the data to go into the advertising packets. */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + + /* The default advertising period is a little low - increase it */ + ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000)); + ble.startAdvertising(); while (true) {