This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to scan devices based name patterns?

I have nRF52840 as the central and nRF52832 as the devices. I have the device names as TELCO_456, TELCO_457, TELCO_458 in the connectable advertisement packet. I have disabled auto connect in the central and I want a scan interrupt when these peripheral devices are available.

How can I set my scan filter settings in the central ?

I'm using SDK16 and SD suitable for this version.

Parents Reply Children
  • Could you modify the function nRF5SDK17009d13099\nRF5_SDK_17.0.0_9d13099\components\ble\common\ble_advdata.c-->ble_advdata_name_find(..) accordingly:

    bool ble_advdata_name_find(uint8_t const * p_encoded_data,
                               uint16_t        data_len,
                               char    const * p_target_name)
    {
        uint16_t        parsed_name_len;
        uint8_t const * p_parsed_name;
        uint16_t        data_offset          = 0;
    
        if (p_target_name == NULL)
        {
            return false;
        }
    
    
        parsed_name_len = ble_advdata_search(p_encoded_data,
                                             data_len,
                                             &data_offset,
                                             BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
    
        p_parsed_name = &p_encoded_data[data_offset];
    
        if (   (data_offset != 0)
            && (parsed_name_len != 0)
            /*&& (strlen(p_target_name) == parsed_name_len)*/ //Comment out
            /*&& (memcmp(p_target_name, p_parsed_name, parsed_name_len) == 0))*/ //Comment out
            && (memcmp(p_target_name, p_parsed_name, strlen(p_target_name)) == 0) //Added
        {
            return true;
        }
    
        return false;
    }

    • Then you add the name "TELCO_" using the function nrf_ble_scan_filter_set()

    I have not tested this, but I think it should work.

    Best regards,

    Simon

  • This works and solved my problem, thanks so much Simon!

  • I am happy you found my solution helpful!

Related