This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Handling failed status on BLE_GATTS_OP_EXEC_WRITE_REQ_NOW

Hello,

I have an authorized write long characteristic which I'm writing using nRF Connect. My peripheral app gets the expected sequence of events: 1) BLE_EVT_USER_MEM_REQUEST to which I provide a memory buffer; 2) a number of BLE_GATTS_OP_PREP_WRITE_REQ; 3) a final BLE_GATTS_OP_EXEC_WRITE_REQ_NOW; followed by 4) BLE_EVT_USER_MEM_RELEASE.

This all works as expected when I have a successful write. But in situations where the incoming data is invalid, if I set the status to indicate an error, my call to sd_ble_gatts_rw_authorize_reply() doesn't result in the central (nRF Connect) detecting/indicating any failure. I call sd_ble_gatts_rw_authorize_reply() with a failed status value both on the BLE_GATTS_OP_PREP_WRITE_REQ (where I first detect it) and also on the final BLE_GATTS_OP_EXEC_WRITE_REQ_NOW.

I've looked at the on_execute_write() in the nrf_ble_qwr.c example, and it looks like I'm using sd_ble_gatts_rw_authorize_reply() similar to how it does at the end of the sequence--the final execute call.

Is there something else/different that needs to be done to indicate a failed sequence of prepared writes (either mid-stream during one of the prepared writes or at the end when the execute occurs)?

Related