Skip to content

Commit effdddc

Browse files
committed
tools: localhost: handle ANNOUNCE_V2
Handle the `ANNOUNCE_V2` TDF in a similar way to `ANNOUNCE`. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 6452f06 commit effdddc

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/infuse_iot/tools/localhost.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ async def websocket_handler(self, request: BaseRequest):
7676
"field": "infuse_id",
7777
"headerHozAlign": "center",
7878
},
79+
{
80+
"title": "App ID",
81+
"field": "application",
82+
"headerHozAlign": "center",
83+
},
7984
{
8085
"title": "Last Heard",
8186
"field": "time",
@@ -101,11 +106,9 @@ async def websocket_handler(self, request: BaseRequest):
101106
],
102107
}
103108
]
104-
# Put ANNOUNCE TDF first, if it exists
105-
if "ANNOUNCE" in self._columns:
106-
sorted_tdfs = ["ANNOUNCE"] + [v for v in sorted(self._columns) if v != "ANNOUNCE"]
107-
else:
108-
sorted_tdfs = sorted(self._columns)
109+
# Put the announce TDFs first for clarity
110+
priorities = {"ANNOUNCE_V2": 0, "ANNOUNCE": 1}
111+
sorted_tdfs = sorted(self._columns, key=lambda x: priorities.get(x, 2))
109112

110113
for tdf_name in sorted_tdfs:
111114
columns.append(
@@ -190,9 +193,8 @@ def recv_thread(self) -> None:
190193
if source.infuse_id not in self._data:
191194
self._data[source.infuse_id] = {
192195
"infuse_id": f"0x{source.infuse_id:016x}",
196+
"application": "Unknown",
193197
}
194-
# Set default application ID
195-
self._data[source.infuse_id]["ANNOUNCE"] = {"application": "Unknown"}
196198

197199
self._data[source.infuse_id]["time"] = InfuseTime.utc_time_string(time.time())
198200
if source.interface == interface.ID.BT_ADV:
@@ -207,6 +209,8 @@ def recv_thread(self) -> None:
207209
self._columns[t.NAME] = self.tdf_columns(t)
208210
if t.NAME not in self._data[source.infuse_id]:
209211
self._data[source.infuse_id][t.NAME] = {}
212+
if t.NAME in ["ANNOUNCE", "ANNOUNCE_V2"]:
213+
self._data[source.infuse_id]["application"] = f"0x{t.application:08x}"
210214

211215
for field in t.iter_fields(nested_iter=False):
212216
if isinstance(field.val, structs.tdf_struct_mcuboot_img_sem_ver):

src/infuse_iot/tools/localhost/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ <h2>Table Control</h2>
117117
);
118118

119119
const uniqueApplications = [
120-
...new Set(rows.map(obj => obj.ANNOUNCE?.application).filter(app => app !== undefined).sort())
120+
...new Set(rows.map(obj => obj.application).filter(app => app !== undefined).sort())
121121
];
122122
if (!arraysEqual(currentApps, uniqueApplications)) {
123123
versions = uniqueApplications.map((v, idx) => { return { id: `row-${idx}`, name: v, checked: true }; })
@@ -159,7 +159,7 @@ <h2>Table Control</h2>
159159
enabledApps = currentApps.filter(a => appShow[a]);
160160

161161
dataTable.clearFilter();
162-
dataTable.setFilter("ANNOUNCE.application", "in", enabledApps);
162+
dataTable.setFilter("application", "in", enabledApps);
163163

164164
filtering_update = false;
165165
}

0 commit comments

Comments
 (0)