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

Error when using SCAN_ADDR_FILTER during scanning

I have adapted the example ble_app_gattsin SDK_17. My code is as follows:

static ble_gap_addr_t m_target_periph_addr =
{
    .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
    .addr      = {0xCE, 0x6D, 0x22, 0x84, 0x9B, 0xF1} //F1:9B:84:22:6D:CE
};

static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;
    memset(&init_scan, 0, sizeof(init_scan));

    init_scan.p_scan_param     = &m_scan_param; //added
    init_scan.connect_if_match = true; //true-connects automatically if there is a filter match
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, m_target_periph_addr.addr);
        APP_ERROR_CHECK(err_code); //This causes an error!
        err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ADDR_FILTER,
                       false);
        APP_ERROR_CHECK(err_code);
}

However, an error is thrown when setting the scan filter as follows: nrf_ble_scan_filter_set()

When using the debugger, I see I get the following error on this line: APP_ERROR_CHECK(err_code);

The error is ERROR 7 [NRF_ERROR_INVALID_PARAM]

What could be the problem?

Related