Change BASE UUID of Custom Service

Hi,

I have developed a firmware in which I have added the custom service. My custom service UUID is showing 00001400-0000-0000-0000-00000000fff0 but I want only 0xFFF0. I have tried to change it but it's not working. how can I do that? Thanks!

UUID showing.....

UUID Desire......


  • Hello Muqarrab,

    Thanks for your question.

    The base UUID should be 16 bytes; not 2. You can look at this point of view when defining Base UUID.

    For example:

    Best Regards,

    Kazi Afroza Sultana

  • Thanks for the answer.

    As other services have 2 byte UUID. Can I change it to 2 bytes?

  • Hello Muqarrab,

    It Seems like you want to show only 0XFFF0. The 16 bit UUIDs are the Bluetooth SIG registered UUIDs. Then you need to register with Bluetooth SIG to get a 16-bit UUID. It costs a few thousand dollar. How do I choose a UUID for my custom services and characteristics? - Novel Bits here in this link, I can see 2500 dollar.

    However, you can set this 16 bit UUID in the code as well. You can see the code here (components\ble\ble_services\ble_dfu\ble_dfu.c)

    #define BLE_DFU_SERVICE_UUID            0xFE59                      /**< The 16-bit UUID of the Secure DFU Service. */

    BLE_UUID_BLE_ASSIGN(service_uuid, BLE_DFU_SERVICE_UUID);
       // Add the DFU service declaration.
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                            &service_uuid,
                                            &(m_dfu.service_handle));

        VERIFY_SUCCESS(err_code);

     You can try this and let us know how it works.

    Thanks.

    Best Regards,

    Kazi Afroza Sultana

  • Hello, this is 3 months late but I had a similar question and stumbled across this thread thanks to Kazi Afroza Sultana. Use the BLE_UUID_BLE_ASSIGN method to accomplish this. Here is an example code that utilizes this method:

    uint32_t ble_cus_init(ble_cus_t * p_cus, const ble_cus_init_t * p_cus_init)
    {
        uint32_t   err_code;
        ble_uuid_t ble_uuid;
    
        // Initialize service structure
        p_cus->evt_handler               = p_cus_init->evt_handler;
        p_cus->conn_handle               = BLE_CONN_HANDLE_INVALID;
    
        // Add Custom Service UUID
        ble_uuid128_t base_uuid = {CUSTOM_SERVICE_UUID_BASE};
        
            err_code =  sd_ble_uuid_vs_add(&base_uuid, &p_cus->uuid_type);
        VERIFY_SUCCESS(err_code);
        
        ble_uuid.type = p_cus->uuid_type;
        ble_uuid.uuid = CUSTOM_SERVICE_UUID;
    
        BLE_UUID_BLE_ASSIGN(ble_uuid, CUSTOM_SERVICE_UUID);
        
            // Add the Custom Service
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_cus->service_handle);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        
        
        // Add Custom Value characteristic to new service
        return custom_value_char_add(p_cus, p_cus_init);

    The method in the above code should result in your desired outcome! Note that you will have to set your base uuid and characteristic uuids yourself.

    Finally, you can set the characteristic UUIDs in a similar way. Just use the BLE_UUID_BLE_ASSIGN in the same way before the sd_ble_gatts_characteristic_add method.

Related