Hello,
I have created a service with three characteristics in which the 1st and 3rd characteristics have all the three Notify, read, write properties. The second characteristic has only read and write properties. So in the creation of these characteristics under a service i did not face any problems and i could see them on the nRF connect app when i run the code. The problem came when i tried to add the descriptors to these characteristics. The 1st and 3rd characteristics advertise a Client Characteristic Configuration Descriptor (CCCD) even if i dont write them. But when i try to add them in the code and also a Client User Descriptor (CUD) in the code there are no errors at compilation but when i run the code the program breaks at a breakpoint named as NRF_BREAKPOINT_COND.
uint32_t ble_dts_init(ble_dts_t * p_dts, const ble_dts_init_t * p_dts_init) { uint32_t err_code; ble_uuid_t ble_uuid; ble_add_char_params_t add_char1_params; ble_add_char_params_t add_char2_params; ble_add_char_params_t add_char3_params; ble_add_descr_params_t add_descr1_params; //ble_add_descr_params_t add_descr2_params; //ble_add_descr_params_t add_descr3_params; // Initialize service structure. p_dts->spectrum_write_handler = p_dts_init->spectrum_write_handler; // Add service. ble_uuid128_t base_uuid = {BLE_DTS_UUID_BASE}; err_code = sd_ble_uuid_vs_add(&base_uuid, &p_dts->uuid_type); VERIFY_SUCCESS(err_code); ble_uuid.type = p_dts->uuid_type; ble_uuid.uuid = BLE_DTS_UUID_SERVICE; err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_dts->service_handle); VERIFY_SUCCESS(err_code); //Add 1st Characteristic memset(&add_char1_params, 0, sizeof(add_char1_params)); add_char1_params.uuid = DTS_UUID_SPECTRUM_CHAR; add_char1_params.uuid_type = p_dts->uuid_type; add_char1_params.init_len = sizeof(uint8_t); add_char1_params.max_len = 20; add_char1_params.char_props.read = 1; add_char1_params.char_props.notify = 1; add_char1_params.char_props.write = 1; add_char1_params.read_access = SEC_OPEN; add_char1_params.cccd_write_access = SEC_OPEN; err_code = characteristic_add(p_dts->service_handle,&add_char1_params,&(p_dts->spectrum_handles)); if(err_code != NRF_SUCCESS) { return err_code; } //Add Client Characteristic Configuration Descriptor for Spectrum characteristic memset(&add_descr1_params, 0, sizeof(add_descr1_params)); add_descr1_params.uuid = BLE_UUID_CCC_DESCR; add_descr1_params.uuid_type = add_char1_params.uuid_type; add_descr1_params.init_len = sizeof(uint8_t); add_descr1_params.max_len = sizeof(uint8_t); add_descr1_params.read_access = SEC_OPEN; add_descr1_params.write_access = SEC_NO_ACCESS; err_code = descriptor_add(p_dts->spectrum_handles.value_handle, &add_descr1_params, &p_dts->spectrum_handles.cccd_handle); VERIFY_SUCCESS(err_code); // Add Characteristic User Descriptor for Spectrum characteristic memset(&add_descr1_params, 0, sizeof(add_descr1_params)); add_descr1_params.uuid = BLE_UUID_DESCRIPTOR_CHAR_USER_DESC; add_descr1_params.uuid_type = add_char1_params.uuid_type; add_descr1_params.init_len = sizeof(uint8_t); add_descr1_params.max_len = sizeof(uint8_t); add_descr1_params.read_access = SEC_OPEN; add_descr1_params.write_access = SEC_OPEN; err_code = descriptor_add(p_dts->spectrum_handles.value_handle, &add_descr1_params, &(p_dts)->spectrum_handles.user_desc_handle); if(err_code != NRF_SUCCESS) { return err_code; }I have attached the service init function that i have written that has the complete 1st characteristic with its 2 descriptors. here the uuid for CCCD is 0x2092 and uuid for CUD is 0x2901.
I am new to the BLE part and i have only tried some basic examples with the nRF52832 DK.I have also uploaded the image that shows the error i get when i run the code.
static void services_init(void) { ret_code_t err_code; ble_dts_init_t dts_init = {0}; ble_dis_init_t dis_init; nrf_ble_qwr_init_t qwr_init = {0}; ble_dis_sys_id_t sys_id; ble_dis_reg_cert_data_list_t reg_cert_data_list; ble_dis_pnp_id_t pnp_id; // Initialize Queued Write Module. qwr_init.error_handler = nrf_qwr_error_handler; err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init); APP_ERROR_CHECK(err_code); // Initialize Device Information Service. memset(&dis_init, 0, sizeof(dis_init)); sys_id.manufacturer_id = 0x000000000030241D; sys_id.organizationally_unique_id = 0x00341513; dis_init.p_sys_id = &sys_id; uint8_t temp_list [] = {0xFE, 0x00, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6D, 0x65, 0x6E, 0x74, 0x61, 0x6C}; reg_cert_data_list.list_len = 14; reg_cert_data_list.p_list = temp_list; dis_init.p_reg_cert_data_list = ®_cert_data_list; ble_srv_ascii_to_utf8(&dis_init.model_num_str, (char *)MODEL_NUMBER); ble_srv_ascii_to_utf8(&dis_init.serial_num_str, (char *)SERIAL_NUMBER); ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char *)FW_REVISION); ble_srv_ascii_to_utf8(&dis_init.hw_rev_str, (char *)HW_REVISION); ble_srv_ascii_to_utf8(&dis_init.sw_rev_str, (char *)SW_REVISION); ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME); dis_init.dis_char_rd_sec = SEC_OPEN; pnp_id.vendor_id_source = BLE_DIS_VENDOR_ID_SRC_BLUETOOTH_SIG; pnp_id.vendor_id = 0x0059; pnp_id.product_id = 0; pnp_id.product_version = 272; dis_init.p_pnp_id = &pnp_id; err_code = ble_dis_init(&dis_init); APP_ERROR_CHECK(err_code); // Initialize DTS. dts_init.spectrum_write_handler = spectrum_write_handler; err_code = ble_dts_init(&m_dts, &dts_init); APP_ERROR_CHECK(err_code); }The lase piece of code shows my services_init function.
Kindly help me with any solutions or examples so that i can continue with my work. This is the first time I am dealing with the descriptors and hence i am a total novice to this. I will be really gratefull for any help that is received.
Thanks in advance!!