STM32WB-WBA BLE Privacy

Revision as of 15:52, 17 June 2022 by Registered User (→‎Code example)
Under construction.png Coming soon

1. STM32WB - Bluetooth® Low Energy (BLE) Privacy

The STM32WB - Bluetooth® Low Energy (BLE) privacy feature reduces the ability to track a device over a period of time by changing the device address on a frequent basis.

The address of a device using privacy mode can be resolved using the Identity Resolving Key (IRK) which is one of the encryption keys exchanged during the pairing process.

2. How to use Resolvable Private Address (RPA)

In initialization sequence (Ble_Hci_Gap_Gatt_Init in app_ble.c).

Set public address : aci_hal_write_config_data(public address offset ).
Set static random address : aci_hal_write_config_data(static random address offset).
One of these addresses will be chosen by the customer and is the proper address of the device.
Depending on the choice, it is defined with Identity_address_type in app_conf.h

This parameter is used in aci_gap_set_authentication_requirement and corresponds to SMP identity address type, which is now used as GAP identity address type when privacy is enabled.

Initialize the GAP layer. Register the GAP service with the GATT with aci_gap_init

2.1. First case - initialize the GAP layer with privacy enabled and use of the defined device address

aci_gap_init(privacy_enabled) Depending on the role of the device, to start advertising, scan request or connection request, Own_address_type must be set to RPA (0x02) (or NRPA (0x03)) which are allowed values when privacy is enabled.

For advertising, scan request or connection request, the device address (depending on Identity_address_type) will be used.

2.2. Second case - initialize the GAP layer with privacy enabled and use of a Resolvable Private Address

aci_gap_init(privacy_enabled) Depending on the role of the device, to start advertising, scan request or connection request, Own_address_type must be set to RPA (0x02) (or NRPA (0x03)) which are allowed values when privacy is enabled.

Now send aci_gap_add_devices_to_resolving_list(peer_identity_address_type equals to 0 or 1, Peer_address_type could be whatever except NULL address)

For advertising, scan request or connection request, a RPA will be used.
But device is not yet known.

2.3. Third case - initialize the GAP layer with privacy enabled and use of a Resolvable Private Address after bonding

aci_gap_init(privacy_enabled) Depending on the role of the device, to start advertising, scan request or connection request, Own_address_type must be set to RPA (0x02) which is one of allowed values when privacy is enabled.

Initiate a connection, a pairing (bonding enabled).
Note that like in first case proper address of the device is used.

Disconnect the link.
Now send aci_gap_add_devices_to_resolving_list(Peer_identity_address_type and peer_address_type of the previously bonded device)
Peer_identity_address_type and peer_address_type can be get with aci_gap_get_bonded_devices.

Depending on the role of the device, to start advertising, scan request or connection request, Own_address_type must be set to RPA (0x02) which is one of allowed values when privacy is enabled.

For advertising, scan request or connection request, a RPA will be generated and could be resolved by devices added in resolving list.
Note that both devices need to be in privacy mode. Privacy is necessary to activate the address resolution in Link Layer.

3. First example: Connection between a smartphone and a STM32WB

3.1. first phase - initialize the GAP layer with privacy enabled, connection and bonding - use of public address

3.2. second phase - add device to resolving list

4. Second example : Connection between two STM32WB

4.1. first phase - initialize the GAP layer with privacy enabled, connection and bonding. Use of static random address

4.2. second phase - add device to resolving list

5. Application example

ST Bluetooth® Low Energy Privacy example[1]

6. References