Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_GAP_Example by
Revision 16:4271375739ea, committed 2017-04-12
- Comitter:
- HTD
- Date:
- Wed Apr 12 18:52:04 2017 +0000
- Parent:
- 15:7e06fce6e4f8
- Child:
- 17:a49d093010d4
- Commit message:
- first commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 12 12:00:16 2016 +0000 +++ b/main.cpp Wed Apr 12 18:52:04 2017 +0000 @@ -18,11 +18,15 @@ #include "ble/BLE.h" /* Optional: Device Name, add for human read-ability */ -const static char DEVICE_NAME[] = "ChangeMe!!"; +const static char DEVICE_NAME[] = "Line Beacon 001"; /* Name it */ + -/* You have up to 26 bytes of advertising data to use. */ -const static uint8_t AdvData[] = {0x01,0x02,0x03,0x04,0x05}; /* Example of hex data */ -//const static uint8_t AdvData[] = {"ChangeThisData"}; /* Example of character data */ +const static uint8_t AdvServiceUUIDs[] = { 0x6F, 0xFE }; +const static uint8_t AdvData[] = { 0x6F, 0xFE, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00 }; /* Replace 0xFF, 0xFF, 0xFF, 0xFF, 0xFF to your bot's HWID */ +//const static uint8_t AdvDataFrameType[] = { 0x02 }; +//const static uint8_t AdvDataHWID[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +//const static uint8_t AdvDataMeasuredTxPower[] = { 0x7F }; +//const static uint8_t AdvDataDeviceMessage[] = { 0x00 }; /* Optional: Restart advertising when peer disconnects */ void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) @@ -71,10 +75,13 @@ ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); /* Sacrifice 2B of 31B to AdvType overhead, rest goes to AdvData array you define */ - ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, AdvData, sizeof(AdvData)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, AdvServiceUUIDs, sizeof(AdvServiceUUIDs)); + + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, AdvServiceUUIDs, sizeof(AdvServiceUUIDs)); /* Optional: Add name to device */ - //ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, AdvData, sizeof(AdvData)); + //ble.gap().setAdvertisingData((const uint8_t *)AdvServiceUUIDs, (const uint8_t *)AdvData); /* Set advertising interval. Longer interval == longer battery life */ ble.gap().setAdvertisingInterval(100); /* 100ms */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Apr 12 18:52:04 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/bLandais/code/mbed-os/#4c0e0edd4545