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

filter by address works for one mac address and not for the other

hello nordic

i am working with nrf52832, sdk 16 v7.0.1, s132

i build my app on the central ble_blinky example and i am scanning for beacon advertising

i added filter by address, when trying to scan for this address: 

static char const m_target_periph_addr[] = {0x8B, 0x3B, 0xA0, 0x0E, 0x6C, 0x54};

i get filter match and all is good but,  when trying to get match for one of those addresses

static char const m_target_periph_addr[] = {0xE9, 0x24, 0x33, 0xF9, 0x81, 0x00 }; 
static char const m_target_periph_addr[] = {0x70, 0x28, 0x33, 0xF9, 0x81, 0x00 };

i don't get a match, i can see on a print i put for the address in the event handler that i read this addresses but do not get a match, could you tell why is that ? is it a softdevice bug or something on my code or something else ?

here is my event handler:

void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;
    //const uint8_t* mac_address;
    //uint8_t* scan_data;

    mac_address = p_scan_evt->params.p_not_found->peer_addr.addr;
    //mac_address = p_scan_evt->params.filter_match.p_adv_report->peer_addr.addr;

    print_buf("mac: ", mac_address, 6);

  switch(p_scan_evt->scan_evt_id)
  {
    case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
        err_code = p_scan_evt->params.connecting_err.err_code;
        APP_ERROR_CHECK(err_code);
        break;

    case NRF_BLE_SCAN_EVT_FILTER_MATCH:
        mac_address = p_scan_evt->params.filter_match.p_adv_report->peer_addr.addr;
        scan_data = (uint16_t)(m_scan.scan_buffer_data[13] << 8);  // also option of (p_scan_evt->params.filter_match.p_adv_report->data) exist
        scan_data |= (uint16_t)m_scan.scan_buffer_data[14];
        ble_receive_flag = true; 
      
    default:
      break;
  }
}

p.s. very strange that even when using the p_scan_evt->params.filter_match... i get the printed address but i don't get a match event

my filter set is in the start scan function:

void ble_scan_start(void)
{
    ret_code_t err_code;

    nrf_ble_scan_all_filter_remove(&m_scan);
    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, m_target_periph_addr); //system_monitor.endo_mac_address);//m_target_periph_addr); // Dudi
    APP_ERROR_CHECK(err_code);

    // Setting filters for scanning.
    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ADDR_FILTER, false); // Dudi
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_start(&m_scan);
    APP_ERROR_CHECK(err_code);
}

here you can see scan results in the nrf connect app in my cellphone of one that works and one that does not

      

hope you can shade some light on the matter cause i have no debugging direction even after trying to figure this out for some time

hope to read from you soon

best regards

Ziv

Related