confirgurable iBeacon example

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero Employee</font></font> </a> bluetoothsteve on ‎04-28-2016 01:34 PM

Project name

 Configurable iBeacon

 

Description

 This example demonstrates how to use BGScript to create a configurable iBeacon device, using the BGM1XX modules and ERF32 SOCs, whose parameters can be adjusted through either the UART interface or over the Bluetooth link. The parameters which can be configured are

  1. The device UUID
  2. The major and minor numbers
  3. The advertise interval

This provides a simpler path for configuring iBeacon devices than rebuilding and reprogramming the entire flash.

Instructions

Part 1 Basic Operation

First let’s start by ensuring that you have the latest version of the Silicon Labs Bluetooth stack installed. Next verify the basic operation of the device. Extract the zip file and build it using bgbuild. This tool is capable of building the project and flashing it with a single command line, for example

C:\SiliconLabs\bgm-1.0.2-755\bin\bgbuild.exe -f " bgm1xx.bgproj"

Once the project has been downloaded to the module or SOC, it will be detectable as an iBeacon by the Silicon Labs BlueGecko app which is available in the Google PlayStore or the Apple AppStore. Install BlueGecko and start it, then tap the Retail Beacon icon. The iBeacon device will be displayed with its name, MAC address, UUID, major and minor numbers. The default values for these parameters can be found in ibeacon-appconfig.bgs.

Part 2 Bluetooth

Now that we’ve verified the basic operation of the device let’s try changing some of the parameters. Exit the Retail Beacon portion of the application and tap the ”BLE Stack & Profile section” icon. Find and connect to your iBeacon. In the Android version of the App this is done by holding the name of the device, in the iOS version tap the iBeacon is only connectable for the first 300 seconds after startup, so if you are unable to connect trying pressing the reset button on the WSTK board. Once connected to the iBeacon, the BlueGecko app will display the services provided by the device. Expand the first unknown service with the following UUID

4f3edfe7-6f17-4f87-b2ee-ea2cdac0dd01

This is known as the device configuration service and is defined in gatt.xml. The device configuration service contains the following characteristics

c_ibeacon_uuid, c_ibeacon_major, c_ibeacon_minor, c_ibeacon_advint and c_ibeacon_reset

Expand the major number characteristic which has the following UUID

f1b41cde-dbf5-4acf-8679-ecb8b4dca702

Tap the pen icon to modify the value. Enter a new value under decimal, for example, and tap the save button. Exit the “BLE Stack & Profile Test” section and tap the “Retail Beacon” icon once more, once the scan completes and the device is shown again the new major number will be displayed. The process for modifying the other parameters is similar to that used above for the major number.

 

Part 3 UART

This portion of the example requires a terminal program such as Realterm that can send raw hex data over a COMPORT. Open your terminal program and connect to the port that corresponds to your development kit. Set the port for 115200 bps, no parity, 8 data bits and 1 stop bit. The commands recognized by the application are as follows

$01 {16 bytes UUID}        write new UUID

$11                                      read UUID

$02 {2 bytes uint8}        write new major value

$12                                    read major

$03 {2 bytes uint8}           write new minor value

$13                                      read minor

$04 {2 bytes uint8}           write adv interval *0.625us ($A000 = 100ms)

$14                                      read adv interval

$FE                                       boot into DFU mode

 

To verify this, start by sending the hexadecimal value 12, the iBeacon should reply with the major number as set in part 2. Once it has been verified that the major number is as expected, try setting the major number to 3 by sending the following sequence of bytes 02 00 03. The iBeacon will respond with the new major number. You can also verify that the new number has been set by opening the retail beacon section of the BlueGecko mobile device app.

 

 

 

Reference Information

This section is a reference to assist you with customizations.

Structure

This example contains the following files

Bluegecko.bjproj this is the project file which contains information about the other files required to build the application

Hardware.xml this file provides information about the configuration of the device necessary for the correct operation of the application. This includes the setup of the UART, GPIO pins for LEDs and the capacitive tune calibration value, CTUNE.

Gatt.xml this file contains information about the GATT table of this application.

Ibeacon-bg.bgs the toplevel BGscript file. This script file includes other scripts as necessary to implement the application

Ibeacon-appconfig.bgs a script with some simple configuration parameters

Ibeacon-common.bgs this is the main implementation of the application.