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 /* mbed Microcontroller Library
Vincent Coubard 0:45a261c84d32 2 * Copyright (c) 2006-2015 ARM Limited
Vincent Coubard 0:45a261c84d32 3 *
Vincent Coubard 0:45a261c84d32 4 * Licensed under the Apache License, Version 2.0 (the "License");
Vincent Coubard 0:45a261c84d32 5 * you may not use this file except in compliance with the License.
Vincent Coubard 0:45a261c84d32 6 * You may obtain a copy of the License at
Vincent Coubard 0:45a261c84d32 7 *
Vincent Coubard 0:45a261c84d32 8 * http://www.apache.org/licenses/LICENSE-2.0
Vincent Coubard 0:45a261c84d32 9 *
Vincent Coubard 0:45a261c84d32 10 * Unless required by applicable law or agreed to in writing, software
Vincent Coubard 0:45a261c84d32 11 * distributed under the License is distributed on an "AS IS" BASIS,
Vincent Coubard 0:45a261c84d32 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Vincent Coubard 0:45a261c84d32 13 * See the License for the specific language governing permissions and
Vincent Coubard 0:45a261c84d32 14 * limitations under the License.
Vincent Coubard 0:45a261c84d32 15 */
Vincent Coubard 0:45a261c84d32 16
Vincent Coubard 0:45a261c84d32 17 #ifndef __BLE_CONFIG_PARAMS_PERSISTENCE_H__
Vincent Coubard 0:45a261c84d32 18 #define __BLE_CONFIG_PARAMS_PERSISTENCE_H__
Vincent Coubard 0:45a261c84d32 19
Vincent Coubard 0:45a261c84d32 20 #include "ble/services/URIBeaconConfigService.h"
Vincent Coubard 0:45a261c84d32 21
Vincent Coubard 0:45a261c84d32 22 /**
Vincent Coubard 0:45a261c84d32 23 * Generic API to load the URIBeacon configuration parameters from persistent
Vincent Coubard 0:45a261c84d32 24 * storage. If persistent storage isn't available, the persistenceSignature
Vincent Coubard 0:45a261c84d32 25 * member of params may be left un-initialized to the MAGIC, and this will cause
Vincent Coubard 0:45a261c84d32 26 * a reset to default values.
Vincent Coubard 0:45a261c84d32 27 *
Vincent Coubard 0:45a261c84d32 28 * @param[out] paramsP
Vincent Coubard 0:45a261c84d32 29 * The parameters to be filled in from persistence storage. This
Vincent Coubard 0:45a261c84d32 30 argument can be NULL if the caller is only interested in
Vincent Coubard 0:45a261c84d32 31 discovering the persistence status of params.
Vincent Coubard 0:45a261c84d32 32
Vincent Coubard 0:45a261c84d32 33 * @return true if params were loaded from persistent storage and have usefully
Vincent Coubard 0:45a261c84d32 34 * initialized fields.
Vincent Coubard 0:45a261c84d32 35 */
Vincent Coubard 0:45a261c84d32 36 bool loadURIBeaconConfigParams(URIBeaconConfigService::Params_t *paramsP);
Vincent Coubard 0:45a261c84d32 37
Vincent Coubard 0:45a261c84d32 38 /**
Vincent Coubard 0:45a261c84d32 39 * Generic API to store the URIBeacon configuration parameters to persistent
Vincent Coubard 0:45a261c84d32 40 * storage. It typically initializes the persistenceSignature member of the
Vincent Coubard 0:45a261c84d32 41 * params to the MAGIC value to indicate persistence.
Vincent Coubard 0:45a261c84d32 42 *
Vincent Coubard 0:45a261c84d32 43 * @note: the save operation may be asynchronous. It may be a short while before
Vincent Coubard 0:45a261c84d32 44 * the request takes affect. Reading back saved configParams may not yield
Vincent Coubard 0:45a261c84d32 45 * correct behaviour if attempted soon after a store.
Vincent Coubard 0:45a261c84d32 46 *
Vincent Coubard 0:45a261c84d32 47 * @param[in/out] paramsP
Vincent Coubard 0:45a261c84d32 48 * The params to be saved; persistenceSignature member gets
Vincent Coubard 0:45a261c84d32 49 * updated if persistence is successful.
Vincent Coubard 0:45a261c84d32 50 */
Vincent Coubard 0:45a261c84d32 51 void saveURIBeaconConfigParams(const URIBeaconConfigService::Params_t *paramsP);
Vincent Coubard 0:45a261c84d32 52
Vincent Coubard 0:45a261c84d32 53 #endif /* #ifndef __BLE_CONFIG_PARAMS_PERSISTENCE_H__*/