From 4b2e453aa911ce3d51ef8a6117fe7d5a07935312 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 2 Dec 2025 16:28:24 +1000 Subject: [PATCH] tools: localhost: handle `ANNOUNCE_V2` Handle the `ANNOUNCE_V2` TDF in a similar way to `ANNOUNCE`. Signed-off-by: Jordan Yates --- src/infuse_iot/tools/localhost.py | 18 +++++++++++------- src/infuse_iot/tools/localhost/index.html | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/infuse_iot/tools/localhost.py b/src/infuse_iot/tools/localhost.py index e17ef8d..6a831f1 100644 --- a/src/infuse_iot/tools/localhost.py +++ b/src/infuse_iot/tools/localhost.py @@ -76,6 +76,11 @@ async def websocket_handler(self, request: BaseRequest): "field": "infuse_id", "headerHozAlign": "center", }, + { + "title": "App ID", + "field": "application", + "headerHozAlign": "center", + }, { "title": "Last Heard", "field": "time", @@ -101,11 +106,9 @@ async def websocket_handler(self, request: BaseRequest): ], } ] - # Put ANNOUNCE TDF first, if it exists - if "ANNOUNCE" in self._columns: - sorted_tdfs = ["ANNOUNCE"] + [v for v in sorted(self._columns) if v != "ANNOUNCE"] - else: - sorted_tdfs = sorted(self._columns) + # Put the announce TDFs first for clarity + priorities = {"ANNOUNCE_V2": 0, "ANNOUNCE": 1} + sorted_tdfs = sorted(self._columns, key=lambda x: priorities.get(x, 2)) for tdf_name in sorted_tdfs: columns.append( @@ -190,9 +193,8 @@ def recv_thread(self) -> None: if source.infuse_id not in self._data: self._data[source.infuse_id] = { "infuse_id": f"0x{source.infuse_id:016x}", + "application": "Unknown", } - # Set default application ID - self._data[source.infuse_id]["ANNOUNCE"] = {"application": "Unknown"} self._data[source.infuse_id]["time"] = InfuseTime.utc_time_string(time.time()) if source.interface == interface.ID.BT_ADV: @@ -207,6 +209,8 @@ def recv_thread(self) -> None: self._columns[t.NAME] = self.tdf_columns(t) if t.NAME not in self._data[source.infuse_id]: self._data[source.infuse_id][t.NAME] = {} + if t.NAME in ["ANNOUNCE", "ANNOUNCE_V2"]: + self._data[source.infuse_id]["application"] = f"0x{t.application:08x}" for field in t.iter_fields(nested_iter=False): if isinstance(field.val, structs.tdf_struct_mcuboot_img_sem_ver): diff --git a/src/infuse_iot/tools/localhost/index.html b/src/infuse_iot/tools/localhost/index.html index d833adb..9e8ddd5 100644 --- a/src/infuse_iot/tools/localhost/index.html +++ b/src/infuse_iot/tools/localhost/index.html @@ -117,7 +117,7 @@

Table Control

); const uniqueApplications = [ - ...new Set(rows.map(obj => obj.ANNOUNCE?.application).filter(app => app !== undefined).sort()) + ...new Set(rows.map(obj => obj.application).filter(app => app !== undefined).sort()) ]; if (!arraysEqual(currentApps, uniqueApplications)) { versions = uniqueApplications.map((v, idx) => { return { id: `row-${idx}`, name: v, checked: true }; }) @@ -159,7 +159,7 @@

Table Control

enabledApps = currentApps.filter(a => appShow[a]); dataTable.clearFilter(); - dataTable.setFilter("ANNOUNCE.application", "in", enabledApps); + dataTable.setFilter("application", "in", enabledApps); filtering_update = false; }