This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Advertise multiple vendor UUIDs

Hello!

I hope this question has not been asked before - at least I can't find it. I do have an application with two vender specific services (128bit UUID's) and I want to advertise both of them.

First: I know how to advertise two standard services (16bit UUIDs):

ble_uuid_t m_adv_uuids[] = 
{
    {BLE_UUID_SERVICE_ONE, BLE_UUID_TYPE_BLE},
    {BLE_UUID_SERVICE_TWO, BLE_UUID_TYPE_BLE}
};

image description

Second: I know how to advertise one vendor Service (128bit UUID):

ble_uuid_t m_adv_uuids[] = 
{
    {BLE_UUID_SERVICE_ONE, BLE_UUID_TYPE_VENDOR_BEGIN}
};

image description

But when I want to add a sencond vendor UUID to "Second", I end up in errors. Mixing BLE and VENDOR_BEGIN is possible, but than I only have one 128bit UUID and the others are 16bit.

PS: Adding UUIDs is done the folowing way:

ble_advdata_t srdata;
memset(&srdata, 0, sizeof(srdata));

srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
srdata.uuids_complete.p_uuids = m_adv_uuids;

Thanks, Johann

Parents
  • You can send UUIDs both in advertisement packet and in scan response packet. Scan response packet is initialized the same way as the advertisement packet (same struct -> ble_advdata_t). The ble_app_uart example in the SDK sends the UUIDs in the scan response packet to save power (less bytes sent if few scan responses is received), so you can see how it is done there.

    To be correct you also should populate the uuids_more_available field in ble_advdata_t and not uuids_complete field as there are more UUIDs available.

    Also take a look at this great tutorial on advertising.

Reply
  • You can send UUIDs both in advertisement packet and in scan response packet. Scan response packet is initialized the same way as the advertisement packet (same struct -> ble_advdata_t). The ble_app_uart example in the SDK sends the UUIDs in the scan response packet to save power (less bytes sent if few scan responses is received), so you can see how it is done there.

    To be correct you also should populate the uuids_more_available field in ble_advdata_t and not uuids_complete field as there are more UUIDs available.

    Also take a look at this great tutorial on advertising.

Children
Related