Hi,
I'm trespassing some code of nRF51 to nRF52 (s132, SDK 12.2.0) and I get an error when I try to call sd_ble_gatts_rw_authorize_reply. This is the code
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
if ( p_ble_evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_READ )
{
ble_gatts_rw_authorize_reply_params_t auth_reply;
auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
uint16_t handleRead=p_ble_evt->evt.gatts_evt.params.authorize_request.request.read.handle;
auth_reply.params.read.gatt_status=BLE_GATT_STATUS_SUCCESS;
err_code=sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gatts_evt.conn_handle,&auth_reply);
APP_ERROR_CHECK(err_code);
}
else if(p_ble_evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
{
ble_gatts_rw_authorize_reply_params_t auth_reply;
auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
uint8_t handle=p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.handle;
ble_gatts_evt_write_t *p_evt_writex= &p_ble_evt->evt.gatts_evt.params.authorize_request.request.write;
uint8_t len=p_evt_writex->len;
uint16_t handlewrite=p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.handle;
if(handle==p_GLOBALCONFIG->global_confbyte_handles.value_handle)
{
if(len != 1)
{
auth_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH; }
else
{
auth_reply.params.write.gatt_status=BLE_GATT_STATUS_SUCCESS;
}
err_code=sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gatts_evt.conn_handle,&auth_reply);
APP_ERROR_CHECK(err_code);
}
}
break;
When I read, I don't get any error, but when I write, I get the error NRF_ERROR_INVALID_PARAM when I call "sd_ble_gatts_rw_authorize_reply" . I think the problem is the "BLE_GATT_STATUS_SUCCESS" status, but I don't know why. This is the correct way or there's any other way to write and read with authorization in s132?