mirror of
https://github.com/esphome/esphome.git
synced 2025-07-30 07:06:38 +00:00
preen
This commit is contained in:
parent
91e1a4ff76
commit
37cbcd5110
@ -1797,7 +1797,6 @@ class BluetoothGATTGetServicesRequest : public ProtoDecodableMessage {
|
||||
class BluetoothGATTDescriptor : public ProtoMessage {
|
||||
public:
|
||||
std::array<uint64_t, 2> uuid{};
|
||||
size_t uuid_index_{0};
|
||||
uint32_t handle{0};
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
@ -1810,7 +1809,6 @@ class BluetoothGATTDescriptor : public ProtoMessage {
|
||||
class BluetoothGATTCharacteristic : public ProtoMessage {
|
||||
public:
|
||||
std::array<uint64_t, 2> uuid{};
|
||||
size_t uuid_index_{0};
|
||||
uint32_t handle{0};
|
||||
uint32_t properties{0};
|
||||
std::vector<BluetoothGATTDescriptor> descriptors{};
|
||||
@ -1825,7 +1823,6 @@ class BluetoothGATTCharacteristic : public ProtoMessage {
|
||||
class BluetoothGATTService : public ProtoMessage {
|
||||
public:
|
||||
std::array<uint64_t, 2> uuid{};
|
||||
size_t uuid_index_{0};
|
||||
uint32_t handle{0};
|
||||
std::vector<BluetoothGATTCharacteristic> characteristics{};
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
@ -1845,7 +1842,6 @@ class BluetoothGATTGetServicesResponse : public ProtoMessage {
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
std::array<BluetoothGATTService, 1> services{};
|
||||
size_t services_index_{0};
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
|
@ -887,7 +887,11 @@ class SInt64Type(TypeInfo):
|
||||
|
||||
|
||||
class FixedArrayRepeatedType(TypeInfo):
|
||||
"""Special type for fixed-size repeated fields using std::array."""
|
||||
"""Special type for fixed-size repeated fields using std::array.
|
||||
|
||||
Fixed arrays are only supported for encoding (SOURCE_SERVER) since we cannot
|
||||
control how many items we receive when decoding.
|
||||
"""
|
||||
|
||||
def __init__(self, field: descriptor.FieldDescriptorProto, size: int) -> None:
|
||||
super().__init__(field)
|
||||
@ -915,42 +919,28 @@ class FixedArrayRepeatedType(TypeInfo):
|
||||
|
||||
@property
|
||||
def public_content(self) -> list[str]:
|
||||
# Add the array member and a counter for decoding
|
||||
return [
|
||||
f"{self.cpp_type} {self.field_name}{{}};",
|
||||
f"size_t {self.field_name}_index_{{0}};",
|
||||
]
|
||||
# Just the array member, no index needed since we don't decode
|
||||
return [f"{self.cpp_type} {self.field_name}{{}};"]
|
||||
|
||||
@property
|
||||
def decode_varint_content(self) -> str:
|
||||
content = self._ti.decode_varint
|
||||
if content is None:
|
||||
return None
|
||||
return f"case {self.number}: if (this->{self.field_name}_index_ < {self.array_size}) {{ this->{self.field_name}[this->{self.field_name}_index_++] = {content}; }} break;"
|
||||
# Fixed arrays don't support decoding
|
||||
return None
|
||||
|
||||
@property
|
||||
def decode_length_content(self) -> str:
|
||||
content = self._ti.decode_length
|
||||
if content is None and isinstance(self._ti, MessageType):
|
||||
# Special handling for non-template message decoding
|
||||
return f"case {self.number}: if (this->{self.field_name}_index_ < {self.array_size}) {{ value.decode_to_message(this->{self.field_name}[this->{self.field_name}_index_++]); }} break;"
|
||||
if content is None:
|
||||
return None
|
||||
return f"case {self.number}: if (this->{self.field_name}_index_ < {self.array_size}) {{ this->{self.field_name}[this->{self.field_name}_index_++] = {content}; }} break;"
|
||||
# Fixed arrays don't support decoding
|
||||
return None
|
||||
|
||||
@property
|
||||
def decode_32bit_content(self) -> str:
|
||||
content = self._ti.decode_32bit
|
||||
if content is None:
|
||||
return None
|
||||
return f"case {self.number}: if (this->{self.field_name}_index_ < {self.array_size}) {{ this->{self.field_name}[this->{self.field_name}_index_++] = {content}; }} break;"
|
||||
# Fixed arrays don't support decoding
|
||||
return None
|
||||
|
||||
@property
|
||||
def decode_64bit_content(self) -> str:
|
||||
content = self._ti.decode_64bit
|
||||
if content is None:
|
||||
return None
|
||||
return f"case {self.number}: if (this->{self.field_name}_index_ < {self.array_size}) {{ this->{self.field_name}[this->{self.field_name}_index_++] = {content}; }} break;"
|
||||
# Fixed arrays don't support decoding
|
||||
return None
|
||||
|
||||
@property
|
||||
def _ti_is_bool(self) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user