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

How do I add a 128-bit UUID to my advertising packet

How do I add a 128-bit UUID? 

I am using SDK 14 and see hardly any examples of how to put a 128-bit UUID in my advertisements. 

The only relevant example I found is under  /nRF5_SDK_14.2.0_17b948a/examples/ble_peripheral/ble_app_pwr_profiling/main.c 

#define KIDDO_BASE_UUID {{0x33, 0xFE, 0x67, 0xCB, 0xEB, 0x92, 0x87, 0xB6, 0xE7, 0x11, 0x40, 0x34, 0x00, 0x00, 0x85, 0x2E}}

static ble_uuid128_t const m_base_uuid128 = KIDDO_BASE_UUID;
ble_uuid_t service_uuid;
ret_code_t err_code;

service_uuid.uuid = 0x0005;

err_code = sd_ble_uuid_vs_add(&m_base_uuid128, &service_uuid.type);
APP_ERROR_CHECK(err_code);

When I execute this, my device advertises, but without the 128-bit UUID. 

Parents
  • sd_ble_uuid_vs_add adds your custom characteristic -  it doesn't make it show up on your advertisement packets. You have to put that in yourself - maybe in the scan response. See for instance the ble_app_uart example in SDK 15.0.0.
    The NUS UUID is defined in:
    static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifier. */
    {
    {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}
    };
    It's used here, in advertising_init:

    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.srdata.uuids_complete.p_uuids = m_adv_uuids;
Reply
  • sd_ble_uuid_vs_add adds your custom characteristic -  it doesn't make it show up on your advertisement packets. You have to put that in yourself - maybe in the scan response. See for instance the ble_app_uart example in SDK 15.0.0.
    The NUS UUID is defined in:
    static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifier. */
    {
    {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}
    };
    It's used here, in advertising_init:

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