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!

  • Hi Sandeep, 

     

    Could you clarify if you scan using use_whitelist = 0 or not ? 

    I'm under the assumption that if scanning with use_whitelist = 1 even with an empty whitelist still mean whitelist is in use. 

    One suggestion that you can test is to start advertising with whitelist first, and then start scanning without whitelist. Just to check if there is any error. 

  • Hi Hung-

    I'm not using the whitelist when scanning, which is why I'm surprised that I'm getting the error.

    My code to start scanning looks like this:

    static const ble_gap_scan_params_t scanParams =
    {
        0,              // Passive scanning
        0,              // Not using directed advertising
        0,              // Not using whitelist
        160,            // 100ms scan interval
        160,            // 100ms scan window
        10               // 10 second timeout
    };
    
    err_code = sd_ble_gap_scan_start(&scanParams);
    APP_ERROR_CHECK(err_code);
    

    My code to start advertising looks like this:

    err_code = pm_whitelist_set(whitelistPeerId, 1);
    APP_ERROR_CHECK(err_code);
    
    err_code = pm_device_identities_list_set(whitelistPeerId, 1);
    APP_ERROR_CHECK(err_code);
            
    ble_advertising_start(BLE_ADV_MODE_FAST);
    

    I believe that I tried what you suggested (started advertising first and then started scanning without whitelist) and did not get an error, though I will double check to make sure.

    Thank you.

  • Update: I tried what you suggested, in that I started advertising first and then started scanning without using the whitelist (i.e. use_whitelist = 0). I do not get any error while calling sd_ble_gap_scan_start.

    As an experiment, I repeated the process, except this time I did enable the whitelist (i.e. use_whitelist = 1) when I started scanning. Interestingly, I still did not get any error when calling sd_ble_gap_scan_start.

    One note: I am using soft device S132 v4.0.2. I know that there are some newer versions that have been released since. By any chance are there any known bugs related to what I am seeing, or are there any bugs that have been fixed since the v4.0.2 release?

    Thanks.

  • Hi Sandeep, 

    Due to Easter holidays, most of our R&D engineer are on vacation now. I will try to get more information about the way identities handled in our softdevice when they are back. Ping me if you don't hear from me by the end of next week. 

  • Hi Sandeep, 

     

    Sorry for the late response. I got the information from our staff. Quoted here: 

    You can not call sd_ble_gap_device_identities_set if the scanner is running. Even though you set use_whitelist=0 when stating the scanner, it will still use the identity list to resolve addresses.

     

    It seems that you would need to do the trick to start advertising first before you start scanning. Or stop scanning, start advertising and start scanning again. In my opinion,  scanning with whitelist = 0 shouldn't use identity list. 

Related