ZO Hong
/
mbed-os_GAP_LineBeacon_nRF52
Using nRF52 as Line Beacon
Fork of BLE_GAP_Example by
Revision 16:836921833959, committed 2017-04-12
- Comitter:
- HTD
- Date:
- Wed Apr 12 18:46:52 2017 +0000
- Parent:
- 15:7e06fce6e4f8
- Commit message:
- first commit
Changed in this revision
diff -r 7e06fce6e4f8 -r 836921833959 BLE_API.lib --- a/BLE_API.lib Tue Jan 12 12:00:16 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#bfc5b9b6ecf5
diff -r 7e06fce6e4f8 -r 836921833959 main.cpp --- a/main.cpp Tue Jan 12 12:00:16 2016 +0000 +++ b/main.cpp Wed Apr 12 18:46:52 2017 +0000 @@ -13,16 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #include "mbed.h" #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[] = { 0x02, 0x01, 0x02, 0xC5, 0x72, 0x10 }; +//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) @@ -37,9 +41,9 @@ /* Avoid compiler warnings */ (void) ble; (void) error; - + /* Initialization error handling should go here */ -} +} /** * Callback triggered when the ble initialization process has finished @@ -59,7 +63,7 @@ if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; } - + /* Set device name characteristic data */ ble.gap().setDeviceName((const uint8_t *) DEVICE_NAME); @@ -71,14 +75,17 @@ 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 */ - + /* Start advertising */ ble.gap().startAdvertising(); } @@ -86,7 +93,7 @@ int main(void) { BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); - + /* Initialize BLE baselayer, always do this first! */ ble.init(bleInitComplete);
diff -r 7e06fce6e4f8 -r 836921833959 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Apr 12 18:46:52 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/bLandais/code/mbed-os/#4c0e0edd4545
diff -r 7e06fce6e4f8 -r 836921833959 mbed.bld --- a/mbed.bld Tue Jan 12 12:00:16 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file
diff -r 7e06fce6e4f8 -r 836921833959 nRF51822.lib --- a/nRF51822.lib Tue Jan 12 12:00:16 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#3cc0718d98d0