ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
proto.h File Reference

Go to the source code of this file.

Data Structures

struct  esphome::api::ProtoVarIntResult
 Result of parsing a varint: value + number of bytes consumed. More...
 
class  esphome::api::ProtoVarInt
 Static varint parsing methods for the protobuf wire format. More...
 
class  esphome::api::ProtoFieldValue
 One decoded field: the payload pointer and a scalar holding the varint or fixed32 value, or the length of a length-delimited field. More...
 
class  esphome::api::ProtoWriteBuffer
 
class  esphome::api::ProtoEncode
 Static encode helpers for the generated encode bodies. More...
 
class  esphome::api::DumpBuffer
 Fixed-size buffer for message dumps - avoids heap allocation. More...
 
class  esphome::api::ProtoMessage
 
class  esphome::api::ProtoDecodableMessage
 
class  esphome::api::ProtoSize
 

Namespaces

namespace  esphome
 
namespace  esphome::api
 

Typedefs

using esphome::api::proto_varint_value_t = uint64_t
 Type used for decoded varint values - uint64_t when BLE needs 64-bit addresses, uint32_t otherwise.
 
using esphome::api::ProtoEncodeFn = uint8_t *(*)(const void *, uint8_t *PROTO_ENCODE_DEBUG_PARAM)
 Generated encode body: writes the fields at pos, returns the cursor past them.
 

Functions

uint32_t esphome::api::float_to_raw (float value)
 
constexpr uint32_t esphome::api::encode_zigzag32 (int32_t value)
 
constexpr uint64_t esphome::api::encode_zigzag64 (int64_t value)
 
constexpr int32_t esphome::api::decode_zigzag32 (uint32_t value)
 
constexpr int64_t esphome::api::decode_zigzag64 (uint64_t value)
 
template<typename Word = size_t>
uint16_t esphome::api::count_packed_varints (const uint8_t *data, size_t len)
 Count varints in a packed buffer: len minus bytes with the continuation bit, summed a word at a time.
 
void esphome::api::encode_varint_to_buffer (uint32_t val, uint8_t *buffer)
 Encode a varint directly into a pre-allocated buffer.
 
constexpr uint32_t esphome::api::proto_tag (uint32_t field_id, uint32_t wire_type)
 Case label for decode_field(): the wire tag of a field, so a field that arrives with another wire type matches no case.
 
void esphome::api::proto_check_bounds_failed (const uint8_t *pos, size_t bytes, const uint8_t *end, const char *caller)
 
void esphome::api::proto_check_encode_end (const uint8_t *end, const uint8_t *expected)
 Aborts unless an encode body ended exactly where calculate_size() promised.
 
void esphome::api::proto_check_sub_message_size (uint32_t field_id, uint32_t expected, const uint8_t *len_pos, const uint8_t *end)
 Aborts unless a sized sub-message (length prefix at len_pos) ended where its calculated size said.
 
template<typename T >
const char * esphome::api::proto_enum_to_string (T value)
 

Variables

constexpr uint8_t esphome::api::WIRE_TYPE_VARINT = 0
 
constexpr uint8_t esphome::api::WIRE_TYPE_LENGTH_DELIMITED = 2
 
constexpr uint8_t esphome::api::WIRE_TYPE_FIXED32 = 5
 
constexpr uint8_t esphome::api::WIRE_TYPE_MASK = 0b111
 
constexpr uint32_t esphome::api::PROTO_VARINT_PARSE_FAILED = 0
 Sentinel value for consumed field indicating parse failure.
 
constexpr uint32_t esphome::api::VARINT_MAX_1_BYTE = 1 << 7
 
constexpr uint32_t esphome::api::VARINT_MAX_2_BYTE = 1 << 14