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

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.

This example advertises a UUID, a major and minor number and the transmission strength. The major and minor numbers are an example of information that is not (normally) meaningful to humans, but that an application can use to identify the beacon and display related information. For example, if the major number is a store ID and the minor number is a location in that store, then a matching application can use these numbers to query a database and display location-specific information.

Running the application

Requirements

The sample application can be seen on any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install :

- nRF Master Control Panel for Android.

- LightBlue for iPhone.

Hardware requirements are in the main readme.

Building instructions

Building with mbed CLI

If you'd like to use mbed CLI to build this, then you should refer to the main readme. The instructions here relate to using the developer.mbed.org Online Compiler

In order to build this example in the mbed Online Compiler, first import the example using the ‘Import’ button on the right hand side.

Next, select a platform to build for. This must either be a platform that supports BLE, for example the NRF51-DK, or one of the following:

List of platforms supporting Bluetooth Low Energy

Or you must also add a piece of hardware and the supporting library that includes a Bluetooth Low Energy driver for that hardware, for example the K64F or NUCLEO_F401RE with the X-NUCLEO-IDB05A1

List of components supporting Bluetooth Low Energy.

Once you have selected your platform, compile the example and drag and drop the resulting binary onto your board.

For general instructions on using the mbed Online Compiler, please see the mbed Handbook

Checking for success

Note: Screens captures depicted below show what is expected from this example if the scanner used is nRF Master Control Panel version 4.0.5. If you encounter any difficulties consider trying another scanner or another version of nRF Master Control Panel. Alternative scanners may require reference to their manuals.

  • Build the application and install it on your board as explained in the building instructions.
  • Open the BLE scanner on your phone.
  • Start a scan.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon/raw-file/66b59f6860ed/img/start_scan.png

figure 1 How to start scan using nRF Master Control Panel 4.0.5

1. Find your device; it should be tagged as an `iBeacon` and observe its advertisements (there is no need to connect to the beacon).

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon/raw-file/66b59f6860ed/img/discovery.png

figure 2 Scan results using nRF Master Control Panel 4.0.5

  • View the beacon's details; the exact steps depend on which scanner you're using.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon/raw-file/66b59f6860ed/img/beacon_details.png

figure 3 Beacon details using nRF Master Control Panel 4.0.5

Tip: If you are in an area with many BLE devices, it may be difficult to identify your beacon. The simplest solution is to turn your board off and on, initiate a new scan on your BLE scanner every time, and look for the beacon that appears only when your board is on.

If you can see the beacon and all its information, the application worked properly.

For more information, see the mbed Classic version of this application.

Changes

RevisionDateWhoCommit message
81:796f36bfa718 2019-08-15 mbed_official Merge pull request #252 from donatieng/mbed_os_update default tip
80:b1d92e01177c 2019-02-27 mbed_official Updating mbed-os to mbed-os-5.11.5
79:f90f67a0964b 2019-02-25 mbed_official Merge pull request #217 from adbridge/master
78:2a8b14905e5e 2019-02-13 mbed_official Updating mbed-os to mbed-os-5.11.2
77:ce292cd870be 2019-01-14 mbed_official Merge pull request #207 from adbridge/master
76:652c2be531c7 2019-01-14 mbed_official Merge pull request #208 from ARMmbed/mbed-os-5.11.0-oob
75:583368bccade 2018-12-14 mbed_official Updating mbed-os to mbed-os-5.10.4
74:93c11e667986 2018-11-16 mbed_official Merge pull request #192 from paul-szczepanek-arm/update-libs
73:bc1a73879fd6 2018-11-07 mbed_official Merge pull request #189 from ARMmbed/donatieng-patch-1
72:ec76013cdcab 2018-10-22 mbed_official Merge pull request #187 from cmonr/master
71:aa0de73ce02e 2018-09-26 mbed_official Merge pull request #183 from ARMmbed/mbed-os-5.10.0-oob
70:5575d1bee775 2018-09-04 mbed_official Merge pull request #173 from pan-/use-cordio
69:e3d5bbf5238f 2018-08-29 mbed_official Merge pull request #172 from 0xc0170/master
68:ebd75ad70b7d 2018-08-23 mbed_official Updating mbed-os to mbed-os-5.9.5
67:95d161c752b7 2018-08-08 mbed_official Merge pull request #168 from cmonr/master
66:3b121faa734f 2018-07-18 mbed_official Merge pull request #166 from cmonr/master
65:026f4415d7d3 2018-07-06 mbed_official Merge pull request #163 from adbridge/master
64:8cd6ce6d1aae 2018-06-22 mbed_official Merge pull request #160 from adbridge/master
63:eb1515e44e8b 2018-06-20 mbed_official Merge pull request #159 from ARMmbed/mbed-os-5.9.0-oob
62:fc2404acd70c 2018-06-11 mbed_official Merge pull request #158 from adbridge/master
61:23bd0c0fae9c 2018-06-05 mbed_official Merge pull request #151 from paul-szczepanek-arm/privacy
60:8cd1fb57195a 2018-04-04 mbed_official Merge pull request #141 from adbridge/master
59:5bd68c958d92 2018-04-04 mbed_official Merge pull request #142 from ARMmbed/mbed-os-5.8.0-oob
58:bca1ffbb94c4 2018-03-23 mbed_official Merge pull request #139 from cmonr/master
57:7fbbc097527f 2018-03-23 mbed_official Merge pull request #137 from adbridge/master
56:da3efeb8ad76 2018-02-13 mbed_official Merge pull request #135 from adbridge/master
55:eab7fb088daa 2018-01-31 mbed_official Merge pull request #134 from cmonr/master
54:5eb83afc0a61 2018-01-17 mbed_official Merge pull request #133 from adbridge/master
53:6f90b11772c1 2018-01-09 mbed_official Merge pull request #129 from adbridge/master
52:9a70e56c39be 2018-01-08 mbed_official Merge pull request #132 from pan-/remove-mbedignore
51:408fb0656207 2017-12-20 mbed_official Merge pull request #126 from ARMmbed/mbed-os-5.7.0-oob
50:fd79ccd69687 2017-12-05 mbed_official Merge pull request #119 from adbridge/master
49:ce8b48ebe5e3 2017-12-01 mbed_official Merge pull request #117 from geky/patch-1
48:39269152b9fb 2017-11-23 mbed_official Merge pull request #115 from adbridge/master
47:8babeb3532b1 2017-11-07 mbed_official Merge pull request #113 from adbridge/master
46:863f3fea9978 2017-11-03 mbed_official Merge pull request #110 from 0xc0170/master
45:0d307fc39fd0 2017-11-01 mbed_official Merge pull request #112 from marcbonnici/master
44:40bc7e96abe7 2017-10-11 mbed_official Merge pull request #108 from adbridge/master
43:481169e30170 2017-09-29 mbed_official Merge pull request #106 from 0xc0170/master
42:aff575e88f29 2017-09-20 mbed_official Merge pull request #103 from ARMmbed/5.6_sanity
41:4c51bab26010 2017-09-08 mbed_official Merge pull request #102 from adbridge/master
40:abc2d39dfdde 2017-08-08 mbed_official Merge pull request #100 from 0xc0170/master
39:31c398bdb3bb 2017-07-28 mbed_official Merge pull request #99 from bcostm/add_disco_l475vg
38:6c79667926db 2017-07-19 mbed_official Merge pull request #97 from 0xc0170/master
37:52e2c5d7fb44 2017-07-19 mbed_official Merge pull request #98 from apalmieriGH/master
36:5a44b976bfaf 2017-07-11 mbed_official Merge pull request #93 from adbridge/master
35:013d2aef603e 2017-06-22 mbed_official Merge pull request #89 from adbridge/master
34:3834225ed8e2 2017-06-22 mbed_official Merge pull request #90 from apalmieriGH/master
33:8d04c8382f67 2017-06-20 mbed_official Merge pull request #88 from adbridge/master
32:f10243c96229 2017-06-15 mbed_official Merge pull request #83 from apalmieriGH/master
31:a30cbf5d7a1f 2017-06-08 mbed_official Merge pull request #82 from adbridge/master
30:f0a2f275ea86 2017-05-25 mbed_official Merge pull request #81 from adbridge/master
29:def124f21fee 2017-05-10 mbed_official Merge pull request #79 from adbridge/master
28:9090fe431353 2017-05-10 mbed_official Merge pull request #78 from ashok-rao/master
27:53620442057b 2017-05-09 mbed_official Merge pull request #77 from 0xc0170/master
26:bc3db54e0770 2017-04-05 mbed_official Merge pull request #70 from 0xc0170/master
25:3edf1e472398 2017-04-05 mbed_official Merge pull request #72 from pan-/update_bluenrg_ref
24:92e36d73fe09 2017-04-05 mbed_official Merge pull request #71 from pan-/fix_bluenrg_reference
23:03e444673038 2017-03-14 mbed_official Merge pull request #68 from adbridge/master
22:e437e0ab4d9f 2017-03-09 mbed_official Merge pull request #66 from ARMmbed/oob_test_mbed-os-5.4