LM506: Apple iBeacon with BlueZ 5.X

As an official Apple iBeacon Partner, LM Technologies Ltd is well-positioned to provide the support that you require utilising iBeacon technology with our modules and adapters.

A common scenario is how to provide a basic Apple iBeacon signal from our LM506 Bluetooth 4.0 SMART-Ready (BLE) Adapter when working with the Linux BlueZ stack.

Step-by-step guide

To perform advanced/direct configuration of a Bluetooth adapter in Linux, you may use the command-line tools hciconfig andhcitool, these allow the user to issue HCI (Host Controller Interface) commands, which are common across all Bluetooth HCI Adapters and which talk to the hardware directly.

1.Open a terminal interface.

2.Issue the following command to identify your Bluetooth Adapter:

hciconfig -a

You should receive a response similar to the following, we will use the identifier on the far left when referring to the adapter in future commands, for now we will assume our adapter is identified by hci0


3.Issue the following command to Stop any Low-Energy Advertisements on the Bluetooth Adapter:

hciconfig hci0 noleadv

This is a peace-of-mind/preparatory step as we will now proceed to customise the Low-Energy advertisement packet issued by the adapter.

4.Issue the following command to supply a custom Low-Energy advertisement packet to the Bluetooth Adapter, this will be the packet of data that identifies the device as an iBeacon to passing mobiles:

hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 06 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 01 00 01 CE 00 00 00 00 00 00 00 00 00 00 00 00 00

The command can be broken down as follows (please refer to Volume 2 Part E Section 7.8.7 of the Bluetooth Core Specification for further details):

a. hcitool -i hci0 – Issue a HCI instruction to the Bluetooth Adapter identified as hci0.
b. cmd 0x08 0x0008 – Issue a HCI Command Packet (cmd) to the LE Controller (0x08 – the OpCode Group Field / OGF) requesting it set the LE Advertising Data (0x0008 – the OpCode Command Field / OCF).

Command LengthByte 1 (Flags[0])Byte 1 (Flags[1])Byte 2 (Flags[2])Byte 3 (Length)Byte 4 (Type)Byte 5-6 (Company ID)Byte 7-8 (Beacon Type)Byte 9-24 (Proximity UUID)Byte 25-26 (Major)Byte 27-28 (Minor)Byte 29 (Measured Power)
0x1E (30)0x02 (ADV_NONCONN_IND)0x010x060x1A (26)0xFF0x004C (Apple)0x0215 (Proximity Beacon)UUID representing the Application
(should be the same for all iBeacons to be handled by the same set of Apps)
16-bit ID to identify for example the building location16-bit ID to identify for example the shelf locationPower Calibration Value

5.Issue the following command to Start Low-Energy Advertisements on the Bluetooth Adapter using Non-connectible undirected advertising (as required by the iBeacon specification):

hciconfig hci0 leadv 3