8 static const char *
const TAG =
"api.proto";
16 if (!res.has_value()) {
17 ESP_LOGV(TAG,
"Invalid field start at %" PRIu32, i);
21 uint32_t field_type = (res->as_uint32()) & 0b111;
22 uint32_t field_id = (res->as_uint32()) >> 3;
28 if (!res.has_value()) {
29 ESP_LOGV(TAG,
"Invalid VarInt at %" PRIu32, i);
34 ESP_LOGV(TAG,
"Cannot decode VarInt field %" PRIu32
" with value %" PRIu32
"!", field_id, res->as_uint32());
41 if (!res.has_value()) {
42 ESP_LOGV(TAG,
"Invalid Length Delimited at %" PRIu32, i);
46 uint32_t field_length = res->as_uint32();
48 if (field_length > length - i) {
49 ESP_LOGV(TAG,
"Out-of-bounds Length Delimited at %" PRIu32, i);
54 ESP_LOGV(TAG,
"Cannot decode Length Delimited field %" PRIu32
"!", field_id);
61 ESP_LOGV(TAG,
"Out-of-bounds Fixed32-bit at %" PRIu32, i);
65 uint32_t
val =
encode_uint32(buffer[i + 3], buffer[i + 2], buffer[i + 1], buffer[i]);
67 ESP_LOGV(TAG,
"Cannot decode 32-bit field %" PRIu32
" with value %" PRIu32
"!", field_id, val);
73 ESP_LOGV(TAG,
"Invalid field type at %" PRIu32, i);
83 #ifdef HAS_PROTO_MESSAGE_DUMP virtual bool decode_32bit(uint32_t field_id, Proto32Bit value)
virtual bool decode_varint(uint32_t field_id, ProtoVarInt value)
static optional< ProtoVarInt > parse(const uint8_t *buffer, uint32_t len, uint32_t *consumed)
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
void decode(const uint8_t *buffer, size_t length)
virtual void dump_to(std::string &out) const =0
virtual bool decode_length(uint32_t field_id, ProtoLengthDelimited value)
Implementation of SPI Controller mode.