onWriteRequest
A callback called when the client sends a Write Request (write with response) to a characteristic.
The maximum length of the value is guaranteed to be at most PeripheralSpec.mtu- 3 byte. 1 byte is consumed by the OpCode and 2 by the handle number.
For Long Write procedure and Reliable Write procedure, see onPrepareWriteRequest, which replies back the written value.
The response returned by this method will be delayed by one connection interval to emulate the time needed to send the response back to the client.
Read more in Bluetooth Code Specification 6.2, Vol 3 (Host), Part G (GATT), 4.9.3 Write Characteristic Value: link.
Exceptions
Exceptions thrown by this method are rethrown immediately, without the simulated transfer time, emulating a failure on the client side (e.g. OperationFailedException, or SecurityException).
Simulated error on the peripheral side should be reported by returning WriteResponse.Failure, which is delayed by one connection interval to emulate the time needed to send the error response.
Any exception other than OperationFailedException will be wrapped into BluetoothException.
Return
The response of the write operation. This emulates a response received from the peripheral and it will be delayed to the client by one connection interval.
Parameters
The characteristic to write to.
The value written to the characteristic.
See also
Throws
in case of a client error (reported without a delay).