androidbluetoothandroid-bluetooth

How to know the maximum length of BT name


I have to define a maximum length of my android device BT name , and I have no idea about the max length defined by the Bluetooth standard.

I found this :

Is there a minimum device name length for BLE 4.0 advertising local name complete?

But I am not sure if it's the same for my case .


Solution

  • It depends on the context in which you want to use the Bluetooth device name as follows:-

    Classic Bluetooth - This is the limit if you want to define the maximum name over classic Bluetooth. As the link that you provide suggests, the maximum length of your Android device's local name should be 248 octets (Bluetooth Specification v5.2, Vol 4, Part E, Section 6.23).

    Bluetooth Low Energy (BLE) - According to the Supplement to Core Bluetooth (CSS), version 9, Part A, section 1.2, the Local name can be either be the same as the one displayed over Classic Bluetooth (i.e. it also has a maximum of 248 octets), or a shortened version if you want to display the name over BLE adverts. For BLE adverts, because the maximum advert length is 31 bytes, it is recommended to keep the name at 10 bytes or lower (so that you have space for other advert elements), however, you can theoretically use a maximum of 29 bytes for the short name (leaving a byte for the advert type and a byte for the advert length).

    If the name is shortened, the not shortened version should be made available via the device name characteristic over GATT (a connection needs to be made in order to read this).

    The following guideline is given in the supplement:-

    A shortened name shall only contain contiguous characters from the beginning of the full name. For example, if the device name is ‘BT_Device_Name’ then the shortened name could be ‘BT_Device’ or ‘BT_Dev’.

    You can find both the Core Bluetooth Specification and its supplement here:-

    https://www.bluetooth.com/specifications/bluetooth-core-specification/

    Some other useful references:-