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