NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

BLE device name length

Open doktordra opened this issue 3 years ago • 7 comments

doktordra avatar Feb 25 '22 22:02 doktordra

Hello, Is it possible to have BLE device name longer than 8 characters AND 32 characters long UUIDs? Thanks!

doktordra avatar Feb 25 '22 23:02 doktordra

Hi, the advertising packet is limited to 31 bytes. So a 128bit uuid will use 18 of those bytes available for the name -2 bytes for the fields, so the max name length is 11 bytes in this case.

The same is true for the scan response data as the second uuid will be placed there.

h2zero avatar Feb 25 '22 23:02 h2zero

Thanks for your answer, but is there any way to bypass that limitation? I have devices already in the wild, with 10 character names and 128bit uuids, and I want to switch to NimBLE. My mobile app might have some issues if I switch to a different naming standards now. And, shouldn't these 11 bytes be more than just 8 characters, or my calculation is wrong? :) Thanks again!

doktordra avatar Feb 26 '22 01:02 doktordra

There is no workaround for this, it is part of the Bluetooth core specification (except Bluetooth 5.0+). Can you share your code used for this? I'm assuming this is working with the Bluedroid library and not here?

h2zero avatar Feb 26 '22 01:02 h2zero

Yep, the code is just the old library, nothing fancy. I use 10 character names and 128bit UUIDs (service, rx, tx) and it works with the old lib. I expected it to be the same here :(

doktordra avatar Feb 26 '22 02:02 doktordra

I don't see why that would happen, 10 chars should be available. Do you have any other data in the advertisements?

h2zero avatar Feb 26 '22 02:02 h2zero

@doktordra are these devices connectable? If not I may have an answer for this.

Otherwise I would suggest using the custom data option to set only the name and service uuids to avoid adding the flags data. If these are connectable devices this procedure will work but it's non-spec (flags required if connectable). The original library, I believe, does not include the flags data unless specified, which will free the additional 3 data bytes needed for your name data.

I will be applying a patch to allow the flags to be removed if the device is not connectable in the next release.

h2zero avatar Apr 08 '22 23:04 h2zero