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.

Parents Reply
  • This line:

    static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */
        {{B_SERVICE_UUID, BLE_UUID_TYPE_VENDOR_BEGIN}};
    

    Basically says: take the 16 bits of B_SERVICE_UUID and the remaining bits from the beginning of the vendor specific UUIDs table.

    And from your init code we can see that you add A_SERVICE first. So A_SERVICE_UUID_BASE will be the first entry in the vendor specific UUIDs table. And therefore BLE_UUID_TYPE_VENDOR_BEGIN will point to A_SERVICE_UUID_BASE.

    So I still think it is the same issue. And that the way to fix it is to change the way the advertising uuid is defined.

Children
Related