2024-06-28 12:13 PM - edited 2024-07-01 01:01 AM
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:
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.
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?
Thank you!
2024-08-07 02:58 AM - edited 2024-08-07 03:01 AM
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.