BlueToe
an alternative GATT/BLE implementation
|
binds a free function as a read handler for the given characteristic More...
#include <bluetoe/characteristic_value.hpp>
binds a free function as a read handler for the given characteristic
This handler is functional similar to free_read_blob_handler, but can not be used for handling requests to large characteristics. To be on the safe side, this type of handler should not be used for characteristic values larger than 20 octets. The handler can be used with a bluetoe::no_read_access parameter in conjunction with bluetoe::indicate or bluetoe::notify to provide the data to a notification or indication without the charactertic beeing able to be read. If only a read handler is passed to the bluetoe::characteristic, the characteristic will be read only.
F | pointer to function to handle a read request |
read_size | the maximum size, a client is able to read from the characteristic. This is the maximum, that can be copied to the out_buffer, without overflowing it. Reading just a part of the characteristic (because of the limited out_buffer size) is fine and not an error. |
out_buffer | Output buffer to copy the data, that is read. |
out_size | The actual number of octets copied to out_buffer. out_size must be smaller or equal to read_size. |
If | the characteristic value could be read successfully (even when the out_buffer was to small, to read the whole value), the function should return luetoe::error_codes::success. In all other cases, Bluetoe will generate an error response to a read request and directly use the return value as error code. For usefull error codes, have a look at bluetoe::error_codes::error_codes. |