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

Custom 128bit UUID is Advertised Incorrectly

Hello, 

I am having some trouble attempting to advertise a single custom 128bit uuid. I have two custom services sharing the same base uuid. Everything works correctly after connecting, the correct uuids show up for both services and chars. The problem is that the base uuid being advertised is completely wrong, and I'm not sure why. Oddly enough the service portion seems to work, which is 0x0100 and 0x0200 in my case, if I swap the services being advertised. I followed everything in this guide to be able to advertise a full 128bit UUID in the first place https://github.com/bjornspockeli/custom_ble_service_example . I'm using nRF5 SDK V15.0.0.

My defined custom UUID base is:

// EE84xxxx-43B7-4F65-9FB9-D7B92D683E36
#define DCS_BASE_UUID {{0x36, 0x3E, 0x68, 0x2D, 0xB9, 0xD7, 0xB9, 0x9F, 0x65, 0x4F, 0xB7, 0x43, 0x00, 0x00, 0x84, 0xEE}}

static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_DCS_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN}};

but this is what is showing up in the advertisement packet:

82c90100-f315-4f60-9fb8-838830daea50

Any help as to where to start to debug would be much appreciated!

-Kent

Parents Reply
  •  and Thank you both for your responses! mrono, it does seem that you were correct in your suspicion. I am in fact using the dfu service and was initializing it before my own custom services. I tested moving the dfu service init to after my service inits and now the correct UUID base is being advertised. I also agree with you very strongly that this is not a suitable solution, and nowhere have I ever seen mention of the importance in the order of service inits in regards to advertising. Would you be willing to expand more on how I could get the correct value at runtime in advertising_init() please!

    -Kent

Children
  • Would you be willing to expand more on how I could get the correct value at runtime in advertising_init() please!

    Try something like this in advertising_init():

        static ble_uuid_t adv_uuid;
        adv_uuid.uuid = BLE_UUID_DCS_SERVICE;
        adv_uuid.type = m_cus.uuid_type;
    
        // ....
        
        init.advdata.uuids_complete.uuid_cnt = 1;
        init.advdata.uuids_complete.p_uuids  = &adv_uuid;
    

    Once you have initialized the custom service then m_cus.uuid_type holds the correct index to that service's base UUID.

Related