I've added a custom service for transferring data. It shall contain one characteristic that will notify when data is available, and the other should be a long read characteristic (no notify). sd_ble_gatts_characteristic_add
is failing (return 0x7) when I add the second characteristic.
I've made attr_char_value.max_len
to 512. I am enabling attr_md.rd_auth = 1 to handle the long read as mentioned in the post devzone.nordicsemi.com/.../
Is this the right way, or are there any new preferred way to enable long read ?
Could someone please point out what is the invalid parameter ? I'm using sdk 14.1 with GCC compiler. The code is below:
static uint32_t sensor_data_char_add(ble_ksh_t * p_ksh, ble_ksh_init_t const * p_pke_init) {
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
extern uint8_t sensor_data_buffer[BLE_KSH_MAX_DATA_CHAR_LEN];
memset(&cccd_md, 0, sizeof(cccd_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.read = 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;
ble_uuid.type = p_ksh->uuid_type;
ble_uuid.uuid = BLE_UUID_KSH_DATA_CHARACTERISTIC;
memset(&attr_md, 0, sizeof(attr_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.rd_auth = 1;
attr_md.wr_auth = 0;
attr_md.vlen = 1;
memset(&attr_char_value, 0, sizeof(attr_char_value));
attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = sizeof(uint8_t);
attr_char_value.init_offs = 0;
attr_char_value.max_len = BLE_GATTS_VAR_ATTR_LEN_MAX;
attr_char_value.p_value = &sensor_data_buffer[0];
return sd_ble_gatts_characteristic_add(p_ksh->service_handle,
&char_md,
&attr_char_value,
&p_ksh->data_handles);
}