Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/apn_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/reboot_count_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions src/infuse_iot/generated/kv_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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,
Expand Down
38 changes: 38 additions & 0 deletions src/infuse_iot/generated/tdf_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/infuse_iot/socket_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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])
2 changes: 1 addition & 1 deletion src/infuse_iot/tools/data_logger_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down