Adding 128 bit service uuid in advertising payload

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
prasanna
Offline
Last seen:2 months 1 week ago
加入:2020-09-29 11:56
Adding 128 bit service uuid in advertising payload

Hi,

I am trying to include the 128 bit service UUID in the advertising payload. I have tried to include in the adv_data as I did for other advertising elements like local. Please find the code attached below. If I try to run this, I cannot detect the peripheral at all. Firstly, I wanted to know is this the correct way to include the 128 bit UUID in the advertising payload or do I need to make use of functions defined in the ble_UUID.h. If so, could you explain how to do this (with an example if possible).

code

static const uint8_t adv_data[] = {
0 x04 GAP_DATA_TYPE_SHORT_LOCAL_NAME
'P', 'A', 'C',
0x03, GAP_DATA_TYPE_MANUFACTURER_SPEC, 0, 210,
0x02, GAP_DATA_TYPE_TX_POWER_LEVEL, 3,
0x11, GAP_DATA_TYPE_UUID128_LIST, 38, 174, 43, 4, 28, 220, 124, 186, 74, 74, 2,
189, 7, 77, 231, 35
};

Thanks in advance.

Device:
PM_Dialog
Offline
Last seen:3 days 13 hours ago
Staff
加入:2018-02-08 11:03
Hi prasanna

Hi prasanna

Please read the comments above the ble_gap_adv_data_set() :

"...The maximum Advertising Data length for undirected connectable advertising is BLE_ADV_DATA_LEN_MAX bytes (31 minus 3 that are reserved to set the Advertising Data type flags - which shall not be set in Advertising Data using this function)...*

In your case, the advertising data exceed the max value, so you should use the scan response data as well.

static const uint8_t adv_data[] = { 0x04, GAP_DATA_TYPE_LOCAL_NAME , 'P','A', 'C', 0x03, GAP_DATA_TYPE_MANUFACTURER_SPEC, 0x00, 0x01, 0x02, GAP_DATA_TYPE_TX_POWER_LEVEL, 0x03, }; static const uint8_t scan_resp[] = { 0x11, GAP_DATA_TYPE_UUID128_LIST, 0x11, 0x22, 0x33, 0x44, 0x00, 0x08, 0x54, 0x8F, 0x53, 0x41, 0x47, 0x45, 0x60, 0xC6, 0x56, 0xAA, }; /* Set advertising data */ ble_gap_adv_data_set(sizeof(adv_data), adv_data, sizeof(scan_resp), scan_resp);

You could use different UUID and manufacturer data according to your requirements.

Thanks, PM_Dialog

prasanna
Offline
Last seen:2 months 1 week ago
加入:2020-09-29 11:56
Dear PM_Dialog,

Dear PM_Dialog,

According to the maximum data you said (31 bytes -3), we are remained with 28 bytes. In my case I am using 4Bytes for local name, 3 for manufacturer data, 2 for tx power and 17 for UUID which results in 26 bytes lower than the allowed maximum bytes. I don't understand how am I exceeding the maximum payload.

注册ards,

Prasanna

prasanna
Offline
Last seen:2 months 1 week ago
加入:2020-09-29 11:56
Dear PM_Dialog,

Dear PM_Dialog,

I understood what was wrong. Some confusion in counting the number of bytes of payload. Now its clear. Thanks once again :)

注册ards, Prasanna

PM_Dialog
Offline
Last seen:3 days 13 hours ago
Staff
加入:2018-02-08 11:03
Hi prasanna,

Hi prasanna,

Thanks for accepting my answer and glad that you make it working. If you have any other follow-up question, please raise a new forum thread.

Thanks, PM_Dialog