STM32WBA Bluetooth® LE – Connection subrating feature

1. Bluetooth® LE enhanced connection update change: connection subrating feature

Bluetooth® LE enhanced connection update change is a 5.3 standard feature implemented for STM32WBA.
The LE enhanced connection update change introduces the concept of subrated connections.

It allows devices to dynamically adjust their connection parameters.
It can sometimes be necessary for a device to use a low duty cycle connection for some use cases (lower power consumption) but be able to switch up to a high duty cycle when required to support other use cases (higher bandwidth).

Use cases which are expected to benefit from subrated connections include Bluetooth LE audio products such as hearing aids and monitoring systems which use sensors.

An audio device like a hearing aid can maintain a subrated connection to a smartphone, making the connection available for immediate use when it becomes necessary to handle audio communication.

Subrating saves power but also allows the connected isochronous stream to be established very quickly.

Using subrated connections, a sensor can efficiently maintain a persistent, low duty cycle subrated connection to another device which collects sensor data.
When required it can then switch the connection up to a high duty cycle quickly so that accumulated sensor data can be uploaded over a higher bandwidth connection.

Bluetooth® LE connections offer a highly flexible way to adapt to dynamic changes of requirements in terms of data throughput and power.

A high duty cycle connection achieves higher data throughput at the expense of increased power consumption, while a low duty cycle connection saves power at the expense of data throughput.

1.1. Connection subrating capabilities and benefits

  • A subrated connection achieves a power saving low duty cycle in a different way to non-subrated connections and is able to switch up to a high duty cycle more quickly.
  • Subrated connections are also able to handle variable packet rates or bursty traffic efficiently.

The ability to switch quickly from a low duty cycle connection to a high duty cycle connection when required and in a short time, provides an improved user experience for some important product types and is the main benefit of the new subrated connections feature.

1.2. Subrate updates compared to connection updates

Subrated connections allow quick changes from a low duty cycle connection to a high duty cycle connection.

ACL connection updates are slow to complete in comparison to subrate connection updates because they use Instants.
Instants allow the central to give the peripheral advanced notice of the change of connection parameters.
Scheduling the connection update to take place at a particular connection event in the future gives the central a window of time during which to retransmit the connection update request PDU if necessary.

Subrate connection changes do not risk breaking the connection and the link layer subrate update procedure does not use Instants. Changes to subrate parameters are made immediately by the peripheral when received and immediately by the central by receiving an acknowledgment.

1.3. Connection subrating

1.3.1. Basic principles

Subrated connections are ACL connections which have additional properties assigned to them and behave differently in some ways.
The additional properties are called the subrate factor, subrate base event, and continuation number.
ACL connection properties which also have a significant effect on the behavior of a subrated connection are the connection interval and the peripheral latency value.
The subrated connection properties provide a mechanism for indicating that only a specific subset of connection events are to be actively used by the connected devices, with the radio not being used in other connection events.
Connection events are actively used when the peripheral listens to the event or sends data in the event.
A subrated connection can therefore have a short ACL connection interval but still exhibit a low duty cycle.

Bluetooth® LE – A basic subrated connection with subrate factor = 5
Connectivity basics subrating 3.png


Only one in every five connection events is used. The other four are skipped and so there is no radio activity during those connection events.
The connection event during which the radio is used to transmit and receive link layer packets is known as a subrated connection event.

1.3.2. Subrate base events

A subrated connection defines a number of consecutive ACL connection events, of which one is actively used (the subrated connection event).
But the subrated connection event does not have to be the first ACL connection event in the sequence of events. The choice of connection event to use from within the sequence of subrate factor events is controlled by the subrate base event value which is used to determine the phase of the subrated events.

Figure below shows a subrated connection where the phase of the subrated events has been shifted by two connection events by specifying a subrate base event value of 2.


Bluetooth® LE – A subrated connection with subrate factor = 5, subrate base event = 2 and peripheral latency = 0
Connectivity basics subrating base event 2.png


The subrate base event property provides packet schedulers with control over connection events and radio use so that a workable schedule can be established across one or more concurrent connections.

1.3.3. Continuation events

The rate of packets exchanged over a connection and the way in which the rate varies is called the traffic profile.
Connection subrating uses the concept of continuation events.
When a subrated connection is actively in use, with a link layer packet which has a non-zero length during the current subrated connection event, a specified number of the following ACL connection events (called the continuation events) will be selected instead of skip them.
This ensures that bursts of activity from the application are not slowed down by subrating.
After an actively used subrated connection event, a number of the connection events that follow on immediately from the subrated connection event will also be selected for use.

Below the subrated connection has a continuation number property with a value of 1.

Bluetooth® LE – Continuation events in a subrated connection. Continuation number = 1
Connectivity subrating continuation event 2.png


  • At connection event #0 (the subrated connection base event), the link layer packet received had no payload, so continuation was not warranted. All other connection events until the next subrated connection event are therefore skipped.
  • At the subrated event, which occurs at ACL connection event #5, at least one non-zero length link layer packet was transmitted, so the next connection event (event #6) is designated a continuation event and is actively used.
  • At least one non-empty link layer packet was handled during this continuation event, connection event #6, so the next connection event, event #7, also becomes a continuation event.
  • Data is handled in event #7, so event #8 also becomes a continuation event.
  • During event #8, there are no non-empty packets, so the sequence of continuations ends here.

Below the subrated connection has a continuation number property with a value of 2.

Bluetooth® LE – Continuation events in a subrated connection. Continuation number = 2
Connectivity subrating peripheral latency continuation nimber equals 2.png


  • At connection event #0, one or more non-zero length packets are handled. This causes the next two connection events to be designated as continuation events since the continuation number is 2.
  • Neither of the continuation events #1 and #2 involve any user data, so the continuation window ends at connection event #2.
  • At the next subrated connection event (connection event #5), user data is handled. This causes events #6 and #7 to be continuation events.
  • Data is handled in continuation event #6, so the continuation window is extended, with connection event #8 being designated as a continuation event.
  • Data is also handled in continuation event #7, so connection event #9 also becomes a continuation event.
  • No user data is handled in either continuation event #8 or #9. A new subrated connection event starts at event #10, so for both of these reasons, the continuation window rooted in subrated connection event #5 ends. The subrated connection event #10 involves user data, so events #11 and #12 become continuation events (not shown).

1.3.4. Peripheral latency and subrated connections

When peripheral latency is used with a subrated connection, the effect can sometimes differ from that of non-subrated connections.
It depends on whether continuation events are in use.
When peripheral latency is greater than zero in a subrated connection, the peripheral latency concept applies only to subrated connection events, which occur at intervals determined by the subrate factor value.
Every other subrated connection event is skipped due to the peripheral latency value of 1 in conjunction with the subrate connection parameters.

Bluetooth® LE – A subrated connection with peripheral latency = 1, subrate factor = 3 and continuation number = 0
Connectivity subrating peripheral latency 2.png


An example of a non-zero continuation number used with a non-zero peripheral latency value.
The peripheral listens at every other subrated connection event as expected, but the peripheral latency property value has no effect on the behavior during continuation events.
After receiving data at a subrated connection event, the peripheral listens at the next continuation event exactly as it would with a peripheral latency value of zero.

Bluetooth® LE – A subrated connection with peripheral latency = 1, subrate factor = 3 and continuation number = 1
Connectivity subrating peripheral latency continuation event 2.png


The following section shows an example of a peripheral that applies peripheral latency, when allowed, with a series of 23 connection events over a subrated connection. The subrate factor value is 3, continuation number is 0, and it has a peripheral latency value of 1.

Bluetooth® LE – A subrated connection with peripheral latency = 1, subrate factor = 3 and continuation number = 0 - part1
Connectivity latency1 part1.png


Bluetooth® LE – A subrated connection with peripheral latency = 1, subrate factor = 3 and continuation number = 0 - part2
Connectivity latency1 part2.png


  • At event #0 (a subrated connection event), the peripheral listens but does not receive a valid packet.
  • Consequently, instead of skipping the second subrated connection event (event #3), the peripheral listens. Again, no valid packet is received.
  • The peripheral listens again at event #6 and this time receives one or more valid packets. There is activity across this connection now, so the peripheral latency value of 1 is applied by the peripheral and it skips the next subrated connection event, event #9.
  • At event #12, the peripheral listens again but receives no valid packets. Consequently, the effect of peripheral latency is suspended, and the peripheral listens at the next subrated connection event.
  • Listening at event #15, the peripheral receives a valid packet. The peripheral latency effect is reinstated because of this activity, and the next subrated connection event, event #18, is skipped.
  • The peripheral listens at event #21 as expected and receives a valid packet. Given this activity, the peripheral latency is applied, and the next subrated connection event (not shown) is skipped.

1.4. How to implement on STM32WBA applications

This feature is available in "full Link Layer" (use of "full ble stack") for STM32WBA.

For software and hardware requirements refer to BLE Stack Integration wiki page.

1.4.1. Peripheral or central commands and events

This command is used to set initial values for acceptable parameters for subrating requests.

hci_le_set_default_subrate

Description

This command is used by the Host to set the initial values for the acceptable parameters for subrating requests, as defined by the HCI_LE Subrate_Request command, for all future ACL connections where the Controller is the Central. This command does not affect any existing connection.
Syntax
tBleStatus hci_le_set_default_subrate( uint16_t Subrate_Min, uint16_t Subrate_Max, uint16_t Max_Latency, uint16_t Continuation_Number, uint16_t Supervision_Timeout );
Parameters
[in] Subrate_Min
Type: uint16_t
Description: Minimum subrate factor.
[in] Subrate_Max
Type: uint16_t
Description: Maximum subrate factor.
[in] Max_Latency
Type: uint16_t
Description: Maximum Peripheral latency allowed in requests by a Peripheral, in units of subrated connection intervals.
[in] Continuation_Number
Type: uint16_t
Description: Minimum number of underlying connection events to remain active after a packet containing a Link Layer PDU with a non-zero Length field is sent or received in requests by a Peripheral.
[in] Supervision_Timeout
Type: uint16_t
Description: Supervision timeout for the LE Link. It shall be a multiple of 10 ms and larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 ms.
Return value
[out] command status
Type: uint8_t
Events generated
HCI_COMMAND_COMPLETE_EVENT

Command used by a central or a peripheral to request a change of subrating factor.

hci_le_subrate_request

Description

This command is used by a Central or a Peripheral to request a change to the subrating factor and/or other parameters applied to an existing connection using the Connection Subrate Update procedure.
Syntax
tBleStatus hci_le_subrate_request( uint16_t Connection_Handle, uint16_t Subrate_Min, uint16_t Subrate_Max, 
uint16_t Max_Latency, uint16_t Continuation_Number, uint16_t Supervision_Timeout );
Parameters
[in] Connection_Handle
Type: uint16_t
Description: Connection handle for which the command applies.
[in] Subrate_Min
Type: uint16_t
Description: Minimum subrate factor.
[in] Subrate_Max
Type: uint16_t
Description: Maximum subrate factor.
[in] Max_Latency
Type: uint16_t
Description: Maximum Peripheral latency allowed in requests by a Peripheral, in units of subrated connection intervals.
[in] Continuation_Number
Type: uint16_t
Description: Minimum number of underlying connection events to remain active after a packet containing a Link Layer PDU with a non-zero Length field is sent or received in requests by a Peripheral.
[in] Supervision_Timeout
Type: uint16_t
Description: Supervision timeout for the LE Link. It shall be a multiple of 10 ms and larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 ms.
Return value
[out] command status
Type: uint8_t
Events generated
HCI_COMMAND_COMPLETE_EVENT
HCI_LE_SUBRATE_CHANGE_EVENT

Event used at the completion of a connection subrate update procedure.

hci_le_subrate_change_event

Description

This event is used to indicate that a Connection Subrate Update procedure has completed and some parameters of the specified connection have changed.
Syntax
Event parameters( uint8_t Status, uint16_t Connection_Handle, uint16_t Subrate_Factor, 
uint16_t Peripheral_Latency, uint16_t Continuation_Number, uint16_t Supervision_Timeout );
Parameters
Status
Type: uint8_t
Description: Status error code.
Connection_Handle
Type: uint16_t
Description: Connection handle for which the command applies.
Subrate_Factor
Type: uint16_t
Description: New subrate factor applied to the specified underlying connection interval Range.
Peripheral_Latency
Type: uint16_t
Description: New Peripheral latency for the connection in number of subrated connection events.
Continuation_Number
Type: uint16_t
Description: Minimum number of underlying connection events to remain active after a packet containing a Link Layer PDU with a non-zero Length field is sent or received in requests by a Peripheral.
Supervision_Timeout
Type: uint16_t
Description: Supervision timeout for the LE Link. It shall be a multiple of 10 ms and larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 ms.

1.4.2. Message sequence chart: modifying the subrate of a connection

The central modifies the subrating of the connection.

Bluetooth® central modifies the connection subrating
Connectivity central modifies connection subrating.png


The peripheral requests a new subrate for its connection.

Bluetooth® peripheral modifies the connection subrating
Connectivity periph modifies connection subrating.png


2. Example of connection subrating feature on STM32WBA

2.1. Advertising data

At startup, the connection subrating server application starts advertising.
The advertised data are composed as follows:

Connection subrating server advertising packet
Description Length AD Type Value
Device Name 8 0x09 CS_XX (XX: last byte of BD address)
Manufacturer Data 15 0xFF See table below
Flags 2 0x01 0x06
(GeneralDiscoverable, BrEdrNotSupported)


Manufacturer data are encoded following the STMicroelectronics BlueST SDK v2, as described below:

STMicroelectronics manufacturer advertising data
Byte Index 0 1 2-3 4 5 6 7 8 9 10-15
Function Length Manufacturer ID Company BlueST SDK Version Device ID Firmware ID Option 1 Option 2 Option 3 Device Address
Value 0x0F 0xFF 0x0030 STMicro 0x02 0x8B Nucleo-WBA 0xE3 - Connection subrating Server 0x00 0x00 0x00 0x08E12Axxxx


2.2. On-board buttons configuration

Button configuration for Bluetooth® LE connection subrating application on Nucleo-WBA55CG boards
Application Condition B1 Click B1 Long Press B2 Click B2 Long Press B3 Click B3 Long Press
CS Server Idle

Connected

-

Starts/Stops notification

/ -

L2cap connection update

/ -

PHY update

/
CS Client Idle

Connected

Starts scan then connects

Starts/Stops write data

/ / / / /

2.3. Connection subrating central and peripheral applications

  • Connection established at 7.5 ms
  • Connection updated to 22.5 ms
  • Subrate request with maximum subrate factor equal to 5. When a subrate indication is received and no data received, the subrated connection is set to 112.5 ms (22.5 ms * 5)
  • Continuation number equals 1. The minimum number of underlying connection events to remain active after a packet containing a LLD PDU with a non-zero length field


2.3.1. Air trace after connection complete and subrate request

Bluetooth® connection updated to 22.5 ms then subrate request with max. subrate factor equals 5 and continuation number equals 1
Connectivity air trace connection subrate req.png


2.3.2. Air trace when write characteristic is started

Bluetooth® example of write characteristic
Connectivity air trace write char.png


2.3.3. Air trace when update characteristic is started

Bluetooth® example of update characteristic
Connectivity air trace notification.png


2.3.4. Flow diagram when notification is started

Bluetooth® example of notification flow diagram between a CS server and a CS client
Connectivity CS DT notification subrate2.png


2.3.5. Flow diagram when write characteristic is started

Bluetooth® example of write flow diagram between a CS client and a CS server
Connectivity write subrate4.png


2.4. No connection subrating use and connection updated to 22.5 ms

2.4.1. Air trace after connection complete

Bluetooth® connection updated to 22.5 ms
Connectivity air trace connection no subrate req.png


2.4.2. Air trace when write characteristic is started

Bluetooth® example of write characteristic
Connectivity air trace write char no subrate.png


2.4.3. Air trace when update characteristic is started

Bluetooth® example of update characteristic
Connectivity air trace notification no subrate.png


3. Code example

An STM32WBA connection subrating code example (peripheral and central) is available from the STM32-Hotspot GitHub[1].

4. References