This example creates a BLE beacon: a method of advertising a small amount of information to nearby devices. The information doesn't have to be human-readable; it can be in a format that only an application can use. Beacons are very easy to set up: the code for all beacons is the same, and only the information you want to advertise - the beacon payload - needs to change. he canonical source for this example lives at https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_Beacon
Diff: source/main.cpp
- Revision:
- 82:7f3513808f75
- Parent:
- 76:652c2be531c7
- Child:
- 83:d0596095a535
--- a/source/main.cpp Thu Aug 15 17:00:47 2019 +0100 +++ b/source/main.cpp Thu Mar 19 00:25:22 2020 +0000 @@ -145,8 +145,8 @@ /* Create advertising parameters and payload */ ble::AdvertisingParameters adv_parameters( - ble::advertising_type_t::CONNECTABLE_UNDIRECTED, - ble::adv_interval_t(ble::millisecond_t(1000)) + ble::advertising_type_t::NON_CONNECTABLE_UNDIRECTED , + ble::adv_interval_t(ble::millisecond_t(100)) ); _adv_data_builder.setFlags(); @@ -159,12 +159,12 @@ * * Note: please remember to calibrate your beacons TX Power for more accurate results. */ - static const uint8_t uuid[] = { 0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, - 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61 }; - uint16_t major_number = 1122; - uint16_t minor_number = 3344; + static const uint8_t uuid[] = { 0x74, 0x27, 0x8B, 0xDA, 0xB6, 0x44, 0x45, 0x20, + 0x8F, 0x0C, 0x72, 0x0E, 0xAF, 0x05, 0x99, 0x35 }; + uint16_t major_number = 1; + uint16_t minor_number = 3; uint16_t tx_power = 0xC8; - uint16_t comp_id = 0x004C; + uint16_t comp_id = 0x069e; Payload ibeacon(uuid, major_number, minor_number, tx_power, comp_id);