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

Device Short name in advertisement

Hi,

Is there a way to set a different short name in the advertisement for a Bluetooth device beside the truncated full name?

Thanks,

Sam

  • Hi Sam, 

    Did you set ble_advdata_name_type_t as BLE_ADVDATA_SHORT_NAME?

    The advertising name will automatically be truncated when there isn't any room for the whole name in the advertising packet. Remember that you can only fit 31 bytes of data in the advertising packet. If you try to remove some data from the advertising packet, you should be able to see the entire name advertised.

    Be advised that each new data field comes with two bytes overhead - one to indicate length, and one to indicate the type. Alternatively, you could also use the SHORTENED name option, to maximally allocate 6 bytes to the device name. Please check the contents of the advertisements do not exceed 31 bytes in total when the device name is cut short.

    -Amanda H.

  • Hi Amanda,

    I know that the advertising name is automatically truncated when BLE_ADVDATA_SHORT_NAME is set. My question is that if there is any way to set this short name to some other short name different than the first n characters of the full name.

    Thanks,

    Sam

  • If I understand you correctly you would like to change the truncated version of the name full name in the case where you have originally chosen BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME and the full name doesn't fit.

    I think this can be achieved by modifying the function name_encode() in nRF5_SDK_17.0.0_9d13099\components\ble\common\ble_advdata.c. There you can see that the name is fetched using sd_ble_gap_device_name_get() and placed directly into p_encoded_data.

    You should modify the function to put in your alternative short name into p_encoded_data if the full name doesn't fit.

    Please tell me if anything is unclear.

    Best regards,

    Simon

Related