|
esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
|
Codec for the plaintext native-API framing: More...
#include <plaintext_frame_helper.hpp>


Public Member Functions | |
| void | encode (std::uint32_t msg_type, ByteView payload, ByteBuffer &out) override |
Serialize a message (numeric type id + protobuf payload) to wire bytes, appending them to out. | |
| void | feed (ByteView data) override |
| Append freshly received bytes to the internal reassembly buffer. | |
| FrameStatus | next (std::uint32_t &out_type, ByteView &out_payload) override |
| Try to extract the next complete frame. | |
Public Member Functions inherited from esphome::api::FrameHelper | |
| FrameHelper ()=default | |
| virtual | ~FrameHelper ()=default |
| FrameHelper (const FrameHelper &)=delete | |
| FrameHelper & | operator= (const FrameHelper &)=delete |
| FrameHelper (FrameHelper &&)=delete | |
| FrameHelper & | operator= (FrameHelper &&)=delete |
| virtual bool | needs_handshake () const |
| True if the transport requires a handshake before application messages (and before the connection should send HelloRequest). | |
| virtual ByteBuffer | connect_bytes () |
| Bytes to transmit immediately after the TCP connection is established (the client's first handshake flight). | |
| virtual void | set_handshake_handlers (HandshakeReady, HandshakeError) |
| Register callbacks fired when the handshake completes or fails. | |
Static Public Attributes | |
| static constexpr std::uint8_t | indicator = 0x00 |
| Indicator byte that prefixes every plaintext frame. | |
Additional Inherited Members | |
Public Types inherited from esphome::api::FrameHelper | |
| using | HandshakeReady = std::function< void()> |
| using | HandshakeError = std::function< void(const std::string &what)> |
Codec for the plaintext native-API framing:
[0x00][varint payload_length][varint msg_type][protobuf payload]
The leading 0x00 indicator distinguishes plaintext from Noise (0x01).
|
overridevirtual |
Serialize a message (numeric type id + protobuf payload) to wire bytes, appending them to out.
Implements esphome::api::FrameHelper.
|
overridevirtual |
Append freshly received bytes to the internal reassembly buffer.
Implements esphome::api::FrameHelper.
|
overridevirtual |
Try to extract the next complete frame.
On FrameStatus::Ok, out_type is the message type id and out_payload is a view of the protobuf payload that stays valid only until the next call to feed or next. On NeedMore nothing was consumed.
Throws ProtocolError on a malformed or oversized frame.
Implements esphome::api::FrameHelper.
|
staticconstexpr |
Indicator byte that prefixes every plaintext frame.