I'm handling the entire prepared write sequence myself, returning NULL for the memory request and dealing with the Prepare Write and Exec Write etc.
I found that if I send back an error during a Prepare Write (in this case I'm sending the Insufficient Resources error) that gets sent to the client correctly and the client then sends a Execute Write Request with the 'Cancel All' flags set. I can see this on the sniffer.
However I don't receive the BLT_GATTS_OP_EXEC_WRITE_REQ_CANCEL rw_auth event. Firstly I'm logging all events and secondly I have a breakpoint right on the line and it's not hit.
switch( write_request->op )
{
case BLE_GATTS_OP_WRITE_REQ:
case BLE_GATTS_OP_WRITE_CMD:
case BLE_GATTS_OP_SIGN_WRITE_CMD:
// send an internal write event for all these
status = rdk_ble_events_send_internal_write( write_request );
if( status == RDK_BLE_EVENTS_NOT_HANDLED )
status = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;
break;
case BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL:
// cancel the queue and return success
rdk_ble_events_clear_prepared_write_info(); // <-- breakpoint not hit
status = BLE_GATT_STATUS_SUCCESS;
break;
case BLE_GATTS_OP_PREP_WRITE_REQ:
status = rdk_ble_events_handle_prepare_write( write_request );
break;
I was expecting the sequence would finish with either a Commit or a Cancel and expected to do some cleanup in the cancel handler.
Is this expected? The only reason I can think of for not receiving the event is that I've returned an error for one of the prepared writes, the stack at that point internally marks this prepared write as errored and complete and when the Cancel All comes in from the client, it thinks there's no prepared write going on, so it doesn't send me the event.
I can work around it by cleaning up at the time I send the error, but I'd like to know if I should be getting the cancel event or not.