Eddystone beacons broadcast a small amount of information, like URLs, to nearby BLE devices. The canonical source for this example lives at https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_EddystoneService

Eddystone beacons broadcast a small amount of information, like URLs, to nearby BLE devices.

The Eddystone Beacon sample application runs in two stages:

  • On startup, the Configuration Service (which allows modification of the beacon runs for a user-defined period (default - 30 seconds).
  • When the Configuration Service period ends, the Eddystone Service broadcasts advertisement packets.

Running the application

Requirements

You should install the *Physical Web* application on your phone:

- Android version

- iOS version

Note: It is also possible to use a regular scanner to interract with your Eddystone beacon but it requires knowledge about BLE and Eddystone beacon specification out of the scope of this document.

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

Working with nRF51-based 16K targets

Because of memory constraints, you can't use the SoftDevice 130 (S130) to build for nRF51-based 16K targets. If you are using these targets, then before building:

  1. Open the ``config.json`` file in this sample.
  2. Change ``soft device`` to ``S110``.
  3. Save.

You can now build for nRF51-based 16K targets.

Setting up the beacon

By default, the beacon directs to the url ``http://mbed.org``. You can change this to your own URL in two ways:

  • Manually edit the code in ``main.cpp`` in your copy of the sample.
  • Build and run the application's default code as explained in the building instructions. When the beacon starts up, the Configuration Service runs for 30 seconds (this is the default value; you can change it in ``main.cpp``). While the Configuration Service runs, you can use a BLE scanner on your phone to edit the values the service presents.

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-EddystoneService/raw-file/4c8f8bf32a99/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 30 seconds. During this time it is possible to change the URL advertised by the beacon. It is also important to note that during these 30 seconds, your device will not advertise any URL.

https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-EddystoneService/raw-file/4c8f8bf32a99/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-EddystoneService/raw-file/4c8f8bf32a99/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-EddystoneService/raw-file/4c8f8bf32a99/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-EddystoneService/raw-file/4c8f8bf32a99/img/result.png

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

Note: You can use the Eddystone Observer sample instead of a phone application.

Committer:
mbed_official
Date:
Thu Jul 28 23:14:36 2016 +0100
Revision:
1:9db4d46bb63f
Parent:
0:4c8f8bf32a99
Child:
2:9ee673e0b86a
Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble


Commit copied from ./src/github.com/ARMmbed/mbed-os-example-ble

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 1:9db4d46bb63f 1 /* mbed Microcontroller Library
mbed_official 1:9db4d46bb63f 2 * Copyright (c) 2006-2015 ARM Limited
mbed_official 1:9db4d46bb63f 3 *
mbed_official 1:9db4d46bb63f 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 1:9db4d46bb63f 5 * you may not use this file except in compliance with the License.
mbed_official 1:9db4d46bb63f 6 * You may obtain a copy of the License at
mbed_official 1:9db4d46bb63f 7 *
mbed_official 1:9db4d46bb63f 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 1:9db4d46bb63f 9 *
mbed_official 1:9db4d46bb63f 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 1:9db4d46bb63f 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 1:9db4d46bb63f 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 1:9db4d46bb63f 13 * See the License for the specific language governing permissions and
mbed_official 1:9db4d46bb63f 14 * limitations under the License.
mbed_official 1:9db4d46bb63f 15 */
mbed_official 1:9db4d46bb63f 16
mbed_official 1:9db4d46bb63f 17 #ifndef __UIDFRAME_H__
mbed_official 1:9db4d46bb63f 18 #define __UIDFRAME_H__
mbed_official 1:9db4d46bb63f 19
mbed_official 1:9db4d46bb63f 20 #include <string.h>
mbed_official 1:9db4d46bb63f 21 #include "EddystoneTypes.h"
mbed_official 1:9db4d46bb63f 22
mbed_official 1:9db4d46bb63f 23 /**
mbed_official 1:9db4d46bb63f 24 * Class that encapsulates data that belongs to the Eddystone-UID frame. For
mbed_official 1:9db4d46bb63f 25 * more information refer to https://github.com/google/eddystone/tree/master/eddystone-uid.
mbed_official 1:9db4d46bb63f 26 */
mbed_official 1:9db4d46bb63f 27 class UIDFrame
mbed_official 1:9db4d46bb63f 28 {
mbed_official 1:9db4d46bb63f 29 public:
mbed_official 1:9db4d46bb63f 30 /**
mbed_official 1:9db4d46bb63f 31 * Construct a new instance of this class.
mbed_official 1:9db4d46bb63f 32 */
mbed_official 1:9db4d46bb63f 33 UIDFrame(void);
mbed_official 1:9db4d46bb63f 34
mbed_official 1:9db4d46bb63f 35 /**
mbed_official 1:9db4d46bb63f 36 * Construct a new instance of this class.
mbed_official 1:9db4d46bb63f 37 *
mbed_official 1:9db4d46bb63f 38 * @param[in] uidNamespaceIDIn
mbed_official 1:9db4d46bb63f 39 * The Eddystone-UID namespace ID.
mbed_official 1:9db4d46bb63f 40 * @param[in] uidInstanceIDIn
mbed_official 1:9db4d46bb63f 41 * The Eddystone-UID instance ID.
mbed_official 1:9db4d46bb63f 42 */
mbed_official 1:9db4d46bb63f 43 UIDFrame(const UIDNamespaceID_t uidNamespaceIDIn, const UIDInstanceID_t uidInstanceIDIn);
mbed_official 1:9db4d46bb63f 44
mbed_official 1:9db4d46bb63f 45 /**
mbed_official 1:9db4d46bb63f 46 * Set the instance and namespace ID.
mbed_official 1:9db4d46bb63f 47 *
mbed_official 1:9db4d46bb63f 48 * @param[in] uidNamespaceIDIn
mbed_official 1:9db4d46bb63f 49 * The new Eddystone-UID namespace ID.
mbed_official 1:9db4d46bb63f 50 * @param[in] uidInstanceIDIn
mbed_official 1:9db4d46bb63f 51 * The new Eddystone-UID instance ID.
mbed_official 1:9db4d46bb63f 52 */
mbed_official 1:9db4d46bb63f 53 void setUIDData(const UIDNamespaceID_t &uidNamespaceIDIn, const UIDInstanceID_t &uidInstanceIDIn);
mbed_official 1:9db4d46bb63f 54
mbed_official 1:9db4d46bb63f 55 /**
mbed_official 1:9db4d46bb63f 56 * Construct the raw bytes of the Eddystone-UID frame that will be directly
mbed_official 1:9db4d46bb63f 57 * used in the advertising packets.
mbed_official 1:9db4d46bb63f 58 *
mbed_official 1:9db4d46bb63f 59 * @param[in] rawFrame
mbed_official 1:9db4d46bb63f 60 * Pointer to the location where the raw frame will be stored.
mbed_official 1:9db4d46bb63f 61 * @param[in] advPowerLevel
mbed_official 1:9db4d46bb63f 62 * Power level value included withing the raw frame.
mbed_official 1:9db4d46bb63f 63 */
mbed_official 1:9db4d46bb63f 64 void constructUIDFrame(uint8_t *rawFrame, int8_t advPowerLevel);
mbed_official 1:9db4d46bb63f 65
mbed_official 1:9db4d46bb63f 66 /**
mbed_official 1:9db4d46bb63f 67 * Get the size of the Eddystone-UID frame constructed with the
mbed_official 1:9db4d46bb63f 68 * current state of the UIDFrame object.
mbed_official 1:9db4d46bb63f 69 *
mbed_official 1:9db4d46bb63f 70 * @return The size in bytes of the Eddystone-UID frame.
mbed_official 1:9db4d46bb63f 71 */
mbed_official 1:9db4d46bb63f 72 size_t getRawFrameSize(void) const;
mbed_official 1:9db4d46bb63f 73
mbed_official 1:9db4d46bb63f 74 /**
mbed_official 1:9db4d46bb63f 75 * Get the Eddystone-UID namespace ID.
mbed_official 1:9db4d46bb63f 76 *
mbed_official 1:9db4d46bb63f 77 * @return A pointer to the namespace ID.
mbed_official 1:9db4d46bb63f 78 */
mbed_official 1:9db4d46bb63f 79 uint8_t* getUIDNamespaceID(void);
mbed_official 1:9db4d46bb63f 80
mbed_official 1:9db4d46bb63f 81 /**
mbed_official 1:9db4d46bb63f 82 * Get the Eddystone-UID instance ID.
mbed_official 1:9db4d46bb63f 83 *
mbed_official 1:9db4d46bb63f 84 * @return A pointer to the instance ID.
mbed_official 1:9db4d46bb63f 85 */
mbed_official 1:9db4d46bb63f 86 uint8_t* getUIDInstanceID(void);
mbed_official 1:9db4d46bb63f 87
mbed_official 1:9db4d46bb63f 88 private:
mbed_official 1:9db4d46bb63f 89 /**
mbed_official 1:9db4d46bb63f 90 * The byte ID of an Eddystone-UID frame.
mbed_official 1:9db4d46bb63f 91 */
mbed_official 1:9db4d46bb63f 92 static const uint8_t FRAME_TYPE_UID = 0x00;
mbed_official 1:9db4d46bb63f 93 /**
mbed_official 1:9db4d46bb63f 94 * The size (in bytes) of an Eddystone-UID frame.
mbed_official 1:9db4d46bb63f 95 */
mbed_official 1:9db4d46bb63f 96 static const uint8_t FRAME_SIZE_UID = 20;
mbed_official 1:9db4d46bb63f 97
mbed_official 1:9db4d46bb63f 98 /**
mbed_official 1:9db4d46bb63f 99 * The Eddystone-UID namespace ID.
mbed_official 1:9db4d46bb63f 100 */
mbed_official 1:9db4d46bb63f 101 UIDNamespaceID_t uidNamespaceID;
mbed_official 1:9db4d46bb63f 102 /**
mbed_official 1:9db4d46bb63f 103 * The Eddystone-UID instance ID.
mbed_official 1:9db4d46bb63f 104 */
mbed_official 1:9db4d46bb63f 105 UIDInstanceID_t uidInstanceID;
mbed_official 1:9db4d46bb63f 106 };
mbed_official 1:9db4d46bb63f 107
mbed_official 1:9db4d46bb63f 108 #endif /* __UIDFRAME_H__ */