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

User Description Descriptor Example

Hi guys,

Is there a recent example that shows how to add user description descriptors to characteristics on S132 V5.1 ? I have tried the various methods I could find in the Q&A, but have not had any luck. 

Thanks! 

Parents
  • To add a little bit more detail, I tried manually adding the description descriptor by editing the characteristic metadata as per below:

     memset(user_desc, 0, 10);
     strcpy(user_desc, "Test");
     char_md.p_char_user_desc = (uint8_t *) user_desc;
     char_md.char_user_desc_size = 4;//strlen(user_desc);
     char_md.char_user_desc_max_size = 4;//strlen(user_desc);

    and when that didn't work, I tried doing it through the sd_ble_gatts_descriptor_add() function

    In both cases, I tried doing it with the first characteristic in my service, and in both cases, the second characteristic was broken by the code. The second characteristic is a 20 byte read and notify with cccd characteristic. When I periodically update the characteristic from a timer in the firmware, the messages show up correctly at the central device. As soon as I try to add the description descriptor to the first characteristic, the second characteristic is broken and the messages no longer show up correctly at the central device. 

    I can post a full code listing it that would help, but it would be great if there is a known good example somewhere that I can have a look at.

  • Hello,

    Sorry for the late reply. May I ask what you intend to do? Are you trying to create a characteristic with notification?

    Sorry that this is not a thorough answer. We are a bit short staffed these days. 

    But yes. Are you sure that it is the descriptor you want to change, and not the cccd?

    Best regards,

    Edvin

  • Hi Edvin,

    I am wanting to add a 'User description descriptor' to an existing characteristic. The idea is that if you connect to the device with a generic app like LightBlue or your nRF Connect app, the app can display human readable text names for the characteristics. Searching through the Q&A, it looks like there are 2 way to do this, as described above, but neither way seems to work ?

    Appreciate your input ! Thanks

  • What does your sd_ble_gatts_descriptor_add() return?

    Does it return something other than 0 (NRF_SUCCESS)? Or is the issue that you don't see the name "test" on your central device?

     

    BR,

    Edvin

  • sd_ble_gatts_descriptor_add() returns NRF_SUCCESS, but after that I still don't see the name that I specified in the app. More importantly, when I do that on my first characteristic, it somehow damages the second characteristic, which should be reporting consistent data with a notify to the central device. As soon as I try either method to add the user description descriptor to the first characteristic, the second characteristic does not report the correct data anymore. 

    Could you possibly grab any of your examples and try to add a user description descriptor?

  • Hello,

    I added a description to the heart_rate_measurement characteristic in the ble_app_hrs example from SDK14..2.0.

    It will not help to upload the project file, since the ble_hrs.c file is outside the project folder. I would have to upload the entire SDK for that. But all you need to change in order to add the characteristic user description is inside the heart_rate_measurement_char_add() function in the ble_hrs.c file.

    Try an unmodified version of this project, and apply the changes between the lines:

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

    and

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_MEASUREMENT_CHAR);

     

    It should look like this:

    static_uint32_t heart_rate_measurement_char_add(...)
        [...]
        
        memset(&char_md, 0, sizeof(char_md));
    
        // Char_user_desc added. Change from here
        char_md.char_props.notify = 1;
        //char_md.p_char_user_desc  = NULL;
        char_md.p_char_pf         = NULL;
        char_md.p_user_desc_md    = NULL;
        char_md.p_cccd_md         = &cccd_md;
        char_md.p_sccd_md         = NULL;
        
        static char user_desc[] = "name";           // in nRF Connect this will show as "6E 61 6D 65"
        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_user_desc added. Change to here
    
        BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_MEASUREMENT_CHAR);
        
        [...]
    }

     

    Compile and flash the project. If you connect to it with nRF Connect for Desktop, it should look like this:

     

    Best regards,

    Edvin

Reply
  • Hello,

    I added a description to the heart_rate_measurement characteristic in the ble_app_hrs example from SDK14..2.0.

    It will not help to upload the project file, since the ble_hrs.c file is outside the project folder. I would have to upload the entire SDK for that. But all you need to change in order to add the characteristic user description is inside the heart_rate_measurement_char_add() function in the ble_hrs.c file.

    Try an unmodified version of this project, and apply the changes between the lines:

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

    and

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_MEASUREMENT_CHAR);

     

    It should look like this:

    static_uint32_t heart_rate_measurement_char_add(...)
        [...]
        
        memset(&char_md, 0, sizeof(char_md));
    
        // Char_user_desc added. Change from here
        char_md.char_props.notify = 1;
        //char_md.p_char_user_desc  = NULL;
        char_md.p_char_pf         = NULL;
        char_md.p_user_desc_md    = NULL;
        char_md.p_cccd_md         = &cccd_md;
        char_md.p_sccd_md         = NULL;
        
        static char user_desc[] = "name";           // in nRF Connect this will show as "6E 61 6D 65"
        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_user_desc added. Change to here
    
        BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_MEASUREMENT_CHAR);
        
        [...]
    }

     

    Compile and flash the project. If you connect to it with nRF Connect for Desktop, it should look like this:

     

    Best regards,

    Edvin

Children
No Data
Related