Bluetooth advertising and private address resolution

Hi! 

We are failing to establish connection with third party devices (laptops, smartphones) in a couple of address-dependent advertising scenarios. 

The problem seems to be that zephyr fails to resolve the device's private address, and therefore match against the filter. 

Scenarios:

- direct advertising (against a device that was previously successfuly bonded): 
```
    advParam = *BT_LE_ADV_CONN_DIR_LOW_DUTY(advConfig.addr);
    advParam.options |= BT_LE_ADV_OPT_DIR_ADDR_RPA;
    err = BT_LE_ADV_START(&advParam, adHid, sdHid);
```
- advertising with an allow list (of all bonded devices): 
```
    setFilters(advConfig);
    advParam = *BT_LE_ADV_CONN_ONE_TIME;
    advParam.options = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | BT_LE_ADV_OPT_FILTER_CONN | BT_LE_ADV_OPT_USE_IDENTITY;
```
- using non-connectable advertising in order to figure out the list of available centrals (we see scan requests, but none of the addresses match):
```
    advParam = *BT_LE_ADV_CONN_ONE_TIME;
    advParam.options = BT_LE_ADV_OPT_NOTIFY_SCAN_REQ | BT_LE_ADV_OPT_SCANNABLE;
    bt_le_ext_adv_update_param(advExt, &advParam);
    bt_le_ext_adv_set_data(advExt, ...);
    bt_le_ext_adv_start(advExt, BT_LE_EXT_ADV_START_DEFAULT);
```

As for motivations, we are trying to support multiple connections at the same time, but struggle with hosts that are trying to aggresively connect when we don't want them to connect - e.g., the bond was already deleted on peripheral or because we want to connect to another device.

Any ideas what may be wrong or how to debug this? Are there any prerequisites that I have missed? 

Why are we seeing those aggresive reconnection loops with our device (host trying to connect again and again, producing hundreds of connect/disconnect notifications), but have not experienced similar behavior with third party products?

Using zephyr 3.7.99, codebase at https://bit.ly/4n33Vd6 (indirection for privacy reasons), relevant files in device/src/bt_advertise.c, device/prj.conf.overlays. 

  • If your device advertised/used HID profile, expect modern hosts to aggressively establish a connection.

    Users don't like it when their wireless mice and keyboards won't work properly - that is why reconnect attempts run very quickly.

    Fix is to unpair the device/remove the bond from the host.

    If your device is intended to be connected to by different hosts, don't use HID profile at all.

Related