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? 

Parents
  • Hello,

    Could you check what you NRF_BLE_SCAN_NAME_CNT define is configured to in the sdk_config.h?
    The nrf_ble_scan_filter_set function will return the NRF_ERROR_INVALID_PARAM whenever the configured filter count for a specific filter type does not match the number of actually set filters.
    Increase NRF_BLE_SCAN_NAME_CNT according to your configuration, and let me know if it resolves your issue.

    Best regards,
    Karl

  • Thanks Karl. 

    NRF_BLE_SCAN_NAME_CNT was 0 and I changed it to 1. This cleared the NRF_ERROR_INVALID_PARAM error. 

    But now my devices does not join a connection anymore. They just keep scanning. 

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid);
    APP_ERROR_CHECK(err_code);


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


    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ALL_FILTER, true);
    APP_ERROR_CHECK(err_code);

    The issue seems to be with NRF_BLE_SCAN_ALL_FILTER macro. When I change that to NRF_BLE_SCAN_UUID_FILTER they connect. 

  • Kaveh.M said:

    Thanks Karl. 

    NRF_BLE_SCAN_NAME_CNT was 0 and I changed it to 1. This cleared the NRF_ERROR_INVALID_PARAM error. 

    No problem at all - I am happy to hear that this resolved your issue!

    Kaveh.M said:
    The issue seems to be with NRF_BLE_SCAN_ALL_FILTER macro. When I change that to NRF_BLE_SCAN_UUID_FILTER they connect. 

    Is your intention that the peripheral device must match all the set filters in order to initiate a connection? If so, have you made sure that the advertising packet of the peripheral includes all the datafields that the central is scanning for?
    The fact that the NRF_BLE_SCAN_UUID_FILTER works suggests that the name filter does not match. Could you enable just the name filtering, and see if it is able to find and match the peripheral's advertisements?

    Best regards,
    Karl

  • I want to filter for both Name and SIG UUID.

    It works when I just filter for the name. Please see below is the code I used for name filtering that works. 

Reply Children
No Data
Related