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.

Revisions of mbed-os.lib

Revision Date Message Actions
31:a30cbf5d7a1f 2017-06-08 Merge pull request #82 from adbridge/master File  Diff  Annotate
30:f0a2f275ea86 2017-05-25 Merge pull request #81 from adbridge/master File  Diff  Annotate
29:def124f21fee 2017-05-10 Merge pull request #79 from adbridge/master File  Diff  Annotate
27:53620442057b 2017-05-09 Merge pull request #77 from 0xc0170/master File  Diff  Annotate
26:bc3db54e0770 2017-04-05 Merge pull request #70 from 0xc0170/master File  Diff  Annotate
23:03e444673038 2017-03-14 Merge pull request #68 from adbridge/master File  Diff  Annotate
22:e437e0ab4d9f 2017-03-09 Merge pull request #66 from ARMmbed/oob_test_mbed-os-5.4 File  Diff  Annotate
21:ff8cfd507880 2017-03-01 Merge pull request #55 from adbridge/master File  Diff  Annotate
19:13573848f817 2017-02-15 Merge pull request #52 from 0xc0170/master File  Diff  Annotate
18:c6a94c16678a 2017-02-02 Merge pull request #48 from adbridge/master File  Diff  Annotate
17:e8770bc9b9a7 2017-01-26 Merge pull request #46 from adbridge/master File  Diff  Annotate
16:4f8470a7b203 2016-12-15 Update mbed-os revision to mbed-os 5.3.0. File  Diff  Annotate
15:4bcd937da124 2016-12-15 Merge pull request #42 from ARMmbed/mbed-os-5.3.0-rc3 File  Diff  Annotate
14:aa438f86ca5e 2016-10-28 Updating mbed-os to mbed-os-5.2.1 File  Diff  Annotate
13:9509abc1e6d9 2016-10-24 Updating mbed-os to mbed-os-5.2.0 File  Diff  Annotate
12:af576944a152 2016-10-24 Merge pull request #32 from ARMmbed/oob File  Diff  Annotate
11:edcf1a0efe8d 2016-10-05 Updating mbed-os to mbed-os-5.1.5 File  Diff  Annotate
10:4c25f4eecc03 2016-09-16 Updating mbed-os to mbed-os-5.1.4 File  Diff  Annotate
9:71d8e805726e 2016-08-20 Updating mbed-os to mbed-os-5.1.2 File  Diff  Annotate
8:bf14819d5954 2016-08-19 Updating mbed-os to mbed-os-5.1.1 File  Diff  Annotate
7:07df845530d9 2016-08-05 Updating mbed-os to mbed-os-5.1.0 File  Diff  Annotate
5:de28b1b114ea 2016-08-03 Updating mbed-os to mbed-os-5.1.0-rc5 File  Diff  Annotate
4:602e4083303a 2016-07-30 Updating mbed-os to mbed-os-5.1.0-rc4 File  Diff  Annotate
3:41f6be68aefb 2016-07-29 Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble File  Diff  Annotate
2:401488de6e22 2016-07-28 Sync with mbed-os-5.1.0-rc3 File  Diff  Annotate
1:2fd54f1254fe 2016-07-28 Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble File  Diff  Annotate
0:66b59f6860ed 2016-07-26 Update example at tag mbed-os-5.0.1-rc1 File  Diff  Annotate