mirror of
https://github.com/esphome/esphome.git
synced 2026-09-03 19:46:02 +00:00
[api] Fix HELPER_LOG format mismatch and remove unused is_varint64 codegen field
- Cast msg_size/type_varint.value to uint32_t in HELPER_LOG to match PRIu32 format (proto_varint_value_t is uint64_t on BLE builds) - Remove unused is_varint64 field from api_protobuf.py TypeInfo classes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
ce70c955c4
commit
9f57c2a9b6
@@ -138,7 +138,8 @@ APIError APIPlaintextFrameHelper::try_read_frame_() {
|
||||
|
||||
if (msg_size_varint.value > MAX_MESSAGE_SIZE) {
|
||||
state_ = State::FAILED;
|
||||
HELPER_LOG("Bad packet: message size %" PRIu32 " exceeds maximum %u", msg_size_varint.value, MAX_MESSAGE_SIZE);
|
||||
HELPER_LOG("Bad packet: message size %" PRIu32 " exceeds maximum %u",
|
||||
static_cast<uint32_t>(msg_size_varint.value), MAX_MESSAGE_SIZE);
|
||||
return APIError::BAD_DATA_PACKET;
|
||||
}
|
||||
rx_header_parsed_len_ = static_cast<uint16_t>(msg_size_varint.value);
|
||||
@@ -153,8 +154,8 @@ APIError APIPlaintextFrameHelper::try_read_frame_() {
|
||||
}
|
||||
if (msg_type_varint.value > std::numeric_limits<uint16_t>::max()) {
|
||||
state_ = State::FAILED;
|
||||
HELPER_LOG("Bad packet: message type %" PRIu32 " exceeds maximum %u", msg_type_varint.value,
|
||||
std::numeric_limits<uint16_t>::max());
|
||||
HELPER_LOG("Bad packet: message type %" PRIu32 " exceeds maximum %u",
|
||||
static_cast<uint32_t>(msg_type_varint.value), std::numeric_limits<uint16_t>::max());
|
||||
return APIError::BAD_DATA_PACKET;
|
||||
}
|
||||
rx_header_parsed_type_ = static_cast<uint16_t>(msg_type_varint.value);
|
||||
|
||||
@@ -193,7 +193,6 @@ class TypeInfo(ABC):
|
||||
return f"case {self.number}: this->{self.field_name} = {content}; break;"
|
||||
|
||||
decode_varint = None
|
||||
is_varint64 = False
|
||||
|
||||
@property
|
||||
def decode_length_content(self) -> str:
|
||||
@@ -463,7 +462,6 @@ class Int64Type(TypeInfo):
|
||||
cpp_type = "int64_t"
|
||||
default_value = "0"
|
||||
decode_varint = "static_cast<int64_t>(value)"
|
||||
is_varint64 = True
|
||||
encode_func = "encode_int64"
|
||||
wire_type = WireType.VARINT # Uses wire type 0
|
||||
|
||||
@@ -484,7 +482,6 @@ class UInt64Type(TypeInfo):
|
||||
cpp_type = "uint64_t"
|
||||
default_value = "0"
|
||||
decode_varint = "value"
|
||||
is_varint64 = True
|
||||
encode_func = "encode_uint64"
|
||||
wire_type = WireType.VARINT # Uses wire type 0
|
||||
|
||||
@@ -1286,7 +1283,6 @@ class SInt64Type(TypeInfo):
|
||||
cpp_type = "int64_t"
|
||||
default_value = "0"
|
||||
decode_varint = "decode_zigzag64(value)"
|
||||
is_varint64 = True
|
||||
encode_func = "encode_sint64"
|
||||
wire_type = WireType.VARINT # Uses wire type 0
|
||||
|
||||
@@ -1624,10 +1620,6 @@ class RepeatedTypeInfo(TypeInfo):
|
||||
"""
|
||||
return self._ti.wire_type
|
||||
|
||||
@property
|
||||
def is_varint64(self):
|
||||
return self._ti.is_varint64
|
||||
|
||||
@property
|
||||
def decode_varint_content(self) -> str:
|
||||
# Pointer fields don't support decoding
|
||||
|
||||
Reference in New Issue
Block a user