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

Get device name from filter match event

Using the scanner module, I set up a scan filter to scan for UUID with no auto connect. In the scan_evt_handler, I have a switch case for the NRF_BLE_SCAN_EVT_FILTER_MATCH.

I see that the filter match has p_adv_report attached to the event structure. I am trying to get the full device name from it, but am not having any luck.

case NRF_BLE_SCAN_EVT_FILTER_MATCH:
{
    volatile nrf_ble_scan_evt_filter_match_t const* filterMatch = &p_scan_evt->params.filter_match;
    volatile uint8_t *data = ble_advdata_parse(filterMatch->p_adv_report->data.p_data, filterMatch->p_adv_report->data.len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
    NRF_LOG_INFO("Filter Match.");

}

The data pointer returned from ble_advdata_parse is always 0x00000000. The advertising device is just the base ble_app_uart example app and it is set up to advertise the full device name. I see the name in nrf_connect phone app when scanned.

What am I missing?

  • Hi,

    In the ble_app_uart example, the name is part of the advertising data, but the uuid is part of the scan response data. That is, they are not both in the same advertisement packet. The advertising data that you get is from the scan response only, which is the set of advertising data that matched with the UUID filter.

    You could for instance read out the peer address from the advertising report (from the scan response matched by the filter), then filter on that address, in order to get the advertising data (containing the name) on a subsequent scan.

    Regards,
    Terje

Related