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

SCAN NAME FILTER not work when NAME has NULL(\x00) in ADV packet.


Hi,

If i use SCAN_NAME_FILTER, the function nrf_ble_scan_filter_set's 3rd argument is null-terminated string.

But HM-10 send FULL NAME including null(0x00) characters and size including null chars.

"HMSoft" is delivered in ADV packet.

len = 14

type=0x09

"HMSoft\x00\x00\x00\x00"

In nordic source

FILE : ble_advdata.c

FUNCTION :ble_advdata_name_find

parsed_name_lne include null characters. So

it returns false.

Which is problem ?

a) adv packet includes null characters and length include null characters

b) nordic nrf_ble_scan_filter_set with NAME_FILLTER that treats name as null-terminated string.

Thanks..

Parents Reply Children
  • It will not work. The problem is

    >> nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name);

    function nrf_blescan_filter_set get the name only without length of the name array.

    The function can not know whether how many null characters are included in name.

    Name from advertisement message has null characters and length include the null-charaters.

    See below source.

    the name compare not using strcmp but memcmp and length check is included.

    I have changed to strcmp and it works ok now.

    FIle : cble_advdata.c

    Function : ble_advdata_name_find

    #if 0
    if ( (data_offset != 0)
    && (parsed_name_len != 0)
    && (strlen(p_target_name) == parsed_name_len)
    && (memcmp(p_target_name, p_parsed_name, parsed_name_len) == 0))
    {
    return true;
    }
    #else
    if ( (data_offset != 0)
    && (parsed_name_len != 0)
    // && (strlen(p_target_name) == parsed_name_len)
    && (strcmp(p_target_name, p_parsed_name) == 0))
    {
    return true;
    }
    #endif // by holic

Related