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

Scan filter with name as well as with MAC address

Hello,

I want to enable the scanning with name for the first scanning of the device and after connecting to that device its address will be saved. After disconnection with this connected device the for again connecting to the same device only i want to use the white list with the Address filter .

Is it possible to do so and if yes how?

Also for using white list filter i am getting parameter invalid error. I have following settings done 

p_scan_param.active = 1;
p_scan_param.interval = NRF_BLE_SCAN_SCAN_INTERVAL;
p_scan_param.window = NRF_BLE_SCAN_SCAN_WINDOW;
p_scan_param.timeout = NRF_BLE_SCAN_SCAN_DURATION;
p_scan_param.filter_policy = BLE_GAP_SCAN_FP_WHITELIST;
p_scan_param.scan_phys = BLE_GAP_PHY_1MBPS;

Is there anything wrong?

 I am getting error to  sd_ble_gap_scan_start  function with error ID 7(NRF_ERROR_INVALID_PARAM). I am not getting the reason behind this? 

  • Hi

    The ble_app_hrs_c example implements name filtering, you can use that as a template.

    The INVALID_PARAM error refers to an invalid parameter somewhere in your scanning function. What are your scan parameters set to? Might be the window, interval or duration are not valid values. As far as I can see, the only difference in yours and the example code is that you're using NRF_BLE_SCAN_SCAN_DURATION instead of SCAN_DURATION_WITELIST (Yes, WITELIST without an H. error in the SDK).

    Best regards,

    Simon

  • Thanks for your reply Simonr.

    I got the issue of getting parameter failure , i was enabling  White list in scan parameters and just enabling the address filter in the code . whereas the filters and white list feature has difference .

    p_scan_param.active = 1;
    p_scan_param.interval = NRF_BLE_SCAN_SCAN_INTERVAL;
    p_scan_param.window = NRF_BLE_SCAN_SCAN_WINDOW;
    p_scan_param.timeout = NRF_BLE_SCAN_SCAN_DURATION;
    p_scan_param.filter_policy = BLE_GAP_SCAN_FP_WHITELIST;
    p_scan_param.scan_phys = BLE_GAP_PHY_1MBPS;

    Above configurations were done and 

    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ADDR_FILTER, false);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, m_target_periph_addr);
    APP_ERROR_CHECK(err_code); 

    were called. (m_target_periph_addr = "CD1F3AB343FC";) which was wrong.

    Then i just replaced

    p_scan_param.filter_policy = BLE_GAP_SCAN_FP_WHITELIST;

    with BLE_GAP_SCAN_FP_ACCEPT_ALL.

    now it is working for the address filter properly.

Related