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:
mbed_official
Date:
Wed Mar 01 18:15:53 2017 +0000
Revision:
20:aba6206ee5d9
Parent:
2:e075005e17d0
Merge pull request #55 from adbridge/master

Updating mbed-os to mbed-os-5.3.6
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble

Who changed what in which revision?

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