cancel
Showing results for 
Search instead for 
Did you mean: 

BLE name advertising

rbenv.3
Associate II

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
Remi QUINTIN
ST Employee

​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.

View solution in original post

6 REPLIES 6
Mich1
Associate III

could you share the code portion initialising the name?

rbenv.3
Associate II

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).

rbenv.3
Associate II

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);

...

}

Remi QUINTIN
ST Employee

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.

Remi QUINTIN
ST Employee

​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.

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: