From adcba4fd9a53068bd3f8b0db500b2d6527ff176c Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sat, 13 Sep 2025 17:02:04 -0500 Subject: [PATCH] [api_protobuf.py] Use type based on size/length (#10696) --- script/api_protobuf/api_protobuf.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index 205bac4937..81653c3302 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -848,10 +848,17 @@ class FixedArrayBytesType(TypeInfo): @property def public_content(self) -> list[str]: + len_type = ( + "uint8_t" + if self.array_size <= 255 + else "uint16_t" + if self.array_size <= 65535 + else "size_t" + ) # Add both the array and length fields return [ f"uint8_t {self.field_name}[{self.array_size}]{{}};", - f"uint8_t {self.field_name}_len{{0}};", + f"{len_type} {self.field_name}_len{{0}};", ] @property