Hi,
after porting an existing application from version 3.0 of the s132 SD to version 5.0, I experience, that sd_ble_gatts_rw_authorize_reply()
returns NRF_ERROR_INVALID_PARAM
, when I try to reply with an ATT Error Response to an ATT Write Request.
For all cases, where the reponse to a write request is simply BLE_GATT_STATUS_SUCCESS, sd_ble_gatts_rw_authorize_reply()
does not return an error. But when I want the BLE stack to respond with an ATT Error Response, sd_ble_gatts_rw_authorize_reply()
returns with NRF_ERROR_INVALID_PARAM (0x07).
Here are the aguments, I pass to sd_ble_gatts_rw_authorize_reply():
(gdb) p/x response
$2 = {type = 0x2, params = {read = {gatt_status = 0x107, update = 0x0, offset = 0x0, len = 0x0, p_data = 0x0}, write = {gatt_status = 0x107, update = 0x0,
offset = 0x0, len = 0x0, p_data = 0x0}}}
(gdb) p/x conn_handle
$3 = 0x0
And this is the event, to which the reponse belongs:
(gdb) p/x evt
$1 = (const ble_gatts_evt_rw_authorize_request_t &) @0x200050d2: {type = 0x2, request = {read = {handle = 0x10, uuid = {uuid = 0x5f4d, type = 0x2},
offset = 0x1}, write = {handle = 0x10, uuid = {uuid = 0x5f4d, type = 0x2}, op = 0x1, auth_required = 0x0, offset = 0x0, len = 0x9, data = {0x8}}}}
According to the documentation of the return value NRF_ERROR_INVALID_PARAM
: "Authorization op invalid, handle supplied does not match requested handle, or invalid data to be written provided by the application."
I think with "Authorization op", ble_gatts_evt_rw_authorize_request_t::type
is ment. Which im my case is 0x02, which is BLE_GATTS_AUTHORIZE_TYPE_WRITE
.
"handle supplied does not match requested handle": Dunno what this means. Maybe the connection handle, but as this problem only occurs, when the gatt_status
is not equal to BLE_GATT_STATUS_SUCCESS
, the connection handle seems to be ok.
"invalid data to be written provided": Well, when I look at othere examples in the SDK, that call sd_ble_gatts_rw_authorize_reply()
, none of them set more than the gatt_status
and the type
field.
What am I'm doing wrong here?
Kind regards,
Torsten