Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it important to first add the advertising service UUID?

Given a peripheral with BLE services A and B, if I advertise B but add A first during my services_init code, then the 16 bit UUID portion of B is added to A's long UUID. Is this intended behaviour i.e. should the service to be advertised always be added first? Certainly, if I add B first then the advertising UUID is correct.

  • Hi,

     Is B a predefined service and is A a custom service? What are you using as a base UUID? Could you provide some code that shows where you set the UUID of B and A and any base UUID if it's used. I need a better overview over what you're actually doing. 

    regards

    Jared 

  • This sounds familiar. Could it be similar to this case?

  • Thank you for sharing this thread. It might very well be similar to that case. 

  • Both A and B are custom services.

    Here's how my UUIDs are declared (relevant portions are shown only):

    // UUID eba38534-0bcb-4b34-85a3-85b9744ccc5f
    #define A_SERVICE_UUID_BASE                                                                   \
        {                                                                                                  \
            0x5f, 0xcc, 0x4c, 0x74, 0xb9, 0x85, 0xa3, 0x85, 0x34, 0x4b, 0xcb, 0x0b, 0x34, 0x85, 0xa3, 0xeb \
        }
    
    #define A_SERVICE_UUID 0x8534
    
    // UUID 148d12e2-a31e-4117-b763-403cc42efa61
    #define B_SERVICE_UUID_BASE                                                               \
        {                                                                                                  \
            0x61, 0xfa, 0x2e, 0xc4, 0x3c, 0x40, 0x63, 0xb7, 0x17, 0x41, 0x1e, 0xa3, 0xe2, 0x12, 0x8d, 0x14 \
        }
    
    #define B_SERVICE_UUID 0x12e2
    
    static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */
        {{B_SERVICE_UUID, BLE_UUID_TYPE_VENDOR_BEGIN}};
    
    ...
    
        // Add A Service UUID
        ble_uuid128_t base_uuid = {A_SERVICE_UUID_BASE};
        err_code = sd_ble_uuid_vs_add(&base_uuid, &p_a->uuid_type);
        VERIFY_SUCCESS(err_code);
    
        ble_uuid.type = p_a->uuid_type;
        ble_uuid.uuid = A_SERVICE_UUID;
    
        // Add the Service
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_a->service_handle);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    
    ...
    
        // Add B Service UUID
        ble_uuid128_t base_uuid = {B_SERVICE_UUID_BASE};
        err_code = sd_ble_uuid_vs_add(&base_uuid, &p_b->uuid_type);
        VERIFY_SUCCESS(err_code);
    
        ble_uuid.type = p_b->uuid_type;
        ble_uuid.uuid = B_SERVICE_UUID;
    
        // Add the Service
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_b->service_handle);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }

  • I'm not sure that they are the same issue as I'm using two custom services (a point of difference).

Related