[fix](trx-frontend-http): load the decoders that own the digital modes panels
AIS, VDES and both APRS decoders were listed under the map plugin group alone, so opening Digital modes and clicking AIS or APRS gave an empty panel reading "Connected, listening for packets" while the decodes piled up unprocessed in the plugin runtime. They appeared only if something had opened the Map tab first, which flushed the queue. There is also a map-data group naming exactly those four that nothing loads: the loader is called with tab names and no tab is called map-data. They load with the tab whose panels they fill now. map-core stays lazy, since their calls into it are optional and the Map tab can go on paying for Leaflet by itself. tests/decode-flow.mjs follows a decode from the wire to the map: an AIS vessel and an APRS beacon arrive on /decode, and it asserts both panels fill with the map module confirmed absent, the mini view names the vessel and offers a pin, following that pin lands on /map centred on the vessel, and both decoders leave a marker. Nothing exercised any of this before — the fixture served an empty decode stream, which is how the map links came to be broken for every decoder at once. The fixture stamps decodes as it sends them, since the client prunes anything outside the retention window, and repeats them, since the views collapse by vessel and need more than one frame to behave. Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -65,6 +65,8 @@ export async function startWebFixture({
|
||||
spectrum = false,
|
||||
tx = false,
|
||||
meterDb = -70,
|
||||
decodes = [],
|
||||
mode = "FM",
|
||||
bookmarks = [],
|
||||
bandplan = {},
|
||||
bandplanEnabled = false,
|
||||
@@ -112,7 +114,7 @@ export async function startWebFixture({
|
||||
signal_meter: spectrum,
|
||||
},
|
||||
},
|
||||
status: { freq: { hz: 100_000_000 }, mode: "FM", tx_en: false, vfo: null, tx: null, rx: { sig: meterDb }, lock: null },
|
||||
status: { freq: { hz: 100_000_000 }, mode, tx_en: false, vfo: null, tx: null, rx: { sig: meterDb }, lock: null },
|
||||
// Reported only by SDR backends, and what makes the client show the
|
||||
// squelch control at all.
|
||||
filter: spectrum
|
||||
@@ -161,6 +163,7 @@ export async function startWebFixture({
|
||||
["/status", status],
|
||||
["/bookmarks", bookmarks],
|
||||
["/bandplan.json", bandplan],
|
||||
["/decode/history", {}],
|
||||
["/api/recorder/status", []],
|
||||
["/api/recorder/files", []],
|
||||
]);
|
||||
@@ -228,6 +231,31 @@ export async function startWebFixture({
|
||||
request.on("close", () => clearInterval(timer));
|
||||
return;
|
||||
}
|
||||
// Decodes arrive on this stream in the server's own shape: a routing
|
||||
// "type" naming the decoder, snake_case fields inside. The mini views, the
|
||||
// map markers and the history all hang off it, and serving nothing left
|
||||
// every one of them untested.
|
||||
if (url.pathname === "/decode") {
|
||||
response.writeHead(200, {
|
||||
"cache-control": "no-cache",
|
||||
connection: "keep-alive",
|
||||
"content-type": "text/event-stream",
|
||||
});
|
||||
response.write(": decode stream\n\n");
|
||||
// Repeats: a live decoder keeps producing, and the views that collapse
|
||||
// by station or vessel need more than one frame to behave like they do
|
||||
// in front of a radio.
|
||||
let sent = 0;
|
||||
const timer = setInterval(() => {
|
||||
if (!decodes.length) return;
|
||||
const decode = decodes[sent++ % decodes.length];
|
||||
// Stamped as they leave: the client prunes anything older than the
|
||||
// retention window, so a fixed epoch would be dropped on arrival.
|
||||
response.write(`data: ${JSON.stringify({ ts_ms: Date.now(), ...decode })}\n\n`);
|
||||
}, 400);
|
||||
request.on("close", () => clearInterval(timer));
|
||||
return;
|
||||
}
|
||||
if (["/events", "/decode", "/spectrum", "/meter"].includes(url.pathname)) {
|
||||
response.writeHead(200, {
|
||||
"cache-control": "no-cache",
|
||||
|
||||
Reference in New Issue
Block a user