|
esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
|
Encrypted frame codec. More...
#include <noise_frame_helper.hpp>


Public Member Functions | |
| NoiseFrameHelper (const NoiseConfig &config) | |
| Construct from config. | |
| 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. | |
| bool | needs_handshake () const override |
| True if the transport requires a handshake before application messages (and before the connection should send HelloRequest). | |
| ByteBuffer | connect_bytes () override |
| Bytes to transmit immediately after the TCP connection is established (the client's first handshake flight). | |
| void | set_handshake_handlers (HandshakeReady on_ready, HandshakeError on_error) override |
| Register callbacks fired when the handshake completes or fails. | |
| const std::string & | server_name () const noexcept |
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 |
Static Public Attributes | |
| static constexpr std::uint8_t | indicator = 0x01 |
| Indicator byte prefixing every Noise 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)> |
Encrypted frame codec.
Wire frames are [0x01][u16_be len][ciphertext]. It drives the NNpsk0 handshake internally (server-hello then server-handshake), then encrypts/decrypts application messages whose inner plaintext is [u16_be type][u16_be len][protobuf payload].
|
explicit |
Construct from config.
Throws ApiError if the PSK is not valid base64 of exactly 32 bytes.
|
overridevirtual |
Bytes to transmit immediately after the TCP connection is established (the client's first handshake flight).
Empty for plaintext.
Reimplemented from esphome::api::FrameHelper.
|
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.
|
inlineoverridevirtual |
True if the transport requires a handshake before application messages (and before the connection should send HelloRequest).
Reimplemented from 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.
|
inlinenoexcept |
|
overridevirtual |
Register callbacks fired when the handshake completes or fails.
next consumes handshake frames internally and invokes these.
Reimplemented from esphome::api::FrameHelper.
|
staticconstexpr |
Indicator byte prefixing every Noise frame.