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

Filters to be enabled as part of Scanning

Hello,

 

I am using nRF52840 S140 V7.0.1. I am using ble_app_multirole_lesc example. I changed roles from “Central and Peripheral” to “Observer and Broadcater”.

 

My understanding about filters are:

 

1) In nrf_ble_scan_filters_enable() we can pass about which filters to be enabled. Once enabled only advertisement packtes which match with those fileters will be passed to application under BLE_GAP_EVT_ADV_REPORT. Remaining will be discarded at low level only.

 

2) If we set true in nrf_ble_scan_filters_enable(), then all filters passed should match. If false either of the filters passed can be matched. So if we pass “NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER” and if it is false then advertisement packet either with exact name or UUID will be passed to application.

 

With about understanding my queries are:

 

1) Even after enabling with NRF_BLE_SCAN_UUID_FILTER filter why I am seeing all advertisemnt packets under BLE_GAP_EVT_ADV_REPORT.

2) Even I kept m_target_periph_name[] = "NordicLESCApp" and passed NRF_BLE_SCAN_NAME_FILTER in nrf_ble_scan_filters_enable(). But still I am seeing all advertisement packets under BLE_GAP_EVT_ADV_REPORT.

3) Even I pased true in nrf_ble_scan_filters_enable(). But still I am seeing all advertisment packets under BLE_GAP_EVT_ADV_REPORT.

 

In all above 3 cases I am seeing NRF_BLE_SCAN_EVT_NOT_FOUND in scan_evt_handler().

 

Thanks & Regards

Vishnu Beema

  • Hello Vishnu,

    These filters are intended to decide what device to connect to. You can see how they are used in nrf_ble_scan.c, in the nrf_ble_scan_on_adv_report() function.

    The softdevice doesn't filter based on these filter settings. It is up to the application (nrf_ble_scan.c). Depending on whether all_filter_mode is true or false, you need to match all the set filters, or only one in order to trigger the NRF_BLE_SCAN_EVT_FILTER_MATCH event or not. 

    It will also call nrf_ble_scan_connect_with_target() which will connect to the target in case of NRF_BLE_SCAN_EVT_FILTER_MATCH if .connect_if_match is true.

    So the assumption that the softdevice will filter out the advertisements and only pass the filter matched advertisements to BLE_GAP_EVT_ADV_REPORT event is not true. All advertisements will be forwarded to BLE_GAP_EVT_ADV_REPORT, but only the filter matches will be passed onto the NRF_BLE_SCAN_EVT_FILTER_MATCH event.

    Best regards,

    Edvin

  • Thank you for your inputs. Now I got better clarity.

Related