STM32WB-WBA Bluetooth® LE – Encrypted Advertising (EAD)

Revision as of 15:26, 11 April 2024 by Registered User


1. STM32WB-WBA Encrypted Advertising

This feature - introduced in Bluetooth® 5.4 provides a standardized approach to the secure broadcasting of data in advertising packets.

It is possible to encrypt advertising data by encapsulating the normal advertising data within an Encrypted Advertising Data type (new AD type.
Because the encrypted advertising data nonce is changed whenever the private address is changed, the encrypted data before and after the change is also different.
This approach prevents the tracking of devices based solely on the private address and advertising data.
The encrypted advertising data pre-shared session key is communicated only to peer devices that are authorized to receive such information.
Only devices that have the key material can decrypt and authenticate messages and track the advertising device.


1.1. Principles

Encrypted Advertising data are added in advertising using the new AD type "Encrypted Advertising Data" (0x31) Encryption of "Encrypted Advertising Data" is based on an algorithm using the value of a new characteristic added to GAP service and AES..(to complete) The characteristic: Encrypted Data Key Material is readable by a device authenticated and authorized.

The peer device, receiving advertising reports containing AD type "Encrypted Advertising Data" is able to decode encrypted data using the previously read Encrypted Data Key Material.

Encrypted Data key Material characterisitc:
*UUID: 0x2B88
*Value: 128 bits


1.2. Advertising data

At startup, Peer To Peer Server 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 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. STM32WBA Long Range Central and Peripheral application

Long Range Central acts as a Central device with the support of GATT Client Layer.
At startup, by pressing B1 button, 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 GATT Service & Characteristics of the Long Range server
  • Enable all GATT server notification characteristics

Once connected, the Long Range Client application:

  • By pressing B1 button, write a message to toggle the Blue LED of the Long Range Server
  • Receive notification to toggle the on board Blue LED from remote Long Range Server Application.

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

Once connected, on both applications:

  • By pressing B2 button, 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
Change in PHY Coded option is not notified to remote device.
  • Payload can be coded with two different rates: 125 kb/s (S = 2) or 500 kb/s (S = 8)

Refer to Bluetooth®Programming Manual PM0271 [1]. 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.4. 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.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 which supports LE coded feature.

1.6. Code example

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

2. References

No categories assignedEdit