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
18 changes: 11 additions & 7 deletions src/infuse_iot/tools/localhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/infuse_iot/tools/localhost/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h2>Table Control</h2>
);

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 }; })
Expand Down Expand Up @@ -159,7 +159,7 @@ <h2>Table Control</h2>
enabledApps = currentApps.filter(a => appShow[a]);

dataTable.clearFilter();
dataTable.setFilter("ANNOUNCE.application", "in", enabledApps);
dataTable.setFilter("application", "in", enabledApps);

filtering_update = false;
}
Expand Down