Creating an Eddystone-URL Beacon

Description

This example demonstrates how to create an Eddystone beacon with Silicon Labs' Bluetooth SDK.

Eddystone Beacons

The Eddystone format defines four different packet types. This example shows how to implement the Eddystone-URL packet. The Eddystone-URL packet advertises a URL in a compressed format. For more information on Eddystone beacons, see Google's Eddystone repository.

URL Beacon Implementation

The first step in creating the beacon is to define custom user data to be advertised:

#define EDDYSTONE_DATA_LEN           (21)

static const uint8_t eddystone_data[EDDYSTONE_DATA_LEN] = {
  0x03,          // Length of service list
  0x03,          // Service list
  0xAA, 0xFE,    // Eddystone ID
  0x10,          // Length of service data
  0x16,          // Service data
  0xAA,  0xFE,   // Eddystone ID
  0x10,          // Frame type Eddystone-URL
  0x00,          // Tx power
  0x00,          // http://www., 0x01=https://www.
  's','i','l','a','b','s','.','c','o','m'
};

Call the API to set this data to be advertised.

gecko_cmd_le_gap_bt5_set_adv_data(0, 0, EDDYSTONE_DATA_LEN, eddystone_data)

The first two parameters are the advertising set handle and a value indicating that data is to be used in advertising packets.

Then, set the transmit power. The Eddystone-URL packet format includes the transmit power in the 10th byte. This data can be used by receivers of the beacon to determine distance so it is important that this data and the actual transmit power match.

gecko_cmd_system_set_tx_power(0); // Set global maximum TX power to 0 dBm

The following call sets the minimum and maximum advertising interval to 100 ms ( 625 us * 160). All three advertising channels are used by default (37, 38, 39).

gecko_cmd_le_gap_set_advertise_timing(0, 160, 160, 0, 0);

The device is now ready to start advertising the Eddystone-URL beacon data. This is accomplished by making the following call:

gecko_cmd_le_gap_start_advertising(0, le_gap_user_data, le_gap_non_connectable);

This tells the stack to use the custom user data and to make the beacon non-connectable.

Setting up

  1. Create a new SoC - Empty software example project in Simplicity Studio.
  2. Replace the existing app.c file with the one attached here.
  3. Build the project and flash it to your device.

Eddystone beacon in BlueGecko app

Usage

After flashing the image to the device, the Eddystone beacon should start broadcasting right away. You can verify this with a mobile app such as the BlueGecko App.

Source