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......


Parents Reply Children
  • 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