cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with Setting Advertisement Data on STM32WB

JR2963
Senior II

Hi,

I have an STM32WB and I'm working with an example. I'm trying to understand how to add data to the advertisement data, including the name:

  1. I thought that all advertisement data is set here, 

 

 

ret = aci_gap_set_discoverable(ADV_IND,
				Min_Inter,
				Max_Inter,
				CFG_BLE_ADDRESS_TYPE,
				NO_WHITE_LIST_USE, /* use white list */
				sizeof(_advData),
				(uint8_t*) _advData,			BleApplicationContext.BleApplicationContext_legacy.advtServUUIDlen,
			BleApplicationContext.BleApplicationContext_legacy.advtServUUID,
				0,
				0);
​

 

and that I don't need to call any other function. Is this correct? Because there are other functions like hci_le_set_advertising_data or aci_gap_update_adv_data.

 

  • I found that the maximum size for advertisement data is 31 bytes, but from version BLE 5 should be able to set size of adv data more then 31 Bytes, Is it able to extend this data with STM32 Stack? How?

Here is how I fill my advData

 

 

static uint8_t _advData[BLE_ADV_DATA_SIZE /* flags */] = {
	/* first block - setting flags */
	0x02,
	AD_TYPE_FLAGS,
	FLAG_BIT_LE_GENERAL_DISCOVERABLE_MODE, // 2 = no time limit
	
	/* second block - name */
	BLE_BLE_NAME_FIX_PART_SIZE + 1, // 3 + 1 is name flag
	AD_TYPE_COMPLETE_LOCAL_NAME, // 9 = AD_TYPE_COMPLETE_LOCAL_NAME
	'G', // [5] G
	'W', // [6] W
	':', // [7] :
	BLE_DEV_MANUF_DATA_SIZE + 1, // 8 + 1 manuf data flag
	AD_TYPE_MANUFACTURER_SPECIFIC_DATA, // FF = Complete local name
	0, // index [10]
	1, // index [11]
	2, // index [12]
	3, // index [13]
	4, // index [14]
	5, // index [15]
	6, // index [16]
	7, // index [17]
};

 

 

When I call advData only with the function aci_gap_set_discoverable, it does not work correctly (see photo 1). However, if I additionally call the function hci_le_set_advertising_data(sizeof(_advData), (uint8_t*) _advData);, it works (see photo 2). If I call the function aci_gap_update_adv_data(sizeof(_advData), (uint8_t*) _advData); instead, it again does not work and is the same as photo 1.

What is the correct way to fill advertisement data?

photo 1 uncorrect.jpg

photo 2 correct.jpg

  

Thank you!

1 REPLY 1
STTwo-32
ST Employee

Hello @JR2963 

For the advertisement data update, you can use the command "aci_gap_update_adv_data". It can be used to update the advertising data for a particular AD type. If the AD type specified does not exist, then it is added to the advertising data. If the overall advertising data length is more than 31 octets after the update, then the command is rejected, and the old data is retained. 

For the extended advertising, I suggest you follow the implementation of this example. It should help you to understand how it works.

PS: the extended advertising is not supported by all mobile phones that support BLE since it is not mandatory to implement it.

Best Regards.

STTwo-32

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.