Hi,
when try to modify BLE device name base DSPS demo. I met a issue that BLE device'name length not more than 7 bytes.
A preliminary analysis is caused by the following code :
device_name_avail_space = APP_ADV_DATA_MAX_SIZE - cmd->info.host.adv_data_len - 2;
I try to extend the ADV_DATA_LEN length,but it caused a serious issue that BLE device could not be found. I think it may be due to modify some key parameters such as ADV data length.
I want to know if there is a limit the length of the BLE device name? How to fix?
Thanks!
Mark Zhao
Device:
Hi mark.zhaofei,
广告字符串的限制是由BLE规范,有效载荷和标志定义的31个字节,只需通过更改nvds_tag_device_name和device_name_tag_len来设置7个字节大小的名称大小,即,您必须适合在广告字符串的有限空间中的名称。如果广告服务的标志,大小和有效载荷将在串中获取房间,因此您不会获得足够的空间以在广告字符串中拟合您的设备名称。固件检查可用空间并连接您的设备的名称以便适合。除了您可以在Device Name属性中的GAP服务中看到设备的整个名称。
Thanks MT_dialog
Hi MT_dialog,
Thanks for your reply. I had followed your advice. modify NVDS_TAG_DEVICE_NAME as "CNOGA_BLE01" and replace the default "DA1458x". At the same time the length DEVICE_NAME_TAG_LEN be increased from the original 7 to 11. But my mobilephnoe discover BLE device's name just is "CNOGA_B". This means that the 7 bytes of limit in other places.
分析发现,限制位于以下代码中:
device_name_length = co_min(device_name_length, device_name_avail_space); in the file of app_sps_device_project.c
device_name_avail_space depend on APP_ADV_DATA_MAX_SIZE and ADV_DATA_LEN.
Next step, I try to expand the size of the ADV_DATA_LEN from 0x1F to 0x23.but it cause more serious issue BLE device could not be found by mobilephone.
It seems to want to change the device name is not a simple matter.Looking forward to your reply! Thanks!
Hi mark.zhaofei,
The codesnippet states that the length of your name is going to be as long as the advertising string can fit. The advertising string is defined by the spec to be 31 (0x1F) bytes in total (including flags, payload, sizes, etc), you can't change the length of the advertising string (it will cause you trouble if you don't reply to the spec). In the DSPS application the advertising string goes like this:
0x02,0x01,0x06 - >默认广告数据
0x11,0x07,0xb7,0x5c, 0x49, 0xd2, 0x04, 0xa3, 0x40, 0x71, 0xa0, 0xb5, 0x35, 0x85, 0x3e, 0xb0, 0x83, 0x07 ->complete list of 128-bit UUID available (DSPS service 128bit UUID)
0x09, 0x09, whatever can fit in the remaining place -> 0x09 is the length of the remaining space, 0x09 is the tag for the devices name, the rest is the the devices name.
You can find the advertising string in the app_sps_device_project.h file.
Adding the allready placed bytes in the string result in 23 bytes that means that your devices name must fit in 8 bytes otherwise will be reduced by the codesnippet you posted.
That doesn't mean that your devices name is reduced, if you connect to your peripheral (with a simple application that shows the profiles database) and go into the GAP service and in the devices name characteristic you will be able to read the whole name you stated in your peripheral.
Thanks MT_dialog
Hi MT_dialog,
Thanks for your reply.I simply summarize my understanding, if there are any wrong, please correct me.
1.In advertising data there is only 8 bytes are used to put the device name.Even increase the length of the name can only be seen in the advertising data 8 bytes, the rest will be reduced.
if yes,may be many mobilephone just get a incomplete name. because only read the name of advertising data in discovery phase.?
2.We can get the whole name by GAP service in the devices name characteristic.
如果是,如何在发现全部的名字phase?
Thanks!
Hi mark.zhaofei,
1. For the DSPS application only 8 bytes are left for the application name. Even if you increase the name's length the function that you post will reduce the name that you have stated in the firmware. I dont know for sure but it seems that the mobile devices keep the name form the advertising string.
2. If you reduce the length of the allready placed bytes in the advertising string you can place the full name of your device. The DSPS because is a custom profile it needs 16 bytes of the advertising string that consumes a lot of space in the advertising string. If you want to keep the service declaration and also place the devices name in the advertising string what you can do is to place the service declaration in the scan response data and free the advertising string in order to put the whole name (up to 31 bytes with mandatory fields, flags, sizes) in it.
Thanks MT_dialog