esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
plaintext_frame_helper.hpp
Go to the documentation of this file.
1#pragma once
2
5
8
9#include <cstddef>
10#include <cstdint>
11
12namespace esphome::api {
13
19class PlaintextFrameHelper final : public FrameHelper {
20public:
22 static constexpr std::uint8_t indicator = 0x00;
23
24 void encode(std::uint32_t msg_type, ByteView payload, ByteBuffer& out) override;
25 void feed(ByteView data) override;
26 FrameStatus next(std::uint32_t& out_type, ByteView& out_payload) override;
27
28private:
30 void compact();
31
32 ByteBuffer buffer_;
33 std::size_t consumed_ = 0;
34};
35
36} // namespace esphome::api
Byte buffer / view aliases and protobuf base-128 varint codec.
Non-owning view over a contiguous run of bytes (a C++17 stand-in for std::span<const std::uint8_t>).
Definition bytes.hpp:17
Stateful codec sitting between the transport and the connection.
Definition frame_helper.hpp:30
Codec for the plaintext native-API framing:
Definition plaintext_frame_helper.hpp:19
FrameStatus next(std::uint32_t &out_type, ByteView &out_payload) override
Try to extract the next complete frame.
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.
static constexpr std::uint8_t indicator
Indicator byte that prefixes every plaintext frame.
Definition plaintext_frame_helper.hpp:22
Abstract frame codec: turns a byte stream into ESPHome message frames and back, independent of the un...
Definition bytes.hpp:10
FrameStatus
Result of attempting to pull a frame from the reassembly buffer.
Definition frame_helper.hpp:17
std::vector< std::uint8_t > ByteBuffer
Owning, growable byte buffer.
Definition bytes.hpp:13