This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Use of whitelist

I m using The nRF52840 + STM32 with serialization library. My device is set in central mode and i want to active whitelist,

the configuration seems to be applied correctly: no error are shown on any side but i don't receive any advertisement frame.

    _scan_param.extended = 1;                // Set if accept extended advertising packetets.
    _scan_param.report_incomplete_evts = 0;  // Set if report inomplete reports.
    _scan_param.active = 1;                  // Set if active scanning.
    _scan_param.filter_policy = BLE_GAP_SCAN_FP_WHITELIST;
    _scan_param.scan_phys = BLE_GAP_PHY_1MBPS;
    _scan_param.interval = (uint16_t) SCAN_INTERVAL;
    _scan_param.window = (uint16_t) SCAN_WINDOW;
    _scan_param.timeout = (uint16_t) SCAN_TIMEOUT;

    ble_gap_addr_t wl_addr_array[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
    ble_gap_addr_t *array[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];

    for (size_t i = 0; i < _devices.size(); i ++) {
        array[i] = &wl_addr_array[i];
        memcpy(wl_addr_array[i].addr, _devices[i]->get_address(), BLE_BD_ADDR_LEN);
        wl_addr_array[i].addr_id_peer = 0;
        wl_addr_array[i].addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;//BLE_GAP_ADDR_TYPE_RANDOM_STATIC
    }

    uint32_t rc = sd_ble_gap_whitelist_set(wl_addr_array, length);

    if (rc != NRF_SUCCESS) {
        tr_error("Failed to set whitelist: %" PRIu32, rc);
    }

    uint32_t error_code = sd_ble_gap_scan_start(&_scan_param, &_adv_report_buffer);

    if (error_code != NRF_SUCCESS) {
        tr_error("Initial scan start failed: %"  PRIu32, error_code);
    }

The example provided in the following link explains that it is necessary to give the scan event handler as a parameter .

is there an equivalent to the function below use in serialization library?

err_code = nrf_ble_scan_init(&m_scan, &scan_init, scan_evt_handler)

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Flib_ble_scan.html

https://jimmywongiot.com/2019/10/18/ble-scanning-with-whitelist/

Do you think that my configuration is correct?

Do you have an example on the use of whitelist in serialization mode?

Thank you

Parents
  • Hello,


    I'm a team mate of Hamdi.

    We are still investigation on how to use whitelist.
    I wanted to emphasize on the fact that we started from a working projet: from the STM32 we periodically ask the nrf52 to scan and it feeds the STM32 with data we can use.
    From this working starting point we changed:
            scan_param.filter_policy form BLE_GAP_SCAN_FP_ACCEPT_ALL to BLE_GAP_SCAN_FP_WHITELIST
    and added the the call to sd_ble_gap_whitelist_set()

    As Hamdi said, this configuration did not trigger any error (from the returned error codes perspective). But it prevents the STM32 to receive any more data from the nrf52.
    We traced as much as we can on both sides.
    What we can say so far is that after adding the whitelist we did not get any more data from the softdevice on the nrf52 side.
    Is there any way to ask the softdevice to trace what is filtering and why?

    Any clues would be very welcome as we are currently stuck and ran out of idea.

    Regards

  • Hi,

    So you are no longer getting any events of type BLE_GAP_EVT_ADV_REPORT ?

    Are you sure that the BLE address you have added to the whitelist is correct? and that the address type is actually BLE_GAP_ADDR_TYPE_PUBLIC ?

    Try scanning with a phone using nRF Connect for mobile, and check the BLE address of the advertiser.

  • Hello,

    As far as I can tell, we are no longer getting events of any types, so no event of type BLE_GAP_EVT_ADV_REPORT either, (our event handler should emit a trace if it gets an event it don't manage).

    Regarding the addresses we have some temperature sensors that emit beacons. We used the nRF  Connect to look at them and get their address.
    What we did at first was to filter beacons using those addresses in our handled for the  BLE_GAP_EVT_ADV_REPORT event.
    It works but we think it's not efficient that's why we started investigating with the whitelist to filter asap.
    Following this, I'm guessing that the type of address is ok (they really are BLE_GAP_ADDR_TYPE_PUBLIC).
    I had also doubted we transmitted the addresses correctly (big or little endian issue) so for one sensor I took its address and added it twice, each time with a different endianness.

    No error are reported from function calls.

    One thing I'm not sure we clearly stated is that the nrf is running the connectivity app provided with the sdk. We added some traces on nrf side, it seems to went fine on this side too (i.e. the whitelist is correctly transmitted to the softdevice). What I wish to be able to do is to have some feedback from the softdevice (some traces) when it filters out beacon because of whitelist or things like that.

    Thanks for your feedback :)

  • I'm still nowhere near having found a solution.

    Does the connectivity app provided as an example support whitelist or is there something in its configuration that prevent whitelist to work?

    Still hoping for help,
    Regards

  • Hi,

    Does the connectivity app provided as an example support whitelist or is there something in its configuration that prevent whitelist to work?

    As far as I know, it should work fine.

    Do you have a spare nRF52 DK? If so, could you try this experiment.

    Program the DK with ble_app_blinky example from the nRF5 SDK, where you set this address, snippet:

    static ble_gap_addr_t const m_peripheral_addr =
    {
        .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
        .addr      = {0xCE, 0x42, 0xBB, 0xD5, 0x91, 0xE9}
    };
    
    
    /**@brief Function for application main entry.
     */
    int main(void)
    {
        // Initialize.
        log_init();
        leds_init();
        timers_init();
        buttons_init();
        power_management_init();
        ble_stack_init();
    
        uint32_t err_code = sd_ble_gap_addr_set(&m_peripheral_addr);
        APP_ERROR_CHECK(err_code);

    Then, on the central side, i.e. on your nRF52840 + STM32 with serialization library setup, you set the whitelist like this:

    #define WHITELIST_PEERS 1
    
    const ble_gap_addr_t const m_peripheral_addr =
    {
        .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
        .addr      = {0xCE, 0x42, 0xBB, 0xD5, 0x91, 0xE9}
    };
    
    ble_gap_addr_t const * addr_ptrs[WHITELIST_PEERS];
    
    int main(void)
    {
        // Initialize the stack, etc..
        ..
        ..
    
        addr_ptrs[0] = &m_peripheral_addr;
        uint32_t err_code = sd_ble_gap_whitelist_set(addr_ptrs, 1);
        APP_ERROR_CHECK(err_code);
        
        ..
        ..

    Do you get BLE_GAP_EVT_ADV_REPORT ?

    PS: Make sure that you restart the scanning if you get the BLE_GAP_EVT_TIMEOUT event with Timeout source set to BLE_GAP_TIMEOUT_SRC_SCAN.

  • Hello,

    I've tested what you suggested and it works fine!!!
    So I've found the issue on our side, it appears that the beacons I'm using for test purpose is using (like in you example) an address of type RANDOM_STATIC while we were thinking it was PUBLIC.

    Many many thanks!

  • Jean-Francois said:
    I've tested what you suggested and it works fine!!!
    So I've found the issue on our side, it appears that the beacons I'm using for test purpose is using (like in you example) an address of type RANDOM_STATIC while we were thinking it was PUBLIC.

    Many many thanks!

     Great! You're welcome :)

Reply Children
No Data
Related