diff --git a/scripts/apn_set.py b/scripts/apn_set.py index 125c801..4d81c04 100755 --- a/scripts/apn_set.py +++ b/scripts/apn_set.py @@ -56,7 +56,7 @@ def state_update(self, live: Live, state: str): self.state = state live.update(self.progress_table()) - def announce_observed(self, live: Live, infuse_id: int, pkt: readings.announce): + def announce_observed(self, live: Live, infuse_id: int, pkt: readings.announce | readings.announce_v2): if infuse_id in self.updated or infuse_id in self.already: return if pkt.application != self.app_id: diff --git a/scripts/reboot_count_reset.py b/scripts/reboot_count_reset.py index a6700b3..9694145 100755 --- a/scripts/reboot_count_reset.py +++ b/scripts/reboot_count_reset.py @@ -48,7 +48,7 @@ def state_update(self, live: Live, state: str): self.state = state live.update(self.progress_table()) - def announce_observed(self, live: Live, infuse_id: int, pkt: readings.announce): + def announce_observed(self, live: Live, infuse_id: int, pkt: readings.announce | readings.announce_v2): if pkt.application != self.app_id: return if pkt.reboots == self.count: diff --git a/src/infuse_iot/generated/kv_definitions.py b/src/infuse_iot/generated/kv_definitions.py index bce8616..5510002 100644 --- a/src/infuse_iot/generated/kv_definitions.py +++ b/src/infuse_iot/generated/kv_definitions.py @@ -150,6 +150,16 @@ class application_active(VLACompatLittleEndianStruct): ] _pack_ = 1 + class board_target(VLACompatLittleEndianStruct): + """Value of CONFIG_BOARD_TARGET""" + + NAME = "BOARD_TARGET" + BASE_ID = 7 + RANGE = 1 + _fields_ = [] + vla_field = ("board_target", structs.kv_string) + _pack_ = 1 + class fixed_location(VLACompatLittleEndianStruct): """Fixed global location of the device""" @@ -435,6 +445,7 @@ class secure_storage_reserved(VLACompatLittleEndianStruct): 4: device_name, 5: infuse_application_id, 6: application_active, + 7: board_target, 10: fixed_location, 20: wifi_ssid, 21: wifi_psk, diff --git a/src/infuse_iot/generated/tdf_definitions.py b/src/infuse_iot/generated/tdf_definitions.py index b4ea10f..3c7cbfd 100644 --- a/src/infuse_iot/generated/tdf_definitions.py +++ b/src/infuse_iot/generated/tdf_definitions.py @@ -407,6 +407,43 @@ class reboot_info(TdfReadingBase): "thread": "{}", } + class announce_v2(TdfReadingBase): + """Common announcement packet""" + + ID = 7 + NAME = "ANNOUNCE_V2" + _fields_ = [ + ("application", ctypes.c_uint32), + ("version", structs.tdf_struct_mcuboot_img_sem_ver), + ("board_crc", ctypes.c_uint16), + ("kv_crc", ctypes.c_uint32), + ("blocks", ctypes.c_uint32), + ("uptime", ctypes.c_uint32), + ("reboots", ctypes.c_uint16), + ("flags", ctypes.c_uint8), + ] + _pack_ = 1 + _postfix_ = { + "application": "", + "version": "", + "board_crc": "", + "kv_crc": "", + "blocks": "", + "uptime": "", + "reboots": "", + "flags": "", + } + _display_fmt_ = { + "application": "0x{:08x}", + "version": "{}", + "board_crc": "0x{:04x}", + "kv_crc": "0x{:08x}", + "blocks": "{}", + "uptime": "{}", + "reboots": "{}", + "flags": "0x{:02x}", + } + class acc_2g(TdfReadingBase): """Accelerometer +-2G""" @@ -1645,6 +1682,7 @@ class pcm_16bit_chan_dual(TdfReadingBase): readings.ambient_temperature.ID: readings.ambient_temperature, readings.time_sync.ID: readings.time_sync, readings.reboot_info.ID: readings.reboot_info, + readings.announce_v2.ID: readings.announce_v2, readings.acc_2g.ID: readings.acc_2g, readings.acc_4g.ID: readings.acc_4g, readings.acc_8g.ID: readings.acc_8g, diff --git a/src/infuse_iot/socket_comms.py b/src/infuse_iot/socket_comms.py index dd50bac..35db5ef 100644 --- a/src/infuse_iot/socket_comms.py +++ b/src/infuse_iot/socket_comms.py @@ -330,7 +330,7 @@ def close(self): # Close the socket self._input_sock.close() - def observe_announce(self) -> Generator[tuple[HopReceived, readings.announce], None, None]: + def observe_announce(self) -> Generator[tuple[HopReceived, readings.announce | readings.announce_v2], None, None]: decoder = TDF() while True: msg = self.receive() @@ -343,6 +343,7 @@ def observe_announce(self) -> Generator[tuple[HopReceived, readings.announce], N source = msg.epacket.route[0] for tdf in decoder.decode(msg.epacket.payload): - if not isinstance(tdf.data[0], readings.announce): - continue - yield (source, tdf.data[0]) + if isinstance(tdf.data[0], readings.announce): + yield (source, tdf.data[0]) + if isinstance(tdf.data[0], readings.announce_v2): + yield (source, tdf.data[0]) diff --git a/src/infuse_iot/tools/data_logger_sync.py b/src/infuse_iot/tools/data_logger_sync.py index b5c9dd8..896e503 100644 --- a/src/infuse_iot/tools/data_logger_sync.py +++ b/src/infuse_iot/tools/data_logger_sync.py @@ -45,7 +45,7 @@ def __init__(self, path: pathlib.Path): else: self.on_disk = os.path.getsize(self.path) // self.BLOCK_SIZE - def observe(self, announce: readings.announce): + def observe(self, announce: readings.announce | readings.announce_v2): self.on_device = announce.blocks def append_data(self, data: bytes):