BLE Services

The Bluetooth GATT (Generic Attribute Profile) governs communication between BLE devices via a dedicated connection.

For GATT documentation, see Bluetooth Core Standard version 4, Vol 3, Parts F and G.

When two BLE devices interact, one acts as a Peripheral, offering GATT Services, and the other acts as a Central, consuming Services. Services are defined in the GATT as collections of characteristics and relationships to other services.

The BGX device typically acts as the Peripheral (GATT server) and a BLE mobile device such as a phone or pad acts as the Central (GATT client). The BGX device can also act as Central.

A BLE Peripheral can connect to only one Central. A BGX device Central is restricted to connect to only one Peripheral.

General BLE issues are discussed in Introduction to BLE below.

The BGX device offers a Streaming Service - provides remote command mode and data streaming.

Introduction to BLE

This section introduces a few terms necessary for later discussion. These terms have a specific meaning in the BLE context.

BLE devices operate in two broad classifications: Central and Peripheral.

Peripherals offer Services, which consist of Characteristics. Services and Characteristics are distinguished by universally unique identifiers, or UUIDs.

Peripherals advertise, by broadcasting some services and characteristics. This allows them to be discovered by Centrals.

After discovering a Peripheral of interest, a Central requests a connection to the Peripheral. After connecting, the Central can discover the Peripheral's Services, and within those Services the Peripheral's Characteristics. The Central can read the value of Characteristics, subscribe to the value of Characteristics, and in some cases write the value of the Characteristic back to the Peripheral.

To subscribe to a Characteristic, the BLE mechanism is to register for notification when that Characteristic is changed, and provide a callback to be called on each notification. Typically the callback reads the Characteristic value and takes any action required.

Connecting to a Peripheral

The general procedure for using a Central to interact with a Peripheral is as follows:

The implementation of these procedural steps depends on the Central platform.


Xpress Streaming Service

In a BGX device, the following capabilities are available:

Additional commands and variables for managing streaming and the remote command interface are listed below:

Commands

Variables

Xpress Streaming Service Characteristics

Xpress Streaming Service defines a GATT profile consisting of a Xpress Streaming Service and three Characteristics, Rx , Tx and Mode .

A BGX device advertises the Xpress Streaming Service on start up according to the advertising variables:

A BGX device can be identified by its Xpress Streaming Service UUID. To interact with a BGX device as a Peripheral, use the Xpress Streaming Service.

Xpress Streaming Service UUID:

331a36f5-2459-45ea-9d95-6142f0c4b307

The Rx (receive) and Tx (transmit) Characteristics are named from the point of view of the Peripheral BGX device.

To send a string to be received by the Peripheral serial interface, write to the Rx Characteristic.

To read a string transmitted from the Peripheral serial interface, enable Notifications or Indications from the Tx Characteristic then wait for subsequent Notification or Indication Events to occur.

The BGX Xpress Streaming Service provides the following characteristics:

Characteristic UUID Length Properties
Peripheral Receive ( Rx ) a9da6040-0823-4995-94ec-9ce41ca28833 1-250 bytes Write, Write without response, Notify ( 1.2.2045.0 and later)
Peripheral Transmit ( Tx ) a73e9a10-628f-4494-a099-12efaf72258f 1-250 bytes Notify, Indicate, Write without Response ( 1.2.2045.0 and later)
Stream Mode ( Mode ) 75a9f022-af03-4e41-b4bc-9de90a47d50b 1-18 bytes Read, Write, Write without response, Notify, Indicate

Stream Mode Settings

Mode Value Description
1 Streaming Mode
2 Local Command Mode
3 Remote Command Mode

Xpress Streaming Service Flow Control

Legacy Flow Control

In firmware versions prior to 1.2.2045.0 , flow control is implemented by sending Xpress Streaming Service data via Notifications (Peripheral-to-Central) and Write operations (Central-to-Peripheral). Notification and Write operations require the receiving device to send an acknowledgement before another operation can occur. This allows the receiving device to delay its acknowledgement until it has freed up enough internal buffer space to hold the next incoming packet of data. This approach greatly reduces throughput, however, because a Notification or Write can happen at most once every two connection intervals.

Fast-Ack Flow Control

Starting with firmware version 1.2.2045.0 , a Streaming Control Channel is available that is used to transmit Streaming Control Messages between two connected devices. These Control Messages contain buffer status information that can be used to ensure that no Xpress Streaming Service data is dropped, allowing the devices to achieve high throughput while still guaranteeing data integrity. Flow control implemented over the Streaming Control Channel is referred to as Fast-Ack Flow Control, or just Fast-Ack.

Streaming Control Messages are sent from the Peripheral to the Central via Notifications on the Rx characteristic.

Streaming Control Messages are sent from the Central to the Peripheral via Write without Response operations on the Tx characteristic.

Streaming Control Messages are three bytes long and take the following format:

Byte 0 Bytes 1 - 2
Opcode Data

The Data field is Little Endian (i.e., Byte 1 is the LSB and Byte 2 is the MSB).

The table below describes the Streaming Control Opcodes available.

Streaming Control Opcode Description
0x00: Initial Buffer Size The Data field represents the total number of bytes the device can hold in its internal buffer.
0x01: Buffer Bytes Freed The Data field represents the number of bytes that have been freed from the device's internal buffers.

Xpress Streaming Service flow control is implemented on the Central device by the following procedure:

  1. After initially connecting, the Central enables Notifications on the Rx characteristic.
  2. The Peripheral responds by transmitting the number of bytes it can buffer internally via an Initial Buffer Size Control Message. The Central must save this value. This value will be referred to as Transmit Byte Available (TBA) for the remainder of this procedure.
  3. The Central then transmits the number of bytes it can buffer internally via an Initial Buffer Size Control Message.
  4. At this point the devices are ready to exchange Xpress Streaming Service data. The Central may send up to TBA bytes to the Peripheral without receiving any kind of response from the Peripheral. Data should be transmitted via Write without Response operations. Each time it transmits data to the Peripheral, the Central must subtract the number of bytes transmitted from the TBA.
  5. As the Peripheral frees up internal buffer space, it will periodically send Buffer Bytes Freed Control Messages to the Central. Each time the Central receives a Buffer Bytes Freed Control Message, it must add the number of bytes freed to the TBA.
  6. As the Central receives and consumes data from the Peripheral, it should transmit Buffer Bytes Freed Control Messages to the Peripheral. The determination of when buffer space has been freed is application-specific and is left up to the application developer.

Backwards Compatibility

Firmware version 1.2.2045.0 and later can still operate in Legacy Flow Control mode, if desired. In order to operate in legacy flow control mode, the Central should not enable Notifications on the Rx characteristric and should use Write operations to transmit data on the Rx characteristric.

Mode Characteristic

The Mode characteristic is used by a central device to put a peripheral BGX into Streaming or Remote Command Mode. A central device (BGX or mobile device) can write the Mode characteristic of a peripheral BGX, but a peripheral BGX cannot write the Mode characteristic of a central device.

To put a peripheral into Streaming Mode, write a single byte value of 0x01 to the Mode characteristic.

To put a peripheral BGX into Remote Command Mode:

Example

If the password is 123456, write the following to the Mode characteristic:

0x03 0x31 0x32 0x33 0x34 0x35 0x36 0x00

Notes:


Using Xpress Streaming Service From Another Device

Silicon Labs provides libraries and frameworks for using the BGX Xpress Streaming Service from Android or iOS mobile devices.

For more information, see BGXpress Host Software