onReadRequest
A callback called when the client sends Read request to a characteristic.
This method should return the value to be sent to the client. The value will be truncated to 512 bytes, which is the maximum length of a GATT attribute value.
The returned response will be delayed by one or more connection interval to emulate the time needed to send the response back to the client.
Note, that this callback is invoked for both Read Characteristic Value procedure and Read Long Characteristic Value procedure. Instead of returning each blob separately, the implementation should return the full value.
See Bluetooth Code Specification 6.2, Vol 3 (Host), Part G (GATT), 4.8.1 Read 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 ReadResponse.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.