BLE name advertising
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-02 6:22 AM
I'm developing a custom board with STM32WB55CGU6 with firmware based on Cable Replacement example. Trying changing the advertised name, I can not put more than 5 chars, the BLE stops working. I know the standard advertising supports until 7 chars. What I have to configure to have a bigger advertised name ?
Solved! Go to Solution.
- Labels:
-
BLE
-
STM32WB series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-03 12:37 PM
I would like to correct my statement above.
The total size of the packet set by the user cannot exceed 25 bytes because the BLE Stack add automatically the following standard AD types:
•AD Flags (3 bytes) => not 1 as I wrote above.
•TX Power Level (3 bytes)
So there is only 25 (not 28) bytes left for other additional AD data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-02 7:58 AM
could you share the code portion initialising the name?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-02 8:10 AM
It is from the Cable Replacement example, file app_ble.c,, line 204 :
static const char local_name[] = { AD_TYPE_COMPLETE_LOCAL_NAME, 'A', 'B', 'C', 'D', 'E'};
Name above runs well. If I put one more char, stops advertising.
I would like to have a bigger name (minimum 7 chars, wish 15 chars).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-02 8:14 AM
complementing code portion :
local_name used in (app_ble.c) :
static void Adv_Request( APP_BLE_ConnStatus_t New_Status )
{
...
/* Start Fast or Low Power Advertising */
ret = aci_gap_set_discoverable(
ADV_IND,
Min_Inter,
Max_Inter,
PUBLIC_ADDR,
NO_WHITE_LIST_USE, /* use white list */
sizeof(local_name),
(uint8_t*) &local_name,
BleApplicationContext.BleApplicationContext_legacy.advtServUUIDlen,
BleApplicationContext.BleApplicationContext_legacy.advtServUUID,
0,
0);
...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-03 9:21 AM
The way you defined the local name is correct. Now the blocking point could come from the advertising data size and its maximum payload which is 31 bytes. But …:
- The TX power level is always transmitted. This AD data is 2 bytes. The AD Flags (1 byte) is also automaticcally added. So there is only 28 bytes left for other additional AD data.
- Each new selected AD elements will be added to the AD Data array.
- The total size of the advertising packet has to be calculated dynamically to warn the user if the packet exceeds the 28 bytes limit after adding several AD elements in the AD Data array (ad_data[]).
So when you add the ADV data for the local name starting from an AD type of 0x08 : Shortened Local Name (5 bytes max) to 0x09 : Complete Local Name (10 bytes max), it may exceed the total allowed bytes.
Now either you remove one of the previous AD data but the ST example may expect it or you reduce the number of letter for your local name till it works (AD Data array size < 28 bytes). For example you can remove the AD_TYPE_MANUFACTURER_SPECIFIC_DATA to get more space for a wider local name.
But this Ad data related to manufacturer is required for the Cable replacement example to enable the connection.
The Manufacturer Specific data type is used for manufacturer specific data. This data size can range from 2 to 25 bytes. In the example below it is 5 bytes.
Or try to remove another AD data but it may lead to unpredictable results if the scanner side is expecting those data.
I added below a typical example of a complete AD data array
uint8_t ad_data[22] = { 2, AD_TYPE_TX_POWER_LEVEL, 0x00 /* 0 dBm */, // Transmission Power
9, AD_TYPE_COMPLETE_LOCAL_NAME, 'X', 'X', '-', 'S', 'T', 'M', '3', '2', // Complete Name
5, AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0x30, 0x00, 0x19 ,/* temperature */, 0x2A/* humidity */
2, AD_TYPE_LE_ROLE, 0x00 /* Only Peripheral role supported */};
In the end, just check what is inside the current advertizing packet to determine the remaining size you may have to extend the local name.
You can use the aci_gap_update_adv_data(…) function to Update the advertising data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-03 12:37 PM
I would like to correct my statement above.
The total size of the packet set by the user cannot exceed 25 bytes because the BLE Stack add automatically the following standard AD types:
•AD Flags (3 bytes) => not 1 as I wrote above.
•TX Power Level (3 bytes)
So there is only 25 (not 28) bytes left for other additional AD data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-10-10 12:53 PM
Hi Remy :
Thanks to your info, I was able to put a much bigger name (16 chars).
The fact was the Cable Replacement example included on advertising the TX Level
and another AD_TYPE_128_BIT_SERV_UUID, that occupied 20 bytes.
I commented it out, and now the advertisement has space for big names.
If possible, inform why was the 128-bit advertised. This is exactly the only one service I have.
Thank you
Ronald Benvenutti
Porto Alegre RS Brazil
Em qui, 3 de out de 2019 às 16:38, ST Community escreveu:
