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
The handler can be used to handle blobs. 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. If the characteristic value will always be smaller than 21 octets, using a bluetoe::free_read_handler will save you from coping with an offset.
F | pointer to function to handle a read request |
offset | offset in octets into the characteristic beeing read. If the offset is larger than the characteristic, the handler should return bluetoe::error_codes::invalid_offset |
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. |