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

Adding a descriptor incorrectly (it makes my device unconnectable)

Hello, I am creating a peripheral with a totally custom set of services and characteristics (it will only talk to our custom central device).  I've adapted the examples and been able to add a service, add a few custom characteristics, and advertise them and connect to it and see the characteristics from an app like "BLE Hero".

So far so good.  What I thought might be nice next is to add some helpful descriptive text so that the characteristics present something a little more friendly than UUIDs.  I assume that this is one function of Descriptors?  (Even if not, I took this as an opportunity to learn about descriptors).  I tried to add the code below (I know this doesnt add a text description, I was just trying to pattern it after an example descirptor add I found) to add a descriptor to a characteristic (right after adding the characteristic) and even though no errors seem to occur, it appears to break my device and my centrals dont connect to it successfully.  So there's probably a pretty gross error in there, can someone please help me see it?

Thanks!

//////////////////////////////////////////
// attempt to add descriptor
//////////////////////////////////////////
            
uint16_t char_handle = p_our_service->characteristic1_handles.value_handle;
            
ble_add_descr_params_t descrip_params;
uint8_t encoded_report_ref[BLE_SRV_ENCODED_REPORT_REF_LEN];
            
ble_srv_report_ref_t report_ref;
report_ref.report_id = 3;
report_ref.report_type = 7;
           

// Add Report Reference descriptor
uint8_t init_len = ble_srv_report_ref_encode(encoded_report_ref, &report_ref);

memset(&descrip_params, 0, sizeof(descrip_params));
descrip_params.uuid        = BLE_UUID_REPORT_REF_DESCR;
descrip_params.read_access = SEC_OPEN;
descrip_params.init_len    = init_len;
descrip_params.max_len     = 50;
descrip_params.p_value     = encoded_report_ref;            
            
uint16_t descrip_handle = 0;
err_code = descriptor_add(char_handle,&descrip_params, &descrip_handle);
if (err_code != NRF_SUCCESS) { RETURN_FAULT(10,err_code) }

Parents Reply Children
No Data
Related