Hi all
I'm using the GATT server on the nRF51822 with the SoftDevice S130 V2.0.1. I've implemented a service and a characteristic which supports only write requests (including reliable write) and requires authorization. I tried to implement the handling according to this MSC to write e.g. 48 bytes to my characteristic.
When I receive the event BLE_EVT_USER_MEM_REQUEST, I deliver a buffer with 256 bytes to the SoftDevice using the function sd_ble_user_mem_reply(). Afterwards I receive the event BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, but when I call the function sd_ble_gatts_rw_authorize_reply() I receive the NRF_ERROR_INVALID_PARAM error.
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
if (pAuth_request->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
{
if (pAuth_request->request.write.handle == gService.char_handle.value_handle)
{
reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
reply.params.write.update = 1;
reply.params.write.len = pAuth_request->request.write.len;
reply.params.write.offset = pAuth_request->request.write.offset;
reply.params.write.p_data = pAuth_request->request.write.data;
sd_stat = sd_ble_gatts_rw_authorize_reply(gConn_handle, &reply);
if (sd_stat != NRF_SUCCESS) {goto exception;}
}
I've initialized the characteristic the following way:
char_md.char_props.auth_signed_wr = 0;
char_md.char_props.broadcast = 0;
char_md.char_props.indicate = 0;
char_md.char_props.notify = 0;
char_md.char_props.read = 0;
char_md.char_props.write = 1;
char_md.char_props.write_wo_resp = 0;
char_md.char_ext_props.reliable_wr = 1;
char_md.char_ext_props.wr_aux = 0;
char_md.char_user_desc_max_size = 0;
char_md.char_user_desc_size = 0;
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 = NULL;
char_md.p_sccd_md = NULL;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
attr_md.rd_auth = 0;
attr_md.wr_auth = 1;
attr_md.vlen = 1;
attr_md.vloc = BLE_GATTS_VLOC_STACK;
BLE_UUID_BLE_ASSIGN(uuid, 0xABCD);
attr_char_value.p_uuid = &uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_offs = 0;
attr_char_value.init_len = 0;
attr_char_value.max_len = 256;
attr_char_value.p_value = NULL;
sd_stat = sd_ble_gatts_characteristic_add(
pSrv->service_handle,
&char_md,
&attr_char_value,
&pSrv->char_handle);
if (sd_stat != NRF_SUCCESS) {goto exception;}
Does anyone have an idea what I am doing wrong? Why do I receive the status NRF_ERROR_INVALID_PARAM? Many thanks in advance.
Kind regards