|
esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
|
Byte-stream transport: async connect, a continuous read pump and a serialized write queue. More...
#include <transport.hpp>
Public Types | |
| using | ConnectHandler = std::function< void(std::error_code)> |
| using | ReadHandler = std::function< void(std::error_code, ByteView)> |
| using | WriteHandler = std::function< void(std::error_code)> |
Public Member Functions | |
| virtual | ~Transport ()=default |
| virtual void | async_connect (const std::string &host, std::uint16_t port, ConnectHandler handler)=0 |
Resolve and connect to host:port; handler fires once. | |
| virtual void | start_read (ReadHandler on_read)=0 |
| Start the continuous read pump. | |
| virtual void | async_write (ByteBuffer data, WriteHandler handler)=0 |
Queue data for transmission (FIFO). handler fires on completion. | |
| virtual void | close ()=0 |
| Close the transport. | |
| virtual bool | is_open () const =0 |
| Whether the transport is currently open. | |
Byte-stream transport: async connect, a continuous read pump and a serialized write queue.
Implementations must invoke every callback on the connection's executor (single-threaded from the connection's perspective).
| using esphome::api::Transport::ConnectHandler = std::function<void(std::error_code)> |
| using esphome::api::Transport::ReadHandler = std::function<void(std::error_code, ByteView)> |
| using esphome::api::Transport::WriteHandler = std::function<void(std::error_code)> |
|
virtualdefault |
|
pure virtual |
Resolve and connect to host:port; handler fires once.
|
pure virtual |
Queue data for transmission (FIFO). handler fires on completion.
|
pure virtual |
Close the transport.
|
pure virtual |
Whether the transport is currently open.
|
pure virtual |
Start the continuous read pump.
on_read is called for each received chunk, or once with a non-zero error_code on failure/EOF.