esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions
wire.hpp File Reference

Self-contained proto3 wire-format primitives (varint / zigzag / fixed32 / fixed64 / length-delimited), with a writer and a reader. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
Include dependency graph for wire.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  esphome::api::ProtoWriter
 
class  esphome::api::ProtoReader
 

Namespaces

namespace  esphome
 
namespace  esphome::api
 

Enumerations

enum class  esphome::api::WireType : std::uint8_t { esphome::api::Varint = 0 , esphome::api::Fixed64 = 1 , esphome::api::LengthDelimited = 2 , esphome::api::Fixed32 = 5 }
 Protobuf wire types (the low 3 bits of a field tag). More...
 

Functions

std::uint32_t esphome::api::zigzag_encode32 (const std::int32_t v)
 
std::int32_t esphome::api::zigzag_decode32 (const std::uint32_t v)
 
std::uint64_t esphome::api::zigzag_encode64 (const std::int64_t v)
 
std::int64_t esphome::api::zigzag_decode64 (const std::uint64_t v)
 
std::size_t esphome::api::varint_size (std::uint64_t v)
 Number of bytes a value occupies as a base-128 varint.
 
std::size_t esphome::api::tag_size (const std::uint32_t field_number)
 Number of bytes the tag for field_number occupies (wire type does not change the byte count — it only fills the low 3 bits).
 
std::uint32_t esphome::api::float_to_bits (const float f)
 
float esphome::api::bits_to_float (const std::uint32_t bits)
 
std::uint64_t esphome::api::double_to_bits (const double d)
 
double esphome::api::bits_to_double (const std::uint64_t bits)
 

Detailed Description

Self-contained proto3 wire-format primitives (varint / zigzag / fixed32 / fixed64 / length-delimited), with a writer and a reader.

The encoding produced here is standard proto3 wire format for the subset the ESPHome native API uses (scalars, string, bytes, enums, repeated, packed, and flat sub-messages). The contract is enforced byte-for-byte by the golden test.