BLE Advertising
BLE Advertising Overview
A BLE peripheral device can advertise to allow detection and connection by BLE central devices.
Advertising is governed by the Bluetooth GAP (Generic Access Profile) specification. Peripheral devices advertise to a Central device. Typically Peripheral devices have limited resources and use low power, while Central devices are more powerful and provide an interface for human interaction.
For GAP details, see below sections of Bluetooth Core Standard document,
- Bluetooth Core Standard version 4, Vol 3, Part C, particularly sections 8 and 11
- Core Specification Supplement, Part A
The Bluetooth GAP specification limits advertising data to two packets:
- Advertising Data payload
- Scan Response payload
For details of the format see BLE Advertising Data Format below.
BLE Advertising with BGX
The BGX supports:
- advertising in high or low mode. See adv .
- advertising service ID and name
- turning off advertising. See adv .
By default, a BGX device advertises the BGX Streaming Service ID and the default module name. See UUID and Name for details.
Advertising Commands and Variables
Commands supporting BLE advertising are:
- adv - advertise in high mode or low mode, or turn advertising off
Variables supporting BLE advertising are:
-
Advertising mode and settings:
-
Advertising data:
- sy d n --- device name
BLE Advertising Data Format
The peripheral device transmits an advertising packet 31 octets in length. The central device scans and receives the advertising packet. The central can then request additional information. In response the peripheral sends a scan response packet, 31 octets in length.
The advertising packet and the scan response packet have the same general format.
The BLE advertising packet and scan response packet both consist of one or more structures of the form:
Length | Type | Content |
---|---|---|
1 octet | 1 octet | Length - 1 octets |
Length
specifies the length of the data, not including the
Length
octet.
The data consists of an octet specifying the data type, followed by the data
content.
Length = Content_length + Type_length = Content_length + 1
Unused octets are set to
00
.
The diagram below shows the general structure of the advertising packet and the scan response packet.
Source: Bluetooth Core standard v4, Vol 3, Part C - Generic Access Profile, Section 11, Advertising and Scan Response Data Format
BLE Advertising Format Examples
In the example tables, the top row shows the octets in the advertising packet or scan response packet, with data in hexadecimal notation. The Least Significant Byte (LSB) is on the left. Unless otherwise noted, data is sent in little-endian order. Some proprietary formats package the data in big-endian order.
The bottom line shows the interpretation, with numbers in decimal notation. Configurable parts of the advertising packet are emphasized .
UUID and Name
This is the default advertising mode for a BGX device, and the only advertising mode currently supported.
02 | 01 | 05 | 11 | 07 | 0011...EEFF | 09 | 09 | 0011...6677 |
Length: 2 | Type: Flags | Flags | Length: 17 | Type: UUID | UUID: 16 octets | Length: 9 | Type: Name | Name: 8 octets |
UUID and name are determined as follows:
Value | Associated Variable | Default | Notes |
---|---|---|---|
UUID
|
None |
331a36f5-2459-45ea-9d95-6142f0c4b307
|
BGX Streaming Service ID
- see Xpress Streaming Service |
name | sy d n | BGX-#### |
#### stands for the last 4 digits of the BD_ADDR
- see bl a . Example:
BGX-F603
|
Note : According to the BLE specification, the Service UUID appears in the advertising response as a hex number in little-endian order, with LSB first.
In the advertising packet, LSB at left:
07b3c4f04261-959d-ea45-5924f5361a33
The name is a string of ASCII character codes, and appears in the advertisement
in the same order as the string. For example, the name BGX-F603 appears as
4247582D46363033
.
The entire advertisement, using the BGX Streaming Service ID and example name above, with LSB at left, appears as:
020106110707b3c4f04261959dea455924f5361a3309094247582D46363033
Note : When advertising with the 1M PHY, the maximum length of the name field in the BGX advertising packet is 8 characters. If the name of an advertising BGX ( sy d n ) exceeds 8 characters in length, it will be shortened in the advertising packet to its first 8 characters.
For example, the name:
BGX-12345
will appear in the advertising packet as:
BGX-1234
Version Notes:
Starting with version
1.1.1229.0
, the BGX can advertise with
both the 1M PHY and the LE Coded PHY (see
bl p p
and
bl p m
). When advertising with the 1M PHY, the name field
of the advertising packet is limited to 8 characters as described above.
When advertising with the LE Coded PHY, the name field length is not limited in
length and can be as long as the maximum allowable length for the
System Device Name
.