From bf74bbdc7851af68cd578fbd51aeadfe8d833d40 Mon Sep 17 00:00:00 2001 From: Audric Date: Mon, 20 Apr 2026 14:54:19 +0200 Subject: [PATCH 1/2] satellite: expose active TG filter in statusJson MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a satellite advertises a SATELLITE_FILTER via MsgTrunkFilter, the parent-side SatelliteLink now emits it as satellites[].filter in its JSON status. Key is omitted when no filter is set (empty => all TGs pass), so existing consumers that check for its absence keep working. This single field propagates to three observer surfaces for free: - HTTP /status — Reflector::refreshStatus() copies statusJson() into m_status["satellites"]. - Redis live snapshot — statusChanged -> publishSatelliteStatusToRedis reserializes statusJson() to live:satellite: on every filter change (handleMsgTrunkFilter already emits statusChanged). - MQTT retained "status" topic — the periodic publishFullStatus(m_status) timer includes the same JSON. Passive propagation only — no dedicated MQTT filter-change event. Follow-up work if active notifications are needed: emit a satellite//filter topic from handleMsgTrunkFilter. --- src/svxlink/reflector/SatelliteLink.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/svxlink/reflector/SatelliteLink.cpp b/src/svxlink/reflector/SatelliteLink.cpp index 766c249..4664137 100644 --- a/src/svxlink/reflector/SatelliteLink.cpp +++ b/src/svxlink/reflector/SatelliteLink.cpp @@ -54,6 +54,11 @@ Json::Value SatelliteLink::statusJson(void) const active_tgs.append(tg); } obj["active_tgs"] = active_tgs; + + if (!m_tg_filter.empty()) + { + obj["filter"] = m_tg_filter.toString(); + } return obj; } /* SatelliteLink::statusJson */ From f24098cd05848594e4c90424a4a51c10d23ce8f4 Mon Sep 17 00:00:00 2001 From: Audric Date: Mon, 20 Apr 2026 14:55:09 +0200 Subject: [PATCH 2/2] test: satellite filter visible in /status (test_16c) Verifies three behaviors in one test against the HTTP /status endpoint: 1. The "filter" key is ABSENT when no filter has been sent. 2. After sat.send_filter("222"), /status.satellites[SAT_ID].filter converges to "222" within the wait_until timeout. 3. After sat.send_filter(""), the key is dropped again. Covers the passive observability path added in the prior commit. Since all three observer surfaces (HTTP, MQTT, Redis) serialize the same statusJson(), the HTTP check is representative. --- tests/test_trunk.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test_trunk.py b/tests/test_trunk.py index fdf7ebb..68c4a7a 100644 --- a/tests/test_trunk.py +++ b/tests/test_trunk.py @@ -1327,6 +1327,51 @@ class TestTrunkIntegration(unittest.TestCase): sender.close() sat.close() + # ------------------------------------------------------------------ + # Test 16c: Satellite TG filter surfaces in /status + # ------------------------------------------------------------------ + def test_16c_satellite_filter_in_status(self): + """After the satellite sends MsgTrunkFilter, the parent's /status + endpoint must expose the active filter string under + satellites[].filter. Since /status, MQTT retained status, and + the Redis live snapshot all serialize SatelliteLink::statusJson(), + exposing the field here covers all three observer surfaces. + """ + sat = SatellitePeer() + sat.connect_satellite() + sat.handshake() + + def sat_present(): + status = get_status(*_http(self.PRIMARY)) + return SAT_ID in status.get("satellites", {}) + wait_until(sat_present, timeout=5.0, + msg="satellite not visible in /status") + + # No filter set yet → the key should be absent (not empty string) + status = get_status(*_http(self.PRIMARY)) + self.assertNotIn("filter", status["satellites"][SAT_ID], + "filter key should be absent when no SATELLITE_FILTER is set") + + # Send a filter; statusChanged(this) on handleMsgTrunkFilter should + # make the key appear on the next /status fetch. + sat.send_filter("222") + + def filter_visible(): + status = get_status(*_http(self.PRIMARY)) + return status.get("satellites", {}).get(SAT_ID, {}).get("filter") == "222" + wait_until(filter_visible, timeout=5.0, + msg="filter did not appear in /status.satellites[SAT_ID]") + + # Clearing the filter (empty string) should drop the key. + sat.send_filter("") + def filter_cleared(): + status = get_status(*_http(self.PRIMARY)) + return "filter" not in status.get("satellites", {}).get(SAT_ID, {}) + wait_until(filter_cleared, timeout=5.0, + msg="filter key not cleared after empty filter sent") + + sat.close() + # ------------------------------------------------------------------ # Test 17: Trunk talker notification reaches monitoring clients # ------------------------------------------------------------------