improve c type generation

This commit is contained in:
Gwendolyn 2023-10-06 02:10:17 +02:00
parent 59ebdd74bb
commit 6ed57d99d2
4 changed files with 518 additions and 31 deletions

View file

@ -462,26 +462,27 @@ class MacAddressesListFormat(VarArrayFormat):
super().__init__(child_type=MacAddressFormat())
""" stuff """
@unique
class LedType(IntEnum):
SERIAL = 1
MULTIPIN = 2
@dataclass
class LedConfig(StructType, union_type_field="led_type"):
led_type: LedType = field(init=False, repr=False, metadata={"format": SimpleFormat('B')})
led_type: LedType = field(metadata={"format": SimpleFormat('B')})
leds_are_cool: int = field(metadata={"format": SimpleFormat('B')})
@dataclass
class SerialLedConfig(LedConfig, StructType, led_type=LedType.SERIAL):
class SerialLedConfig(LedConfig, led_type=LedType.SERIAL):
gpio: int = field(metadata={"format": SimpleFormat('B')})
rmt: int = field(metadata={"format": SimpleFormat('B')})
@dataclass
class MultipinLedConfig(LedConfig, StructType, led_type=LedType.MULTIPIN):
class MultipinLedConfig(LedConfig, led_type=LedType.MULTIPIN):
gpio_red: int = field(metadata={"format": SimpleFormat('B')})
gpio_green: int = field(metadata={"format": SimpleFormat('B')})
gpio_blue: int = field(metadata={"format": SimpleFormat('B')})
@ -491,3 +492,17 @@ class MultipinLedConfig(LedConfig, StructType, led_type=LedType.MULTIPIN):
class RangeItemType(StructType):
address: str = field(metadata={"format": MacAddressFormat()})
distance: int = field(metadata={"format": SimpleFormat('H')})
@dataclass
class FirmwareAppDescription(StructType, no_c_type=True):
magic_word: int = field(metadata={"format": SimpleFormat('I')}, repr=False)
secure_version: int = field(metadata={"format": SimpleFormat('I')})
reserv1: list[int] = field(metadata={"format": SimpleFormat('2I')}, repr=False)
version: str = field(metadata={"format": FixedStrFormat(32)})
project_name: str = field(metadata={"format": FixedStrFormat(32)})
compile_time: str = field(metadata={"format": FixedStrFormat(16)})
compile_date: str = field(metadata={"format": FixedStrFormat(16)})
idf_version: str = field(metadata={"format": FixedStrFormat(32)})
app_elf_sha256: str = field(metadata={"format": FixedHexFormat(32)})
reserv2: list[int] = field(metadata={"format": SimpleFormat('20I')}, repr=False)