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

device length about sd_ble_gap_device_name_set

Hi I use SDK 12.3 and sdk 2.0.1 , and set a device name length is 21 like "1234567890ABCDEFGHIJK" by sd_ble_gap_device_name_set; but in the advertise data the name length is only 18 and the name is "1234567890ABCDEFGH" ;

and on Android Phone display name is "1234567890ABCDEFGH", length 18; but on iOS Phone is "1234567890ABCDEFGHIJK" length 21;

so I don`t know which one is right , and why lost 3 octets name?

  • yes when i set a device name longer than 18 ; the advertise data only show the first 18 of name; I want an error response if the advertise data can`t show all data of the name longer than 18 when use sd_ble_gap_device_name_set() or set advertise data use sd_ble_gap_adv_start();

  • If you choose an advertising name that is too long, the code will just show the longest name possible within the 31 advertising bytes. It will not return an error (see this case).

    else
    {
        // Else short name needs to be used. Or application has requested use of short name.
        adv_data_format = BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME;
    
        // If application has set a preference on the short name size, it needs to be considered,
        // else fit what can be fit.
        if ((BLE_ADVDATA_SHORT_NAME == p_advdata->name_type) &&
                (p_advdata->short_name_len <= rem_adv_data_len))
        {
            // Short name fits available size.
            actual_length = p_advdata->short_name_len;
        }
        // Else whatever can fit the data buffer will be packed.
        else
        {
            actual_length = rem_adv_data_len;
        }
    }
    
  • You could always return an error in the last else block where the advertising name is shortened.

Related