mirror of
https://github.com/esphome/esphome.git
synced 2025-08-05 09:57:47 +00:00
revert
This commit is contained in:
parent
d567533161
commit
a03a748a56
@ -358,7 +358,7 @@ void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
|
|||||||
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
for (uint8_t j = 0; j < repeated_count; j++) {
|
for (uint8_t j = 0; j < repeated_count; j++) {
|
||||||
if (repeated_fields[j].field_num == field_id && repeated_fields[j].get_wire_type() == 0) {
|
if (repeated_fields[j].field_num == field_id && get_wire_type(repeated_fields[j].get_type()) == 0) {
|
||||||
void *field_addr = base + repeated_fields[j].get_offset();
|
void *field_addr = base + repeated_fields[j].get_offset();
|
||||||
decoded = decode_repeated_varint_field(repeated_fields[j].get_type(), field_addr, value);
|
decoded = decode_repeated_varint_field(repeated_fields[j].get_type(), field_addr, value);
|
||||||
break;
|
break;
|
||||||
@ -395,7 +395,7 @@ void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
|
|||||||
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
for (uint8_t j = 0; j < repeated_count; j++) {
|
for (uint8_t j = 0; j < repeated_count; j++) {
|
||||||
if (repeated_fields[j].field_num == field_id && repeated_fields[j].get_wire_type() == 2) {
|
if (repeated_fields[j].field_num == field_id && get_wire_type(repeated_fields[j].get_type()) == 2) {
|
||||||
void *field_addr = base + repeated_fields[j].get_offset();
|
void *field_addr = base + repeated_fields[j].get_offset();
|
||||||
decoded = decode_repeated_length_field(repeated_fields[j].get_type(), field_addr, value,
|
decoded = decode_repeated_length_field(repeated_fields[j].get_type(), field_addr, value,
|
||||||
repeated_fields[j].get_message_type_id());
|
repeated_fields[j].get_message_type_id());
|
||||||
@ -430,7 +430,7 @@ void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
|
|||||||
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
for (uint8_t j = 0; j < repeated_count; j++) {
|
for (uint8_t j = 0; j < repeated_count; j++) {
|
||||||
if (repeated_fields[j].field_num == field_id && repeated_fields[j].get_wire_type() == 5) {
|
if (repeated_fields[j].field_num == field_id && get_wire_type(repeated_fields[j].get_type()) == 5) {
|
||||||
void *field_addr = base + repeated_fields[j].get_offset();
|
void *field_addr = base + repeated_fields[j].get_offset();
|
||||||
decoded = decode_repeated_32bit_field(repeated_fields[j].get_type(), field_addr, value);
|
decoded = decode_repeated_32bit_field(repeated_fields[j].get_type(), field_addr, value);
|
||||||
break;
|
break;
|
||||||
|
@ -271,7 +271,6 @@ struct FieldMeta {
|
|||||||
// Helper methods
|
// Helper methods
|
||||||
inline ProtoFieldType get_type() const { return static_cast<ProtoFieldType>(type_and_size & 0x1F); }
|
inline ProtoFieldType get_type() const { return static_cast<ProtoFieldType>(type_and_size & 0x1F); }
|
||||||
inline uint8_t get_precalced_size() const { return ((type_and_size >> 5) & 0x03) + 1; }
|
inline uint8_t get_precalced_size() const { return ((type_and_size >> 5) & 0x03) + 1; }
|
||||||
inline uint8_t get_wire_type() const { return ::esphome::api::get_wire_type(get_type()); }
|
|
||||||
inline uint16_t get_offset() const {
|
inline uint16_t get_offset() const {
|
||||||
if (get_type() == ProtoFieldType::TYPE_MESSAGE) {
|
if (get_type() == ProtoFieldType::TYPE_MESSAGE) {
|
||||||
// Reconstruct full offset from packed fields (10-bit offset)
|
// Reconstruct full offset from packed fields (10-bit offset)
|
||||||
@ -298,7 +297,6 @@ struct RepeatedFieldMeta {
|
|||||||
// Helper methods
|
// Helper methods
|
||||||
inline ProtoFieldType get_type() const { return static_cast<ProtoFieldType>(type_and_size & 0x1F); }
|
inline ProtoFieldType get_type() const { return static_cast<ProtoFieldType>(type_and_size & 0x1F); }
|
||||||
inline uint8_t get_precalced_size() const { return ((type_and_size >> 5) & 0x03) + 1; }
|
inline uint8_t get_precalced_size() const { return ((type_and_size >> 5) & 0x03) + 1; }
|
||||||
inline uint8_t get_wire_type() const { return ::esphome::api::get_wire_type(get_type()); }
|
|
||||||
inline uint16_t get_offset() const {
|
inline uint16_t get_offset() const {
|
||||||
if (get_type() == ProtoFieldType::TYPE_MESSAGE) {
|
if (get_type() == ProtoFieldType::TYPE_MESSAGE) {
|
||||||
// Reconstruct full offset from packed fields (10-bit offset)
|
// Reconstruct full offset from packed fields (10-bit offset)
|
||||||
@ -325,7 +323,7 @@ inline const FieldMeta *find_field_binary(const FieldMeta *fields, uint8_t count
|
|||||||
right = mid;
|
right = mid;
|
||||||
} else {
|
} else {
|
||||||
// Found field_id, check wire type
|
// Found field_id, check wire type
|
||||||
if (fields[mid].get_wire_type() == wire_type) {
|
if (get_wire_type(fields[mid].get_type()) == wire_type) {
|
||||||
return &fields[mid];
|
return &fields[mid];
|
||||||
}
|
}
|
||||||
// Field number matches but wire type doesn't - search nearby entries
|
// Field number matches but wire type doesn't - search nearby entries
|
||||||
@ -333,14 +331,14 @@ inline const FieldMeta *find_field_binary(const FieldMeta *fields, uint8_t count
|
|||||||
|
|
||||||
// Search backwards
|
// Search backwards
|
||||||
for (uint8_t k = mid; k > 0 && fields[k - 1].field_num == field_id; k--) {
|
for (uint8_t k = mid; k > 0 && fields[k - 1].field_num == field_id; k--) {
|
||||||
if (fields[k - 1].get_wire_type() == wire_type) {
|
if (get_wire_type(fields[k - 1].get_type()) == wire_type) {
|
||||||
return &fields[k - 1];
|
return &fields[k - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search forwards
|
// Search forwards
|
||||||
for (uint8_t k = mid + 1; k < count && fields[k].field_num == field_id; k++) {
|
for (uint8_t k = mid + 1; k < count && fields[k].field_num == field_id; k++) {
|
||||||
if (fields[k].get_wire_type() == wire_type) {
|
if (get_wire_type(fields[k].get_type()) == wire_type) {
|
||||||
return &fields[k];
|
return &fields[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user