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

Updating Characteristic User Description in BDS generated code

Hi, I am trying to determine if there is an error in the generated code or if I am not performing the actions correctly. I am trying to Update Characteristic User Description value in Bluetooth Developer Studio generated code.

I am working on a nRF52840 dev kit with SDK v14.0 and my BDS has plugin v1.3.0 sdk14. In BDS I've created a custom service with a few custom characteristics. Each of those I've added the User Description descriptor 0x2901. I've copied the generated output to my experimental/bluetoothds_template project, made the necessary Your_job modifications, and flashed my device. In the Android app I am able to read/write my characteristic just fine and read the initial User Descriptor just fine.

When I try to update the User Descriptor, I never see change in the android app after reading. In file ble_XX_service.c setting the init value in ble_XX_service_init works just fine the lines

ble_add_char_user_desc_t XX_characteristic_user_description;
uint8_t XX_characteristic_user_description_val[]  = {'b', 'd', 's' };

In my main I call

ble_ipn_monitor_service_XX_t test;
test.XX_characteristic_user_description.user_description.p_str = ptr_to_my_new_string;
test.XX_characteristic_user_description.user_description.length = size_of_my_new_string; 
ble_ipn_monitor_service_XX_characteristic_user_description_set(&m_XX_service, &test.XX_characteristic_user_description);

But I never see the set update take effect. In ble_XX_service.h are

ble_gatts_char_handles_t XX_handles; /**< Handles related to the testchar characteristic. */
ble_gatts_char_handles_t XX_characteristic_user_description_handles; /**< Handles related to the Characteristic User Description descriptor. */

The generated setup init code uses XX_handles and the _set function uses XX_characteristic_user_description_handles but I cannot find where XX_characteristic_user_description_handles gets properly initialized. I think this is the Bug.

Anyone have experience with this?

  • Hi,

    How does your User Description Security requirement looks like? Have you enabled write_access ?

  • Hi Sigurd, The parameters for the CUD is request_XX_characteristic_user_description.read_access = SEC_OPEN; request_XX_characteristic_user_description.write_access = SEC_NO_ACCESS;

    However I am NOT trying to write from the Central(Phone). I'm trying to update the CUD from the Peripheral (ble device).

  • I actually got this to work by changing the generated handle used in the generated set function. The original generated ble_YY_XX_characteristic_user_description_set function calls the code return sd_ble_gatts_value_set(p_YY->conn_handle, p_YY->XX_characteristic_user_description_handles.value_handle, &gatts_value); but I never found where this handle was initialized by the generated code. I changed the code to return sd_ble_gatts_value_set(p_YY->conn_handle, p_YY->XX_handles.user_desc_handle, &gatts_value); because this is the handle that is used in the generated _init() function when setting up all the descriptors. I believe this is a bug in the BDS plugin when generating code for this function.

Related