The NRF52840 can not filter by MAC Address other BLE devices that are from other manufacturers.

Hi all!

I am working in a BLE scanner but I have enabled the filter by MAC ADDRESS.  I can filter  beacons that are produced  based in NRF52 and NRF51. But when i try set a MAC ADDRESS of a SOC produced by other company  the filter no match.

wich could be the problem?

Parents
  • Hi eudaldo!

    That should not happen at all. May I ask how you set up the other company device? Are you certain it is advertising? Can you see it on your phone, for example, with the nRF Connect app?

    Best regards,

    Hieu

  • I store the MAC ADDRESS in array of char, I put them in reverse (LSB  --> MSB) attach an example:

    char target_device[][6] = {
    {0x96, 0xEA, 0x57, 0x6E, 0x91, 0xDF},
    {0x13, 0x48, 0x35, 0x79, 0xBE, 0xEB},
    {0x68, 0xDA, 0xFC, 0x71, 0x77, 0x60},
    {0xBF, 0x92, 0xD9, 0x70, 0xAF, 0xFD},
    {0x8C, 0x4B, 0x7A, 0xD6, 0xAB, 0xFE},
    {0x0E, 0x2B, 0xE6, 0x5A, 0xA8, 0xE7},
    {0xC3, 0x6B, 0xD2, 0x56, 0x79, 0xEB}
    };

    I have try put the MAC ADDRESS in the normal form (MSB--->LSB), but it does not work.

    For set the filter I use the following code:

     //Setting filters for scanning.
    
    
        int rows =  sizeof (target_device) / 6;
    
        for (int t=0 ; t<rows; t++)
        {
              char td[] = { target_device[t][0],target_device[t][1]  ,target_device[t][2]  ,target_device[t][3] ,target_device[t][4]  ,target_device[t][5]};
              
              err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, td);
              
              APP_ERROR_CHECK(err_code);    
        }
    
       
         err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ADDR_FILTER, false);
         APP_ERROR_CHECK(err_code);

    I attach the devices that I want to scan:

  • I don't see anything wrong here. It really could just be that the nRF chip doesn't see beacon 3 at all...

    As a final test, could you reconfigure the scan module to print all BLE addresses it see without any filtering, and let it run for 1~2 minute?

    If beacon 3 still won't show up in that, perhaps we need to look at a sniffer trace

  • I have done, I modified the scan_init and scan_evt_handler and scan the beacon 2 and beacon 3:

    scan_init:

    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.connect_if_match = false;
        init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;
        init_scan.p_scan_param     = &m_scan_param;
    
        err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
        APP_ERROR_CHECK(err_code);
     
    }

    scan_evt_handler:

    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        ret_code_t err_code;
        char data_hex[10];
        char len[10];
        
    
        switch(p_scan_evt->scan_evt_id)
        {
    
            case NRF_BLE_SCAN_EVT_NOT_FOUND:  //FOB filter, it is filtered by the company ID           
                
                unsigned char* addr       =  p_scan_evt->params.p_not_found->peer_addr.addr;      
                   
                uart_putstring("ADDR:");
    
                for (int a=5; a>=0; a--)
                {
                      sprintf(data_hex,"%02x", addr[a] );
                      uart_putstring(data_hex);
                        
                }
    
                uart_putstring("\r\n");
                
            break;
    
    
            
            case NRF_BLE_SCAN_EVT_FILTER_MATCH:
           
                 
            break;
    
    
            
            default:
            break;
    
        }
        
    }

    and the result is the next:

    The NRF52 is able to see both beacons, but the problem is in NRF_BLE_SCAN_EVT_FILTER_MATCH, for some reason the Beacon 3 does not trigger the scan event. Disappointed

  • That is really very strange...

    Nothing stands out immediately to me right now. What is the advertising period of beacon 3? Other than let the filtered scan run for a long while and see how it goes, I don't have anything to recommend today...

    I am out of office today and tomorrow, so I will go over your code carefully one more time on Monday. If you need something urgent, please let me know here and we can arrange some alternatives.

  • Hi Hieu! 

    I managed to filter all the beacons!!! I have tried in differents version of the SDK, and with the SDK 17.1 with the with the most updated Soft Device S140, I succeeded

    thanks a lot Hieu!

  • Hi Carlos,

    It is still a problem that you observe that odd behavior with your previous SDK. If you can note here with what SDK you found the problem, that would be great.

    It's nevertheless great news that you solved the problem.

    Hieu

Reply Children
No Data
Related