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

SDK 15.2 - SCAN_ADDR_FILTER

Problem Statement:

I have two eval kits, one running peripheral role and the other central role.  I'm trying to use the SCAN_ADDR_FILTER option so the central will connect to this specific peripheral by address. 

What I've tried:

I've hard-coded the peripheral's address into the central code per various SDK examples.

If I change to a name-based filter, the peripheral is discovered and connected successfully.  So it is verified to be advertising and connectable.

Code snippet from Central app:

static ble_gap_addr_t m_target_periph_addr =
{
    .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
    .addr      = {0xC1, 0x2E, 0x4A, 0xE0, 0x71, 0x81} // This matches what nRF Connect shows via Scan, for peripheral
};

...

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;
    init_scan.connect_if_match = true;
 
    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);
 
    if (is_connect_per_addr)
    {
        err_code = nrf_ble_scan_filter_set(&m_scan,
                                          SCAN_ADDR_FILTER,
                                          m_target_periph_addr.addr);
        APP_ERROR_CHECK(err_code);
    }
 
    err_code = nrf_ble_scan_filters_enable(&m_scan,
                                           NRF_BLE_SCAN_ALL_FILTER,
                                           false);
    APP_ERROR_CHECK(err_code);
}

Questions:

Am I using the wrong type of address (RANDOM_STATIC)? 

Is there I setting I need to update in the peripheral app to make address filtering work?

Related