URI-Beacons are handy when there is a need to advertise a small amount of information (usually a URL) to any nearby device. They’re really easy to set up: the code is fully available on the mbed website, so all you’ll need to do is tell the beacon what to broadcast. The canonical source for this example lives at https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_URIBeacon

URI-Beacons are handy when there is a need to advertise a small amount of information (usually a URL) to any nearby device. They’re really easy to set up: the code is fully available on the mbed website, so all you’ll need to do is tell the beacon what to broadcast.

Technical details are better presented here, which happens to be the mbed-classic equivalent of this example. Please also refer to Google's URIBeacon project.

What You’ll Need

To get this going, you’ll need:

- To see URIBeacons get the *Physical Web* app installed on your phone:

- Android version

- iOS version

- One of the BLE platforms listed in the README.md of this repository, for example a Nordic DK board.

Build 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

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

  • Build the application and install it on your board as explained in the building instructions.
  • Open the *Physical Web* application on your phone. It will start to search for nearby beacons.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-URIBeacon/raw-file/45a261c84d32/img/app_start.png

figure 1 Start of the *Physical Web* application version 0.1.856 on Android

  • When the beacon starts up, the Configuration Service runs for 60 seconds. During this time it is possible to change the URL advertised by the beacon. It is also important to note that during these 60 seconds, your device will not advertise any URL.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-URIBeacon/raw-file/45a261c84d32/img/open_configuration.png

figure 2 How to open the beacon configuration view using the *Physical Web* application version 0.1.856 on Android

  • Edit the URL advertised by your beacon.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-URIBeacon/raw-file/45a261c84d32/img/edit_url.png

figure 3 How to edit the URL advertised by your beacon using the *Physical Web* application version 0.1.856 on Android

  • Save the URL which will be advertised by your beacon.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-URIBeacon/raw-file/45a261c84d32/img/save_url.png

figure 4 How to save your beacon configuration and start advertising URL using the *Physical Web* application version 0.1.856 on Android.

  • Find your device; it should advertise the URL you have set.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-URIBeacon/raw-file/45a261c84d32/img/result.png

figure 5 Display of URL advertised by your beacon using the *Physical Web* application version 0.1.856 on Android.

Please note that the URIBeacon spec requires the URIBeacon app to remain in config mode for the first 60 seconds before switching to being a beacon. So if you're using a physical-web app, you'll only see the beacon after this period; if you're using one of the generic apps for BLE scanning, you should see a configurable beacon being advertised for the first 60 seconds.

You'll find links on Google's project page to client apps to test URIBeacon. Here's a link that should get you an Android App; please browse to `uribeacon-sample-release.apk`. But you should begin with the links to android apps mentioned above.

Committer:
Vincent Coubard
Date:
Tue Jul 26 14:52:13 2016 +0100
Revision:
0:45a261c84d32
Child:
2:e075005e17d0
Update example at tag mbed-os-5.0.1-rc1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vincent Coubard 0:45a261c84d32 1 URI-Beacons are handy when there is a need to advertise a small amount of
Vincent Coubard 0:45a261c84d32 2 information (usually a URL) to any nearby device. They’re really easy to set
Vincent Coubard 0:45a261c84d32 3 up: the code is fully available on the mbed website, so all you’ll need to do
Vincent Coubard 0:45a261c84d32 4 is tell the beacon what to broadcast.
Vincent Coubard 0:45a261c84d32 5
Vincent Coubard 0:45a261c84d32 6 Technical details are better presented [here](https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_URIBeacon/),
Vincent Coubard 0:45a261c84d32 7 which happens to be the mbed-classic equivalent of this example. Please also refer to [Google's URIBeacon project](https://github.com/google/uribeacon).
Vincent Coubard 0:45a261c84d32 8
Vincent Coubard 0:45a261c84d32 9 What You’ll Need
Vincent Coubard 0:45a261c84d32 10 ================
Vincent Coubard 0:45a261c84d32 11
Vincent Coubard 0:45a261c84d32 12 To get this going, you’ll need:
Vincent Coubard 0:45a261c84d32 13
Vincent Coubard 0:45a261c84d32 14 - To see URIBeacons get the *Physical Web* app installed on your phone:
Vincent Coubard 0:45a261c84d32 15
Vincent Coubard 0:45a261c84d32 16 - [Android version](https://play.google.com/store/apps/details?id=physical_web.org.physicalweb)
Vincent Coubard 0:45a261c84d32 17
Vincent Coubard 0:45a261c84d32 18 - [iOS version](https://itunes.apple.com/us/app/physical-web/id927653608?mt=8)
Vincent Coubard 0:45a261c84d32 19
Vincent Coubard 0:45a261c84d32 20 - One of the BLE platforms listed in the README.md of this repository, for example a
Vincent Coubard 0:45a261c84d32 21 Nordic DK board.
Vincent Coubard 0:45a261c84d32 22
Vincent Coubard 0:45a261c84d32 23 Build Instructions
Vincent Coubard 0:45a261c84d32 24 ==================
Vincent Coubard 0:45a261c84d32 25
Vincent Coubard 0:45a261c84d32 26 After cloning the parent repository, switch to the subfolder BLE_URIBeacon, and
Vincent Coubard 0:45a261c84d32 27 execute the following:
Vincent Coubard 0:45a261c84d32 28
Vincent Coubard 0:45a261c84d32 29 ```Shell
Vincent Coubard 0:45a261c84d32 30 mbed compile -t <toolchain> -m <target>
Vincent Coubard 0:45a261c84d32 31 ```
Vincent Coubard 0:45a261c84d32 32 Assuming that you're building for the nRF51 DK platform, available targets is
Vincent Coubard 0:45a261c84d32 33 `NRF51_DK`.
Vincent Coubard 0:45a261c84d32 34
Vincent Coubard 0:45a261c84d32 35 The other targets you can use are described in the main README.md for this repository.
Vincent Coubard 0:45a261c84d32 36
Vincent Coubard 0:45a261c84d32 37 The resulting binaries would be under `.build/<target_name>/<toolchain>/`.
Vincent Coubard 0:45a261c84d32 38
Vincent Coubard 0:45a261c84d32 39 Under that folder, the file called `ble-uribeacon.hex` is the one which
Vincent Coubard 0:45a261c84d32 40 can be flashed to the target using mbed's DAP over USB; the parent README or the
Vincent Coubard 0:45a261c84d32 41 documentation for your yotta target will explain how to choose between the available
Vincent Coubard 0:45a261c84d32 42 binaries and hex files.
Vincent Coubard 0:45a261c84d32 43
Vincent Coubard 0:45a261c84d32 44 Checking for Success
Vincent Coubard 0:45a261c84d32 45 ====================
Vincent Coubard 0:45a261c84d32 46
Vincent Coubard 0:45a261c84d32 47
Vincent Coubard 0:45a261c84d32 48 1. Build the application and install it on your board as explained in the building instructions.
Vincent Coubard 0:45a261c84d32 49
Vincent Coubard 0:45a261c84d32 50 1. Open the *Physical Web* application on your phone. It will start to search for nearby beacons.
Vincent Coubard 0:45a261c84d32 51
Vincent Coubard 0:45a261c84d32 52 ![](img/app_start.png)
Vincent Coubard 0:45a261c84d32 53
Vincent Coubard 0:45a261c84d32 54 **figure 1** Start of the *Physical Web* application version 0.1.856 on Android
Vincent Coubard 0:45a261c84d32 55
Vincent Coubard 0:45a261c84d32 56 1. When the beacon starts up, the Configuration Service runs for 60 seconds.
Vincent Coubard 0:45a261c84d32 57 During this time it is possible to change the URL advertised by the beacon.
Vincent Coubard 0:45a261c84d32 58 It is also important to note that during these 60 seconds, your device will not advertise any URL.
Vincent Coubard 0:45a261c84d32 59
Vincent Coubard 0:45a261c84d32 60 ![](img/open_configuration.png)
Vincent Coubard 0:45a261c84d32 61
Vincent Coubard 0:45a261c84d32 62 **figure 2** How to open the beacon configuration view using the *Physical Web* application version 0.1.856 on Android
Vincent Coubard 0:45a261c84d32 63
Vincent Coubard 0:45a261c84d32 64
Vincent Coubard 0:45a261c84d32 65 1. Edit the URL advertised by your beacon.
Vincent Coubard 0:45a261c84d32 66
Vincent Coubard 0:45a261c84d32 67 ![](img/edit_url.png)
Vincent Coubard 0:45a261c84d32 68
Vincent Coubard 0:45a261c84d32 69 **figure 3** How to edit the URL advertised by your beacon using the *Physical Web* application version 0.1.856 on Android
Vincent Coubard 0:45a261c84d32 70
Vincent Coubard 0:45a261c84d32 71
Vincent Coubard 0:45a261c84d32 72 1. Save the URL which will be advertised by your beacon.
Vincent Coubard 0:45a261c84d32 73
Vincent Coubard 0:45a261c84d32 74 ![](img/save_url.png)
Vincent Coubard 0:45a261c84d32 75
Vincent Coubard 0:45a261c84d32 76 **figure 4** How to save your beacon configuration and start advertising URL using the *Physical Web* application version 0.1.856 on Android.
Vincent Coubard 0:45a261c84d32 77
Vincent Coubard 0:45a261c84d32 78
Vincent Coubard 0:45a261c84d32 79 1. Find your device; it should advertise the URL you have set.
Vincent Coubard 0:45a261c84d32 80
Vincent Coubard 0:45a261c84d32 81 ![](img/result.png)
Vincent Coubard 0:45a261c84d32 82
Vincent Coubard 0:45a261c84d32 83 **figure 5** Display of URL advertised by your beacon using the *Physical Web* application version 0.1.856 on Android.
Vincent Coubard 0:45a261c84d32 84
Vincent Coubard 0:45a261c84d32 85
Vincent Coubard 0:45a261c84d32 86 **Please note that the URIBeacon spec requires the URIBeacon app to remain in
Vincent Coubard 0:45a261c84d32 87 config mode for the first 60 seconds before switching to being a beacon. So if
Vincent Coubard 0:45a261c84d32 88 you're using a physical-web app, you'll only see the beacon after this period;
Vincent Coubard 0:45a261c84d32 89 if you're using one of the generic apps for BLE scanning, you should see a
Vincent Coubard 0:45a261c84d32 90 configurable beacon being advertised for the first 60 seconds.**
Vincent Coubard 0:45a261c84d32 91
Vincent Coubard 0:45a261c84d32 92 You'll find [links](https://github.com/google/uribeacon/tree/uribeacon-final#contents) on Google's project page to client apps to test URIBeacon. Here's a link that should get you an [Android App](https://github.com/google/uribeacon/releases/tag/v1.2); please browse to `uribeacon-sample-release.apk`. But you should begin with the links to android apps mentioned above.