Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Simultaneous central / peripheral with whitelist only used in one role

Hello. The project that I'm working requires both central and peripheral role support, working simultaneously. There are times where, while advertising in the peripheral, I want to use the whitelist and device identities list (I use the peer manager to for this). In my central role, I am at times scanning and establishing connections, but I don't ever need or want to use the whitelist or device identity list.

In my testing, I am getting errors when I follow the below sequence of events:

1. Start scanning via call to sd_ble_gap_scan_start. Note that I'm not using the whitelist and not using directed advertisements.

2. While in the middle of scanning I'd like to advertise with the whitelist enabled. Before I start advertising, I call pm_whitelist_set to specify the peers that I would like to whitelist with. This call succeeds.

3. Next, I call pm_device_identities_list_set to provide the same peer ID. This call returns the error BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE. 

From within the peer manager I can see that the error is coming from the call to sd_ble_gap_device_identities_set. In the description for sd_ble_gap_device_identities_set, there is a comment that "The device identity list cannot be set if a BLE role is using the list." I don't understand why I'm getting this error. Since my scanning has both the use_whitelist and adv_dir_report fields set to 0, the device identity list should not already be in use.

It's strange because my call to pm_whitelist_set (which results in a call to sd_ble_gap_whitelist_set) succeeds, and sd_ble_gap_whitelist_set has a similar note about not working while in use.

I did a quick test to stop scanning (via a call to sd_ble_gap_scan_stop) immediately before calling pm_device_identities_list_set, and I no longer get the error. I imagine that to get around this issue I could do this in my application, and then immediately restart scanning after the call to pm_device_identities_list_set; however this is not a very desirable solution and adds a lot of complexity to my application.

Any idea why I might be getting this error?

Thanks!

Related