![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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
Revision 83:d0596095a535, committed 2022-01-26
- Comitter:
- YJKIYOKAWA
- Date:
- Wed Jan 26 01:12:40 2022 +0000
- Parent:
- 82:7f3513808f75
- Commit message:
- delta beacon
Changed in this revision
source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
source/pretty_printer.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7f3513808f75 -r d0596095a535 source/main.cpp --- a/source/main.cpp Thu Mar 19 00:25:22 2020 +0000 +++ b/source/main.cpp Wed Jan 26 01:12:40 2022 +0000 @@ -159,10 +159,11 @@ * * Note: please remember to calibrate your beacons TX Power for more accurate results. */ - static const uint8_t uuid[] = { 0x74, 0x27, 0x8B, 0xDA, 0xB6, 0x44, 0x45, 0x20, - 0x8F, 0x0C, 0x72, 0x0E, 0xAF, 0x05, 0x99, 0x35 }; +// static const uint8_t uuid[] = { 0x74, 0x27, 0x8B, 0xDA, 0xB6, 0x44, 0x45, 0x20, +// 0x8F, 0x0C, 0x72, 0x0E, 0xAF, 0x05, 0x99, 0x35 }; + static const uint8_t uuid[] = { 0xA0,0xB1,0x37,0x30,0x3A,0x9A,0x11,0xE3,0xAA,0x6E,0x08,0x00,0x20,0x0C,0x9A,0x66 }; uint16_t major_number = 1; - uint16_t minor_number = 3; + uint16_t minor_number = 8; uint16_t tx_power = 0xC8; uint16_t comp_id = 0x069e;
diff -r 7f3513808f75 -r d0596095a535 source/pretty_printer.h --- a/source/pretty_printer.h Thu Mar 19 00:25:22 2020 +0000 +++ b/source/pretty_printer.h Wed Jan 26 01:12:40 2022 +0000 @@ -65,7 +65,7 @@ } /** print device address to the terminal */ -inline void print_address(const Gap::Address_t &addr) +inline void print_address(const ble::address_t &addr) { printf("%02x:%02x:%02x:%02x:%02x:%02x\r\n", addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]); @@ -74,20 +74,20 @@ inline void print_mac_address() { /* Print out device MAC address to the console*/ - Gap::AddressType_t addr_type; - Gap::Address_t address; - BLE::Instance().gap().getAddress(&addr_type, address); + ble::own_address_type_t addr_type; + ble::address_t address; + BLE::Instance().gap().getAddress(addr_type, address); printf("DEVICE MAC ADDRESS: "); print_address(address); } -inline const char* phy_to_string(Gap::Phy_t phy) { +inline const char* phy_to_string(ble::phy_t phy) { switch(phy.value()) { - case Gap::Phy_t::LE_1M: + case ble::phy_t::LE_1M: return "LE 1M"; - case Gap::Phy_t::LE_2M: + case ble::phy_t::LE_2M: return "LE 2M"; - case Gap::Phy_t::LE_CODED: + case ble::phy_t::LE_CODED: return "LE coded"; default: return "invalid PHY";