Central device has Issue with filtering based on peripheral Device Name

I have developed two codes based on app_ble_uart for central and peripheral and added peer manager to it for link encryption. The peripheral device advertise based on SIG UUID and its name. Central device is supposed to filter for SIG UUID and Device Name, and if both match the expected value, it would perform connection and then pairing. 

Peripheral device seems to work without problem. 

For central device code, when I just filter for SIG UUID, it works fine, connect to peripheral and send and receive data through UART-BLE encrypted link. But when I filter for both SIG UUID and Device Name, by adding the following: 

err_code = nrf_ble_scan_filter_set(&m_scan,SCAN_NAME_FILTER,m_target_periph_name);
APP_ERROR_CHECK(err_code);

I get this following error during debugging (at app_error_weak.c line 100 NRF_BREAKPOINT_COND): 

<info> app_timer: RTC: initialized.
<error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at \nRF5_SDK_17.0.2_d674dde\examples\My Projects\uart_central_wpmg_5\main.c:409
PC at: 0x00034765
<error> app: End of error report

When I comment out "APP_ERROR_CHECK(err_code);" part of the above code the issue is gone.

Can you advise what is the issue here? 

  • Hello Kaveh.m,

    Kaveh.M said:
    How can I make sure that the advertising packet of the peripheral includes all the datafields that the central is scanning for?

    The best way to debug issues in BLE communication is to use the nRF Sniffer tool. The nRF Sniffer tool is a powerful tool to wield when developing with BLE is the nRF Sniffer tool - it lets you see the contents of the packets being exchanged between the devices. In essence letting you listen into the on-air BLE traffic.
    You could use this to confirm that you are advertising and transferring as expected.

    It sounds strange to me that you are unable to match on both filters, but each separately works as expected. I do not immediately see what is wrong in the provided code. Could you confirm that you are doing active scanning in the code you used to try to match both filters? This should be configured during the scan initialization. If you only do passive scanning then the scanner will not send scan requests, which could be the reason why there is no filter match for the combination of the two (since the UUID's are in the scan response packet).

    If you could confirm that the advertising is as expected with the Sniffer then I can try to reproduce this on my end to debug and see what might be going wrong.

    Best regards,
    Karl

Related