BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
bluetoe::free_read_blob_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_blob_handler< F >:

Detailed Description

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

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.

Template Parameters
Fpointer to function to handle a read request
Parameters
offsetoffset 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_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_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: