mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 15:30:21 +00:00
[api] Decode without a vtable (#19029)
This commit is contained in:
+551
-339
File diff suppressed because it is too large
Load Diff
@@ -424,12 +424,15 @@ class HelloRequest final : public ProtoDecodableMessage {
|
||||
StringRef client_info{};
|
||||
uint32_t api_version_major{0};
|
||||
uint32_t api_version_minor{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class HelloResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -462,6 +465,9 @@ class DisconnectRequest final : public ProtoDecodableMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("disconnect_request"); }
|
||||
#endif
|
||||
enums::DisconnectReason reason{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
static uint8_t *encode_msg(const void *self, ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM);
|
||||
uint8_t *encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM) const {
|
||||
return encode_msg(this, buffer PROTO_ENCODE_DEBUG_ARG);
|
||||
@@ -473,7 +479,7 @@ class DisconnectRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class DisconnectResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -844,12 +850,15 @@ class CoverCommandRequest final : public CommandProtoMessage {
|
||||
bool has_tilt{false};
|
||||
float tilt{0.0f};
|
||||
bool stop{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_FAN
|
||||
@@ -918,12 +927,15 @@ class FanCommandRequest final : public CommandProtoMessage {
|
||||
int32_t speed_level{0};
|
||||
bool has_preset_mode{false};
|
||||
StringRef preset_mode{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_LIGHT
|
||||
@@ -1014,12 +1026,15 @@ class LightCommandRequest final : public CommandProtoMessage {
|
||||
uint32_t flash_length{0};
|
||||
bool has_effect{false};
|
||||
StringRef effect{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
@@ -1119,12 +1134,15 @@ class SwitchCommandRequest final : public CommandProtoMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("switch_command_request"); }
|
||||
#endif
|
||||
bool state{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
@@ -1179,12 +1197,15 @@ class SubscribeLogsRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
enums::LogLevel level{};
|
||||
bool dump_config{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class SubscribeLogsResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -1222,12 +1243,15 @@ class NoiseEncryptionSetKeyRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
const uint8_t *key{nullptr};
|
||||
uint16_t key_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class NoiseEncryptionSetKeyResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -1316,12 +1340,15 @@ class HomeassistantActionResponse final : public ProtoDecodableMessage {
|
||||
const uint8_t *response_data{nullptr};
|
||||
uint16_t response_data_len{0};
|
||||
#endif
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_API_HOMEASSISTANT_STATES
|
||||
@@ -1357,12 +1384,15 @@ class HomeAssistantStateResponse final : public ProtoDecodableMessage {
|
||||
StringRef entity_id{};
|
||||
StringRef state{};
|
||||
StringRef attribute{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
class GetTimeRequest final : public ProtoMessage {
|
||||
@@ -1386,12 +1416,15 @@ class DSTRule final : public ProtoDecodableMessage {
|
||||
uint32_t month{0};
|
||||
uint32_t week{0};
|
||||
uint32_t day_of_week{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class ParsedTimezone final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -1399,12 +1432,15 @@ class ParsedTimezone final : public ProtoDecodableMessage {
|
||||
int32_t dst_offset_seconds{0};
|
||||
DSTRule dst_start{};
|
||||
DSTRule dst_end{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class GetTimeResponse final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -1416,12 +1452,15 @@ class GetTimeResponse final : public ProtoDecodableMessage {
|
||||
uint32_t epoch_seconds{0};
|
||||
ParsedTimezone parsed_timezone{};
|
||||
bool has_parsed_timezone{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#ifdef USE_API_USER_DEFINED_ACTIONS
|
||||
class ListEntitiesServicesArgument final : public ProtoMessage {
|
||||
@@ -1489,7 +1528,7 @@ class ExecuteServiceArgument final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class ExecuteServiceRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -1512,7 +1551,7 @@ class ExecuteServiceRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_API_USER_DEFINED_ACTION_RESPONSES
|
||||
@@ -1598,12 +1637,15 @@ class CameraImageRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
bool single{false};
|
||||
bool stream{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_CLIMATE
|
||||
@@ -1704,12 +1746,15 @@ class ClimateCommandRequest final : public CommandProtoMessage {
|
||||
StringRef custom_preset{};
|
||||
bool has_target_humidity{false};
|
||||
float target_humidity{0.0f};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_WATER_HEATER
|
||||
@@ -1776,12 +1821,15 @@ class WaterHeaterCommandRequest final : public CommandProtoMessage {
|
||||
uint32_t state{0};
|
||||
float target_temperature_low{0.0f};
|
||||
float target_temperature_high{0.0f};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_NUMBER
|
||||
@@ -1839,12 +1887,15 @@ class NumberCommandRequest final : public CommandProtoMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("number_command_request"); }
|
||||
#endif
|
||||
float state{0.0f};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
@@ -1897,12 +1948,15 @@ class SelectCommandRequest final : public CommandProtoMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("select_command_request"); }
|
||||
#endif
|
||||
StringRef state{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_SIREN
|
||||
@@ -1963,12 +2017,15 @@ class SirenCommandRequest final : public CommandProtoMessage {
|
||||
uint32_t duration{0};
|
||||
bool has_volume{false};
|
||||
float volume{0.0f};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_LOCK
|
||||
@@ -2025,12 +2082,15 @@ class LockCommandRequest final : public CommandProtoMessage {
|
||||
enums::LockCommand command{};
|
||||
bool has_code{false};
|
||||
StringRef code{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_BUTTON
|
||||
@@ -2061,12 +2121,15 @@ class ButtonCommandRequest final : public CommandProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const LogString *message_name() const override { return LOG_STR("button_command_request"); }
|
||||
#endif
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_MEDIA_PLAYER
|
||||
@@ -2147,12 +2210,15 @@ class MediaPlayerCommandRequest final : public CommandProtoMessage {
|
||||
StringRef media_url{};
|
||||
bool has_announcement{false};
|
||||
bool announcement{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_BLUETOOTH_PROXY
|
||||
@@ -2164,12 +2230,15 @@ class SubscribeBluetoothLEAdvertisementsRequest final : public ProtoDecodableMes
|
||||
const LogString *message_name() const override { return LOG_STR("subscribe_bluetooth_le_advertisements_request"); }
|
||||
#endif
|
||||
uint32_t flags{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothLERawAdvertisement final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2218,12 +2287,15 @@ class BluetoothDeviceRequest final : public ProtoDecodableMessage {
|
||||
enums::BluetoothDeviceRequestType request_type{};
|
||||
bool has_address_type{false};
|
||||
uint32_t address_type{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothDeviceConnectionResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2256,12 +2328,15 @@ class BluetoothGATTGetServicesRequest final : public ProtoDecodableMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("bluetooth_gatt_get_services_request"); }
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothGATTDescriptor final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2367,12 +2442,15 @@ class BluetoothGATTReadRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothGATTReadResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2413,12 +2491,15 @@ class BluetoothGATTWriteRequest final : public ProtoDecodableMessage {
|
||||
bool response{false};
|
||||
const uint8_t *data{nullptr};
|
||||
uint16_t data_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2429,12 +2510,15 @@ class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2447,12 +2531,15 @@ class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage {
|
||||
uint32_t handle{0};
|
||||
const uint8_t *data{nullptr};
|
||||
uint16_t data_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2464,12 +2551,15 @@ class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage {
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
bool enable{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothGATTNotifyDataResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2682,12 +2772,15 @@ class BluetoothScannerSetModeRequest final : public ProtoDecodableMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("bluetooth_scanner_set_mode_request"); }
|
||||
#endif
|
||||
enums::BluetoothScannerMode mode{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_VOICE_ASSISTANT
|
||||
@@ -2700,12 +2793,15 @@ class SubscribeVoiceAssistantRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
bool subscribe{false};
|
||||
uint32_t flags{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantAudioSettings final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2757,23 +2853,29 @@ class VoiceAssistantResponse final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
uint32_t port{0};
|
||||
bool error{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantEventData final : public ProtoDecodableMessage {
|
||||
public:
|
||||
StringRef name{};
|
||||
StringRef value{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantEventResponse final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2784,12 +2886,15 @@ class VoiceAssistantEventResponse final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
enums::VoiceAssistantEvent event_type{};
|
||||
std::vector<VoiceAssistantEventData> data{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantAudio final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2803,6 +2908,9 @@ class VoiceAssistantAudio final : public ProtoDecodableMessage {
|
||||
bool end{false};
|
||||
const uint8_t *data2{nullptr};
|
||||
uint16_t data2_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
static uint8_t *encode_msg(const void *self, ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM);
|
||||
uint8_t *encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM) const {
|
||||
return encode_msg(this, buffer PROTO_ENCODE_DEBUG_ARG);
|
||||
@@ -2814,7 +2922,7 @@ class VoiceAssistantAudio final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantTimerEventResponse final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2829,12 +2937,15 @@ class VoiceAssistantTimerEventResponse final : public ProtoDecodableMessage {
|
||||
uint32_t total_seconds{0};
|
||||
uint32_t seconds_left{0};
|
||||
bool is_active{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantAnnounceRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2847,12 +2958,15 @@ class VoiceAssistantAnnounceRequest final : public ProtoDecodableMessage {
|
||||
StringRef text{};
|
||||
StringRef preannounce_media_id{};
|
||||
bool start_conversation{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantAnnounceFinished final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2900,12 +3014,15 @@ class VoiceAssistantExternalWakeWord final : public ProtoDecodableMessage {
|
||||
uint32_t model_size{0};
|
||||
StringRef model_hash{};
|
||||
StringRef url{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantConfigurationRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -2915,12 +3032,15 @@ class VoiceAssistantConfigurationRequest final : public ProtoDecodableMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("voice_assistant_configuration_request"); }
|
||||
#endif
|
||||
std::vector<VoiceAssistantExternalWakeWord> external_wake_words{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class VoiceAssistantConfigurationResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -2952,12 +3072,15 @@ class VoiceAssistantSetConfiguration final : public ProtoDecodableMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("voice_assistant_set_configuration"); }
|
||||
#endif
|
||||
std::vector<std::string> active_wake_words{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_ALARM_CONTROL_PANEL
|
||||
@@ -3012,12 +3135,15 @@ class AlarmControlPanelCommandRequest final : public CommandProtoMessage {
|
||||
#endif
|
||||
enums::AlarmControlPanelStateCommand command{};
|
||||
StringRef code{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_TEXT
|
||||
@@ -3073,12 +3199,15 @@ class TextCommandRequest final : public CommandProtoMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("text_command_request"); }
|
||||
#endif
|
||||
StringRef state{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_DATETIME_DATE
|
||||
@@ -3134,12 +3263,15 @@ class DateCommandRequest final : public CommandProtoMessage {
|
||||
uint32_t year{0};
|
||||
uint32_t month{0};
|
||||
uint32_t day{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_DATETIME_TIME
|
||||
@@ -3195,12 +3327,15 @@ class TimeCommandRequest final : public CommandProtoMessage {
|
||||
uint32_t hour{0};
|
||||
uint32_t minute{0};
|
||||
uint32_t second{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_EVENT
|
||||
@@ -3301,12 +3436,15 @@ class ValveCommandRequest final : public CommandProtoMessage {
|
||||
bool has_position{false};
|
||||
float position{0.0f};
|
||||
bool stop{false};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_DATETIME_DATETIME
|
||||
@@ -3358,12 +3496,15 @@ class DateTimeCommandRequest final : public CommandProtoMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("date_time_command_request"); }
|
||||
#endif
|
||||
uint32_t epoch_seconds{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_UPDATE
|
||||
@@ -3423,12 +3564,15 @@ class UpdateCommandRequest final : public CommandProtoMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("update_command_request"); }
|
||||
#endif
|
||||
enums::UpdateCommand command{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_ZWAVE_PROXY
|
||||
@@ -3441,6 +3585,9 @@ class ZWaveProxyFrame final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
const uint8_t *data{nullptr};
|
||||
uint16_t data_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
static uint8_t *encode_msg(const void *self, ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM);
|
||||
uint8_t *encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM) const {
|
||||
return encode_msg(this, buffer PROTO_ENCODE_DEBUG_ARG);
|
||||
@@ -3452,7 +3599,7 @@ class ZWaveProxyFrame final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class ZWaveProxyRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -3464,6 +3611,9 @@ class ZWaveProxyRequest final : public ProtoDecodableMessage {
|
||||
enums::ZWaveProxyRequestType type{};
|
||||
const uint8_t *data{nullptr};
|
||||
uint16_t data_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
static uint8_t *encode_msg(const void *self, ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM);
|
||||
uint8_t *encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM) const {
|
||||
return encode_msg(this, buffer PROTO_ENCODE_DEBUG_ARG);
|
||||
@@ -3475,7 +3625,7 @@ class ZWaveProxyRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class ZWaveProxyRequestResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -3540,12 +3690,15 @@ class InfraredRFTransmitRawTimingsRequest final : public ProtoDecodableMessage {
|
||||
uint16_t timings_length_{0};
|
||||
uint16_t timings_count_{0};
|
||||
uint32_t modulation{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class InfraredRFReceiveEvent final : public ProtoMessage {
|
||||
public:
|
||||
@@ -3611,12 +3764,15 @@ class SerialProxyConfigureRequest final : public ProtoDecodableMessage {
|
||||
enums::SerialProxyParity parity{};
|
||||
uint32_t stop_bits{0};
|
||||
uint32_t data_size{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class SerialProxyDataReceived final : public ProtoMessage {
|
||||
public:
|
||||
@@ -3654,12 +3810,15 @@ class SerialProxyWriteRequest final : public ProtoDecodableMessage {
|
||||
uint32_t instance{0};
|
||||
const uint8_t *data{nullptr};
|
||||
uint16_t data_len{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class SerialProxySetModemPinsRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -3670,12 +3829,15 @@ class SerialProxySetModemPinsRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
uint32_t instance{0};
|
||||
uint32_t line_states{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class SerialProxyGetModemPinsRequest final : public ProtoDecodableMessage {
|
||||
public:
|
||||
@@ -3685,12 +3847,15 @@ class SerialProxyGetModemPinsRequest final : public ProtoDecodableMessage {
|
||||
const LogString *message_name() const override { return LOG_STR("serial_proxy_get_modem_pins_request"); }
|
||||
#endif
|
||||
uint32_t instance{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class SerialProxyGetModemPinsResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -3723,12 +3888,15 @@ class SerialProxyRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
uint32_t instance{0};
|
||||
enums::SerialProxyRequestType type{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class SerialProxyRequestResponse final : public ProtoMessage {
|
||||
public:
|
||||
@@ -3762,12 +3930,15 @@ class SerialProxySetModeRequest final : public ProtoDecodableMessage {
|
||||
#endif
|
||||
uint32_t instance{0};
|
||||
enums::SerialProxyMode mode{};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
#endif
|
||||
#ifdef USE_BLUETOOTH_PROXY_CONNECTIONS
|
||||
@@ -3783,12 +3954,15 @@ class BluetoothSetConnectionParamsRequest final : public ProtoDecodableMessage {
|
||||
uint32_t max_interval{0};
|
||||
uint32_t latency{0};
|
||||
uint32_t timeout{0};
|
||||
void decode(const uint8_t *buffer, size_t length) {
|
||||
ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *dump_to(DumpBuffer &out) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;
|
||||
static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
};
|
||||
class BluetoothSetConnectionParamsResponse final : public ProtoMessage {
|
||||
public:
|
||||
|
||||
@@ -216,7 +216,7 @@ void ProtoWriteBuffer::debug_check_encode_size_(uint32_t field_id, uint32_t expe
|
||||
|
||||
#endif
|
||||
|
||||
void ProtoDecodableMessage::decode(const uint8_t *buffer, size_t length) {
|
||||
void ProtoDecodableMessage::decode_fields(void *msg, const uint8_t *buffer, size_t length, DecodeFieldFn field) {
|
||||
const uint8_t *ptr = buffer;
|
||||
const uint8_t *end = buffer + length;
|
||||
|
||||
@@ -287,7 +287,7 @@ void ProtoDecodableMessage::decode(const uint8_t *buffer, size_t length) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->decode_field(tag, data, scalar);
|
||||
field(msg, tag, data, scalar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||
@@ -723,7 +724,13 @@ class ProtoMessage {
|
||||
// Base class for messages that support decoding
|
||||
class ProtoDecodableMessage : public ProtoMessage {
|
||||
public:
|
||||
void decode(const uint8_t *buffer, size_t length);
|
||||
/// Stores one decoded field into \p msg; generated per message type. \p scalar is the varint or
|
||||
/// fixed32 value, or the length of the length-delimited payload at \p data. An unknown field or
|
||||
/// wrong wire type matches no case and is skipped.
|
||||
using DecodeFieldFn = void (*)(void *msg, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);
|
||||
/// Walk \p buffer and hand every field to \p field. The generated decode() passes the message's
|
||||
/// own decode_field, so decodable messages carry no vtable.
|
||||
static void decode_fields(void *msg, const uint8_t *buffer, size_t length, DecodeFieldFn field);
|
||||
|
||||
/**
|
||||
* Count occurrences of a repeated field in a protobuf buffer.
|
||||
@@ -735,14 +742,15 @@ class ProtoDecodableMessage : public ProtoMessage {
|
||||
* @return Number of times the field appears in the buffer
|
||||
*/
|
||||
static uint32_t count_repeated_field(const uint8_t *buffer, size_t length, uint32_t target_field_id);
|
||||
|
||||
protected:
|
||||
~ProtoDecodableMessage() = default;
|
||||
/// Store one decoded field; \p scalar is the varint or fixed32 value, or the length of the
|
||||
/// length-delimited payload at \p data. An unknown field or wrong wire type matches no case and is skipped.
|
||||
/// Three register arguments keep the decode loop free of spills.
|
||||
virtual void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {}
|
||||
// The destructor stays accessible on purpose: the generated messages are aggregates that brace
|
||||
// initialise sub message members, which copies a base temporary. That trades away the compile time
|
||||
// guard against deleting through this type; messages are stack locals and never owned through a base
|
||||
// pointer. ProtoMessage keeps its guard for the dump builds.
|
||||
};
|
||||
#ifndef HAS_PROTO_MESSAGE_DUMP
|
||||
// decode() passes decode_field explicitly, so nothing here may add a vtable
|
||||
static_assert(!std::is_polymorphic_v<ProtoDecodableMessage>, "decodable messages carry no vtable");
|
||||
#endif
|
||||
|
||||
class ProtoSize {
|
||||
public:
|
||||
|
||||
@@ -2536,8 +2536,8 @@ def build_message_type(
|
||||
|
||||
# Get source direction to determine if we need decode/encode methods
|
||||
source = message_source_map[desc.name]
|
||||
needs_decode = source in (SOURCE_BOTH, SOURCE_CLIENT)
|
||||
needs_encode = source in (SOURCE_BOTH, SOURCE_SERVER)
|
||||
needs_decode = message_needs_decode(source)
|
||||
needs_encode = message_needs_encode(source)
|
||||
|
||||
# Add MESSAGE_TYPE method if this is a service message
|
||||
if message_id is not None:
|
||||
@@ -2661,15 +2661,22 @@ def build_message_type(
|
||||
|
||||
cpp = ""
|
||||
if decode:
|
||||
o = f"void {desc.name}::decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {{\n"
|
||||
o = f"void {desc.name}::decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {{\n"
|
||||
o += f" auto &msg = *static_cast<{desc.name} *>(self);\n"
|
||||
o += " const ProtoFieldValue value(data, scalar);\n"
|
||||
o += " switch (tag) {\n"
|
||||
o += indent("\n".join(decode), " ") + "\n"
|
||||
o += indent("\n".join(decode), " ").replace("this->", "msg.") + "\n"
|
||||
o += " }\n"
|
||||
o += "}\n"
|
||||
cpp += o
|
||||
prot = "void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;"
|
||||
prot = "static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);"
|
||||
protected_content.insert(0, prot)
|
||||
if not fixed_vector_fields:
|
||||
public_content.append(
|
||||
"void decode(const uint8_t *buffer, size_t length) {\n"
|
||||
" ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);\n"
|
||||
"}"
|
||||
)
|
||||
|
||||
# Generate custom decode() override for messages with FixedVector fields
|
||||
if fixed_vector_fields:
|
||||
@@ -2679,8 +2686,8 @@ def build_message_type(
|
||||
for field_name, field_number in fixed_vector_fields:
|
||||
o += f" uint32_t count_{field_name} = ProtoDecodableMessage::count_repeated_field(buffer, length, {field_number});\n"
|
||||
o += f" this->{field_name}.init(count_{field_name});\n"
|
||||
# Call parent decode to populate the fields
|
||||
o += " ProtoDecodableMessage::decode(buffer, length);\n"
|
||||
# Then the shared loop fills them
|
||||
o += " ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);\n"
|
||||
o += "}\n"
|
||||
cpp += o
|
||||
# Generate the decode() declaration in header (public method)
|
||||
@@ -2839,6 +2846,23 @@ def get_field_opt(
|
||||
return field.options.Extensions[opt]
|
||||
|
||||
|
||||
def message_needs_decode(source: int) -> bool:
|
||||
return source in (SOURCE_BOTH, SOURCE_CLIENT)
|
||||
|
||||
|
||||
def message_needs_encode(source: int) -> bool:
|
||||
return source in (SOURCE_BOTH, SOURCE_SERVER)
|
||||
|
||||
|
||||
def is_decodable_class(desc: descriptor.DescriptorProto, source: int) -> bool:
|
||||
"""Whether the generated class derives from ProtoDecodableMessage: decoded, and either on a
|
||||
decodable base class or with at least one live field."""
|
||||
return message_needs_decode(source) and (
|
||||
get_base_class(desc) is not None
|
||||
or any(not field.options.deprecated for field in desc.field)
|
||||
)
|
||||
|
||||
|
||||
def get_base_class(desc: descriptor.DescriptorProto) -> str | None:
|
||||
"""Get the base_class option from a message descriptor."""
|
||||
if not desc.options.HasExtension(pb.base_class):
|
||||
@@ -2940,11 +2964,11 @@ def build_base_class(
|
||||
|
||||
# Determine if any message using this base class needs decoding/encoding
|
||||
needs_decode = any(
|
||||
message_source_map.get(msg.name, SOURCE_BOTH) in (SOURCE_BOTH, SOURCE_CLIENT)
|
||||
message_needs_decode(message_source_map.get(msg.name, SOURCE_BOTH))
|
||||
for msg in messages
|
||||
)
|
||||
needs_encode = any(
|
||||
message_source_map.get(msg.name, SOURCE_BOTH) in (SOURCE_BOTH, SOURCE_SERVER)
|
||||
message_needs_encode(message_source_map.get(msg.name, SOURCE_BOTH))
|
||||
for msg in messages
|
||||
)
|
||||
|
||||
@@ -3378,6 +3402,7 @@ static void dump_bytes_field(DumpBuffer &out, const char *field_name, const uint
|
||||
|
||||
# Generate message types with base class information
|
||||
# Simple grouping by ifdef
|
||||
decodable_messages: list[tuple[str, str | None]] = []
|
||||
current_ifdef = None
|
||||
|
||||
for m in mt:
|
||||
@@ -3394,6 +3419,8 @@ static void dump_bytes_field(DumpBuffer &out, const char *field_name, const uint
|
||||
continue
|
||||
|
||||
s, c, dc = build_message_type(m, base_class_fields, message_source_map)
|
||||
if is_decodable_class(m, message_source_map[m.name]):
|
||||
decodable_messages.append((m.name, message_ifdef_map.get(m.name)))
|
||||
msg_ifdef = message_ifdef_map.get(m.name)
|
||||
|
||||
# Handle ifdef changes
|
||||
@@ -3420,6 +3447,22 @@ static void dump_bytes_field(DumpBuffer &out, const char *field_name, const uint
|
||||
cpp += "#endif\n"
|
||||
dump_cpp += "#endif\n"
|
||||
|
||||
# decode() passes decode_field explicitly, so without the dump virtuals no decodable message
|
||||
# may carry a vtable; a build at any level below VERY_VERBOSE proves it
|
||||
cpp += "#ifndef HAS_PROTO_MESSAGE_DUMP\n"
|
||||
assert_ifdef = None
|
||||
for name, msg_ifdef in decodable_messages:
|
||||
if msg_ifdef != assert_ifdef:
|
||||
if assert_ifdef is not None:
|
||||
cpp += "#endif\n"
|
||||
if msg_ifdef is not None:
|
||||
cpp += _make_ifdef_line(msg_ifdef) + "\n"
|
||||
assert_ifdef = msg_ifdef
|
||||
cpp += f'static_assert(!std::is_polymorphic_v<{name}>, "decodable messages carry no vtable");\n'
|
||||
if assert_ifdef is not None:
|
||||
cpp += "#endif\n"
|
||||
cpp += "#endif\n"
|
||||
|
||||
content += """\
|
||||
|
||||
} // namespace esphome::api
|
||||
|
||||
@@ -287,18 +287,19 @@ def test_a_fixed64_field_fails_at_generation_time() -> None:
|
||||
build_message_type(desc, {}, {"Wide": SOURCE_CLIENT})
|
||||
|
||||
|
||||
def test_message_gets_a_single_decode_field_override() -> None:
|
||||
"""All wire types of a decoded message land in one decode_field() switch."""
|
||||
def test_message_decodes_through_one_static_decode_field() -> None:
|
||||
"""All wire types of a decoded message land in one static decode_field() switch that the
|
||||
inline decode() hands to the shared loop."""
|
||||
desc = descriptor_pb2.DescriptorProto(name="Mixed")
|
||||
desc.field.add(name="name", number=1, type=STRING)
|
||||
desc.field.add(name="count", number=2, type=UINT32)
|
||||
desc.field.add(name="level", number=3, type=FLOAT)
|
||||
header, cpp, _ = build_message_type(desc, {}, {"Mixed": SOURCE_CLIENT})
|
||||
decl = "void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;"
|
||||
decl = "static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);"
|
||||
assert header.count(decl) == 1
|
||||
assert (
|
||||
cpp.count(
|
||||
"void Mixed::decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {"
|
||||
"void Mixed::decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {"
|
||||
)
|
||||
== 1
|
||||
)
|
||||
@@ -310,6 +311,37 @@ def test_message_gets_a_single_decode_field_override() -> None:
|
||||
(3, "WIRE_TYPE_FIXED32"),
|
||||
):
|
||||
assert f"case proto_tag({number}, {wire_type}):" in cpp, cpp
|
||||
# The static body works on the cast message, never on this
|
||||
assert "auto &msg = *static_cast<Mixed *>(self);" in cpp
|
||||
assert "this->" not in cpp
|
||||
assert (
|
||||
header.count(
|
||||
"ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);"
|
||||
)
|
||||
== 1
|
||||
)
|
||||
|
||||
|
||||
def test_fixed_vector_message_keeps_its_own_decode() -> None:
|
||||
"""A message that sizes a FixedVector first decodes through its own decode(), not the inline one."""
|
||||
desc = descriptor_pb2.DescriptorProto(name="Sized")
|
||||
field = desc.field.add(name="values", number=1, type=UINT32)
|
||||
field.label = descriptor_pb2.FieldDescriptorProto.LABEL_REPEATED
|
||||
field.options.Extensions[pb.fixed_vector] = True
|
||||
header, cpp, _ = build_message_type(desc, {}, {"Sized": SOURCE_CLIENT})
|
||||
assert (
|
||||
"ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);"
|
||||
not in header
|
||||
)
|
||||
assert header.count("void decode(const uint8_t *buffer, size_t length);") == 1
|
||||
assert "void Sized::decode(const uint8_t *buffer, size_t length) {" in cpp
|
||||
assert "ProtoDecodableMessage::count_repeated_field(buffer, length, 1)" in cpp
|
||||
assert (
|
||||
cpp.count(
|
||||
"ProtoDecodableMessage::decode_fields(this, buffer, length, &decode_field);"
|
||||
)
|
||||
== 1
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", [SOURCE_CLIENT, SOURCE_SERVER, SOURCE_BOTH])
|
||||
|
||||
Reference in New Issue
Block a user