STM32WBA Bluetooth® Low Energy – Long Range


1. STM32WBA Bluetooth® Low Energy Long Range feature

The Long Range or Low Energy Coded PHY feature extends the Bluetooth® Low Energy to a range of 1,6 km or more.

By using the advertising extension feature, the Bluetooth® Low Energy coded advertising Primary (and secondary) PHY becomes active as Bluetooth® Low Energy coded.

The HCI and ACI commands define new parameter values.
Based on the BLE_p2pClient_Ext and BLE_p2pServer_Ext applications, two new applications have been developed to demonstrate the feature and to provide range measurements: BLE_App_Long_Range_Central and BLE_App_Long_Range_Peripheral[1].

Application functionalities are derived from the BLE_p2pClient and BLE_p2pServer applications:
Refer to the following page for the Peer to Peer project explanation.

1.1. Principles

The advertising extension feature is required.
Modified or new GAP commands have been implemented to enable the Bluetooth® Low Energy coded feature.

  • To set the advertising parameters:

aci_gap_adv_set_configuration: Adv_Mode parameter is equal to 0x02 (use Bluetooth® Low Energy coded as primary advertising PHY)

aci_gap_adv_set_configuration

Description

This command is used to set the extended advertising configuration to one advertising set.
Syntax
tBleStatus aci_gap_adv_set_configuration(uint8_t Adv_Mode, uint8_t Advertising_Handle, uint16_t Adv_Event_Properties, 
uint32_t Primary_Adv_Interval_Min, uint32_t Primary_Adv_Interval_Max, uint8_t Primary_Adv_Channel_Map, uint8_t Own_Address_Type, 
uint8_t Peer_Address_Type, const uint8_t* Peer_Address, uint8_t Adv_Filter_Policy, uint8_t Adv_TX_Power, uint8_t Secondary_Adv_Max_Skip, 
uint8_t Secondary_Adv_PHY, uint8_t Adv_SID, uint8_t Scan_Req_Notification_Enable );
Parameters
[in] Adv_mode
Type: uint8_t
Description: Bitmap of the extended advertising modes.
'[in] Advertising_handle
Type: uint8_t
Description: Used to identify an advertising set.
[in] Adv_Event_Properties
Type: uint16_t
Description: Type of the advertising event.
[in] Primary_adv_interval_min
Type: uint32_t
Description: Minimum advertising interval.
[in] Primary_adv_interval_max
Type: uint32_t
Description: Maximum advertising interval.
[in] Primary_adv_channel_map
Type: uint8_t
Description: Advertising channel map.
[in] Own_address_type
Type: uint8_t
Description: Own address type: if Privacy is disabled, the address can be public or static random; otherwise, it can be a resolvable private address or a non-resolvable private address.
[in] Peer_address_type
Type: uint8_t
Description: Address type of the peer device.
[in] Peer_address
Type: 6 bytes
Description: Public Device Address, Random Device Address, Public Identity Address, or Random (static) Identity Address of the device to be connected.
[in] Adv_filter_policy
Type: uint8_t
Description: Advertising filter policy.
[in] Adv_Tx_power
Type: uint8_t
Description: Advertising TX power. Units: dBm.
[in] Secondary_Adv_Max_Skip
Type: uint8_t
Description: Secondary advertising maximum skip.
[in] Secondary_Adv_PHY
Type: uint8_t
Description: Secondary advertising PHY.
[in] Adv_SID
Type: uint8_t
Description: Value of the Advertising SID subfield in the ADI field of the PDU.
[in] Scan_Req_Notification_Enable
Type: uint8_t
Description: Scan request notifications.
Return value
[out] command status
Type: uint8_t
  • To set the scan procedure:

aci_gap_ext_start_scan: scanning_PHY parameter is equal to 0x04 (use of Bluetooth® Low Energy coded as scan PHY)

aci_gap_ext_start_scan

Description

This command is used to start a scanning procedure when the extended advertising feature is supported.
Syntax
tBleStatus aci_gap_ext_start_scan(uint8_t Scan_Mode, uint8_t Procedure, uint8_t Own_Address_Type, uint8_t Filter_Duplicates, 
uint16_t Duration, uint16_t Period, uint8_t Scanning_Filter_Policy, uint8_t Scanning_PHYs, const Scan_Param_Phy_t* Scan_Param_Phy);
Parameters
[in] Scan_mode
Type: uint8_t
Description: not used.
'[in] Procedure
Type: uint8_t
Description: Scan procedure.
[in] Own_address_type
Type: uint8_t
Description: Own address type: if Privacy is disabled, the address can be public or static random; otherwise, it can be a resolvable private address or a non-resolvable private address.
[in] Filter_duplicate
Type: uint8_t
Description: Enable/disable duplicate filtering.
[in] Duration
Type: uint16_t
Description: Scan duration.
[in] Period
Type: uint16_t
Description: Scan period.
[in] Scanning_filter_policy
Type: uint8_t
Description: The scanning filter policy determines the scanner Link Layer process advertising, and scan response PDUs.
[in] Scanning_PHYs
Type: uint8_t
Description: Scan PHYs.
[in] Scan_type
Type: uint8_t
Description: Passive or active scanning. With passive scanning, no scan request PDUs are sent.
Scan_Param_Phy_t
[in] Scan_interval
Type: uint16_t
Description: Time interval starting at the last scan from the controller and finishing at the subsequent scan start on the primary advertising physical channel.
[in] Scan_window
Type: uint16_t
Description: Duration of the scan on the primary advertising physical channel.
Return value
[out] command status
Type: uint8_t
  • To set the connection:

aci_gap_ext_create_connection: initiating PHYs parameter is equal to 0x04 (use of LE coded as scan connectable PHY)

aci_gap_ext_create_connection

Description:This command is used to create a connection with the local device in the central role to an advertiser when the extended advertising feature is supported.

Syntax
tBleStatus aci_gap_ext_create_connection(uint8_t Initiating_Mode, uint8_t Procedure, uint8_t Own_Address_Type, uint8_t Peer_Address_Type,
const uint8_t* Peer_Address, uint8_t Advertising_Handle, uint8_t Subevent, uint8_t Initiator_Filter_Policy, uint8_t Initiating_PHYs,
const Init_Param_Phy_t* Init_Param_Phy);
Parameters
[in] Initiating_Mode
Type: uint8_t
Description: not used.
'[in] Procedure
Type: uint8_t
Description: Scan procedure.
[in] Own_address_type
Type: uint8_t
Description: Own address type: if Privacy is disabled, the address can be public or static random; otherwise, it can be a resolvable private address or a non-resolvable private address..
[in] Peer_Address_Type
Type: uint8_t
Description: Enable/disable duplicate filtering..
[in] Peer_Address
Type: 6 bytes
Description: Scan duration.
[in] Advertising_Handle
Type: uint16_t
Description: Scan period.
[in] Subevent
Type: uint8_t
Description: The scanning filter policy determines how the scanner's Link Layer processes advertising and scan response PDUs.
[in] Initiator_Filter_Policy
Type: uint8_t
Description: Scan PHYs.
[in] Initiating_PHYs
Type: uint8_t
Description: Passive or active scanning. With passive scanning, no scan request PDUs are sent.
Init_Param_Phy_t
[in] Scan_interval
Type: uint16_t
Description: Time interval from when the Controller started its last scan until it begins the subsequent scan on the primary advertising physical channel.
[in] Scan_window
Type: uint16_t
Description: Duration of the scan on the primary advertising physical channel.
[in] Conn_Interval_min
Type: uint16_t
Description: Minimum value for the connection event interval.
[in] Conn_interval_max
Type: uint16_t
Description: Maximum value for the connection event interval.
[in] Connection_latencyl
Type: uint16_t
Description: Maximum Peripheral latency for the connection in number of connection events.
[in] Supervision_timeout
Type: uint16_t
Description: Supervision timeout for the LE Link.
[in] Min_CE_length
Type: uint16_t
Description: Information parameter about the minimum length of connection needed for this LE connection.
[in] Max_CE_length
Type: uint16_t
Description: Information parameter about the maximum length of connection needed for this LE connection.
Return value
[out] command status
Type: uint8_t

1.2. Advertising data

At startup, Peer To Peer Server Long Range application starts advertising.
Data advertised are composed as follows:

P2P Server Long Range advertising packet
Description Length AD type Value
Device name 8 0x09 p2pS_LR_XX (XX: last byte of BD address)
Manufacturer data 15 0xFF See the table below
Flags 2 0x01 0x06
(GeneralDiscoverable, BrEdrNotSupported)



Manufacturer data are encoded following 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 0x8F - p2p Server Long Range 0x00 0x00 0x00 0x08E12Axxxx


1.3. On-board buttons configuration

Button configuration for Bluetooth® Low Energy Long Range application on Nucleo-WBA55CG boards
Application Condition B1 click B1 long press B2 Click B2 long press B3 click B3 long press

Long Range server

Idle - / - / - /
Connected Starts/Stops notification Change LE coded PHY options
Long Range client Idle Starts scan then connects / - / - /
Connected Starts/Stops write data Change LE coded PHY Options

1.4. STM32WBA Long Range central and peripheral application

Long Range central acts as a central device with the support of the GATT Client Layer.
At startup, by pressing the B1 button, the Long Range client application:

  • Starts scanning to detect Long Range server application by filtering the firmware ID of the STMicroelectronics manufacturer advertising data.
  • Stops Scanning once Long Range server detected.
  • Connects to the Long Range server to establish the connection.
  • Discovers the Long Range server GATT Service & Characteristics.
  • Enables all GATT server notification characteristics.

Once connected, the Long Range client application:

  • By pressing B1 button, writes a message to toggle the Blue LED of the Long Range server.
  • Receives a notification to toggle the on board Blue LED from the remote Long Range server Application.

Long Range peripheral acts as a peripheral device with the support of the GATT Client Layer.
At reset, the Long Range peripheral application starts one extended advertising set at primary and secondary LE coded PHY.

Once connected, on both applications:

  • By pressing the B2 button, the HCI_LE_SET_PHY command is sent. It allows to toggle Phy_options parameter S=8/2 (red led is ON/OFF).
Info white.png Information
The change in the PHY coded option is not notified to the remote device.
  • Payload can be coded using two different rates: 125 kb/s (S = 2), or 500 kb/s (S = 8)

Refer to Bluetooth®Programming Manual PM0271 [2]. See chapter 5.7 STM32WBA LE Coded PHY.

Example of flow diagram between STM32WBA Long Range server & Long Range client
STM32WBA P2P Flow Diagram


B2 to toggle Phy options: client writes with S=8, peripheral notifies with S=2
STM32WBA P2P Flow Diagram


1.5. Collector applications compatibility

The BLE_App_Long_Range_Peripheral project is compatible with the following collector:
BLE_App_Long_Range_Central or a smartphone supporting the Bluetooth® Low Energy coded feature.

1.6. Code example

A STM32WBA Long Range code example has been shared on the STM32-Hotspot GitHub [1].

2. References