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

Definition of a different UUID for a characteristic

Hi,

I want my characteristic to have a different UUID than its service on my server:


I followed the leads from the post below:

https://devzone.nordicsemi.com/f/nordic-q-a/15208/characteristic-s-base-uuid-different-from-service-s-base-uuid

Below is my function to add a characteristic to the service:

static uint32_t setting_zone_power_char_add(ble_cooktop_t * p_cooktop, const ble_cooktop_init_t * p_cooktop_init)
{
    
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_gatts_attr_md_t attr_md;


    ble_uuid_t uuidA = { .uuid = 0x6666 };
    ble_uuid128_t uuidA_base = { 0xAA, 0xAA, 0xAA, 0xAA, 
										0xAA, 0xAA, 0x99, 0x99, 
										0x88, 0x88, 0x77, 0x77, 
										0x00, 0x00, 0x66, 0x66 };
    sd_ble_uuid_vs_add(&uuidA_base, &uuidA.type);
    // uuidA is now 66666666-7777-8888-9999-AAAAAAAAAAAA

    memset(&char_md, 0, sizeof(char_md));

    static char user_desc[] = "setting_zone";
    char_md.p_char_user_desc  = (uint8_t *) user_desc;
    char_md.char_user_desc_size = strlen(user_desc);
    char_md.char_user_desc_max_size = strlen(user_desc);	

    char_md.char_props.write         = 1;
    char_md.char_props.read         = 1;
    char_md.char_props.notify         = 1;
    char_md.char_props.indicate         = 1;
    char_md.char_props.write_wo_resp = 1;
    char_md.p_char_user_desc         = NULL;
    char_md.p_char_pf                = NULL;
    char_md.p_cccd_md                = NULL;
    char_md.p_sccd_md                = NULL;

       uuidA.type = BLE_UUID_TYPE_VENDOR_BEGIN;

    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

    attr_md.vloc    = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 0;
    attr_md.vlen    = 1;

    memset(&attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid    = &uuidA;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = 1;
    attr_char_value.init_offs = 0;

    attr_char_value.max_len   = 0x03;

    //sd_ble_gatts_descriptor_add();
    return sd_ble_gatts_characteristic_add(p_cooktop->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_cooktop->setting_zone_power_handles);


}

The project compiles and I can connect to my server using nrfConnect but the UUID for the characteristic is not the one I defined but used the same base UUID as the service UUID.

Related