Scanned RPA device showing address type being BLE_ADDR_TYPE_RANDOM

refuhoo
Posts: 2
Joined: Tue Sep 25, 2018 7:06 am

Scanned RPA device showing address type being BLE_ADDR_TYPE_RANDOM

Postby refuhoo » Sun Oct 14, 2018 9:15 pm

Hi,

I'm working on pairing a EPS32 with another BLE chip (from TI). After bound and reconnecting, I'm making the other BLE chip advertising using directed adv and RPA. But I'm facing two issues:

1. The scan result in ESP32 shows the address type is BLE_ADDR_TYPE_RANDOM, while it should be BLE_ADDR_TYPE_RPA_PUBLIC. It seems to be a but in ESP32, because I tried doing the same thing using two TI BLE chips, and it's working as expected: the central TI chip can see adv from the other TI chip, while address type being RPA.
case ESP_GAP_BLE_SCAN_RESULT_EVT: {
esp_ble_gap_cb_param_t *scan_result = (esp_ble_gap_cb_param_t *)param;
switch (scan_result->scan_rst.search_evt) {
case ESP_GAP_SEARCH_INQ_RES_EVT:
scan_result->scan_rst.ble_addr_type is BLE_ADDR_TYPE_RANDOM
scan_result->scan_rst.ble_evt_type is ESP_BLE_EVT_CONN_DIR_ADV

2. If I do esp_ble_gap_config_local_privacy(true), ESP32 uses random address to scan. I want the other chip to do directed adv when reconnecting. How do I make directed adv targeting a random address since it changes? I know it doesn't change all the time, but if the BLE chip runs out of power for several days and ESP32 reboots, how will directed adv work?
So I'm doing esp_ble_gap_config_local_privacy(false) but I'm not sure if it's the right thing to do.

thanks
Malcolm

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: Scanned RPA device showing address type being BLE_ADDR_TYPE_RANDOM

Postby chegewara » Tue Oct 16, 2018 12:43 am

1. This is great explanation how it works in esp-idf:
https://github.com/espressif/esp-idf/issues/2559

2. Directed advertising can only work if 2 peer device are bonded and exchange IRK key. From bluetooth specs:
To generate a resolvable private address, the device must have either the
Local Identity Resolving Key (IRK) or the Peer Identity Resolving Key (IRK).
The resolvable private address shall be generated with the IRK and a randomly
generated 24-bit number
When peer devices exchange key then it does not matter how often esp32 will change address as long as it will use resolvable private address. In esp32 this can be achieved with:

Code: Select all

esp_ble_gap_config_local_privacy(true);
// and
.own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC or BLE_ADDR_TYPE_RPA_RANDOM
If you have any further questions i will assist.

cashchew
Posts: 5
Joined: Wed Sep 18, 2019 4:14 pm

Re: Scanned RPA device showing address type being BLE_ADDR_TYPE_RANDOM

Postby cashchew » Wed Apr 08, 2020 1:53 pm

@chegawara, what is the usage difference between BLE_ADDR_TYPE_RPA_PUBLIC vs BLE_ADDR_TYPE_RPA_RANDOM? If I use BLE_ADDR_TYPE_RPA_RANDOM, do I need to call esp_ble_gap_set_rand_addr(random_static_addr)? Will the IRK get changed every time I change random_static_addr value?

Who is online

Users browsing this forum: Baidu [Spider], ESP_Roland and 88 guests