BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
bluetoe::free_read_handler< F > Struct Template Reference

binds a free function as a read handler for the given characteristic More...

#include <bluetoe/characteristic_value.hpp>

Inheritance diagram for bluetoe::free_read_handler< F >:

Detailed Description

template<std::uint8_t(*)(std::size_t read_size, std::uint8_t *out_buffer, std::size_t &out_size) F>
struct bluetoe::free_read_handler< F >

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.

Template Parameters
Fpointer to function to handle a read request
Parameters
read_sizethe 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_bufferOutput buffer to copy the data, that is read.
out_sizeThe actual number of octets copied to out_buffer. out_size must be smaller or equal to read_size.
Return values
Ifthe 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.
See also
characteristic
free_read_blob_handler
free_write_blob_handler
free_raw_write_handler
bluetoe::error_codes::error_codes
Examples
read_write_handler_example.cpp.

The documentation for this struct was generated from the following file: