mirror of
https://github.com/esphome/esphome.git
synced 2025-09-13 08:42:18 +01:00
Fix bytes field encoding in protobuf code generator
This commit is contained in:
@@ -526,9 +526,13 @@ class BytesType(TypeInfo):
|
||||
reference_type = "std::string &"
|
||||
const_reference_type = "const std::string &"
|
||||
decode_length = "value.as_string()"
|
||||
encode_func = "encode_string"
|
||||
encode_func = "encode_bytes"
|
||||
wire_type = WireType.LENGTH_DELIMITED # Uses wire type 2
|
||||
|
||||
@property
|
||||
def encode_content(self) -> str:
|
||||
return f"buffer.encode_bytes({self.number}, reinterpret_cast<const uint8_t*>(this->{self.field_name}.data()), this->{self.field_name}.size());"
|
||||
|
||||
def dump(self, name: str) -> str:
|
||||
o = f'out.append("\'").append({name}).append("\'");'
|
||||
return o
|
||||
|
Reference in New Issue
Block a user