From bd31369e5e6f9917ee0ed6c9f3378a7e966ed7b6 Mon Sep 17 00:00:00 2001 From: Audric Date: Sun, 19 Apr 2026 00:45:44 +0200 Subject: [PATCH] docs: sync README / MQTT / TWIN / TESTS with v1.3.3 - README /status example adds twin{...}, trunks[X].nodes and muted; node-list bullet now mentions twin partner as well as trunk peers. - docs/MQTT.md documents the nodes/local + nodes/ topics (retained) that were already being published but absent from the docs; the QoS/retain table is extended accordingly. - docs/TWIN_PROTOCOL.md status line bumped to v1.3.x+twin2 and test count updated (8 -> 11) to include the partner-roster test. - tests/TESTS.md bumps the trunk suite (31 -> 32) and twin suite (10 -> 11) counts and adds entries for the two new roster tests. --- README.md | 36 ++++++++++++++++++++++++++++++------ docs/MQTT.md | 32 ++++++++++++++++++++++++++++++++ docs/TWIN_PROTOCOL.md | 5 +++-- tests/TESTS.md | 10 ++++++---- 4 files changed, 71 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e1cc7a5..9d8f112 100644 --- a/README.md +++ b/README.md @@ -61,9 +61,12 @@ automatically. `[TRUNK_x]` section, with a shared filter syntax (exact, `24*` prefix, `2427-2438` range). Reloadable at runtime via the PTY admin channel - **Node-list broadcasting** — on local client login / logout / TG change the - reflector debounces (500 ms) and emits a `MsgTrunkNodeList` to every peer - carrying callsign + current TG + optional lat/lon/QTH. Inbound lists are - republished via MQTT under `nodes/`; the local list under + reflector debounces (500 ms) and emits a `MsgTrunkNodeList` to every trunk + peer (and, when configured, the `[TWIN]` partner) carrying callsign + + current TG + optional lat/lon/QTH. Inbound lists from trunk peers or twin + partners are republished via MQTT under `nodes/`, Redis under + `live:peer_node:…`, and surfaced in `/status` under + `trunks[SECTION].nodes` / `twin.nodes`. The local list is published on `nodes/local` - **PTY admin channel** — live commands written to `/dev/shm/reflector_ctrl`: `TRUNK MUTE|UNMUTE
` (applied on the inbound audio path), @@ -415,9 +418,28 @@ static configuration in a single response: "active_talkers": { "222": "IW1GEU", "25": "SM0ABC" - } + }, + "muted": [], + "nodes": [ + {"callsign": "SM0ABC", "tg": 25}, + {"callsign": "SM1DEF", "tg": 2} + ] } }, + "twin": { + "host": "reflector-partner.example.com", + "port": 5304, + "connected": true, + "outbound_connected": true, + "outbound_hello": true, + "inbound_connected": true, + "inbound_hello": true, + "local_prefix": "1", + "peer_id": "TWIN", + "nodes": [ + {"callsign": "IW1XYZ", "tg": 1234} + ] + }, "satellites": { "my-satellite": { "id": "my-satellite", @@ -433,8 +455,10 @@ static configuration in a single response: ``` `active_talkers` lists TGs with an active remote talker at query time (both -prefix-based and cluster TGs). `satellites` and `satellite_server` appear only -when applicable. +prefix-based and cluster TGs). `trunks[SECTION].nodes` carries the roster +received from each trunk peer; `twin.nodes` carries the partner's roster +when a `[TWIN]` section is configured. `twin`, `satellites`, and +`satellite_server` appear only when applicable. --- diff --git a/docs/MQTT.md b/docs/MQTT.md index 6c0ff11..4d32034 100644 --- a/docs/MQTT.md +++ b/docs/MQTT.md @@ -130,6 +130,36 @@ Down payload: {} ``` +### Node lists + +Published when the local node roster changes (debounced 500 ms after +client login / logout / TG change) and when a roster arrives from a +remote peer. + +``` +{TOPIC_PREFIX}/nodes/local # this reflector's connected clients +{TOPIC_PREFIX}/nodes/ # roster mirrored from a trunk peer + # or [TWIN] partner +``` + +Payload: +```json +{ + "timestamp": 1712345678, + "nodes": [ + {"callsign": "ON4ABC", "tg": 2620, "qth_name": "Brussels", + "lat": 50.85, "lon": 4.35}, + {"callsign": "IK1XYZ", "tg": 2221} + ] +} +``` + +`lat`, `lon`, and `qth_name` are omitted when the node has not supplied +them. For trunk peers `` comes from the peer's `PEER_ID` (or +section name as fallback); for `[TWIN]` partners the id is `TWIN`. +Both topics are published with **retain** enabled so late-joining +subscribers see the last-known roster immediately. + ### Periodic full status Published at the configured `STATUS_INTERVAL` (default every 1 second). The @@ -153,6 +183,8 @@ subscribers immediately receive the last known state. | `client/.../disconnected` | 0 | No | | `client/.../rx` | 0 | No | | `trunk/...` | 0 | No | +| `nodes/local` | 0 | **Yes** | +| `nodes/` | 0 | **Yes** | | `status` | 0 | **Yes** | QoS 0 (fire-and-forget) is used throughout. Event messages are ephemeral — a diff --git a/docs/TWIN_PROTOCOL.md b/docs/TWIN_PROTOCOL.md index b9d7077..2ebaa4f 100644 --- a/docs/TWIN_PROTOCOL.md +++ b/docs/TWIN_PROTOCOL.md @@ -1,8 +1,9 @@ # GeuReflector — Twin (HA-Pair) Protocol -> **Status:** Implemented in v1.3.x+twin1. See §Implementation for +> **Status:** Implemented in v1.3.x+twin2. See §Implementation for > what shipped and `tests/test_twin.py` for integration test coverage -> (8 tests including an end-to-end V2-client audio-mirror path). +> (11 tests including end-to-end V2-client audio mirroring and +> partner-roster propagation into `/status.twin.nodes`). ## Motivation diff --git a/tests/TESTS.md b/tests/TESTS.md index 01df566..a7d13f5 100644 --- a/tests/TESTS.md +++ b/tests/TESTS.md @@ -5,8 +5,8 @@ The integration tests verify the trunk protocol, satellite links, twin (HA-pair) protocol, Redis-backed config store, and end-to-end audio routing by spinning up reflector meshes in Docker Compose and connecting fake peers and clients from a Python test harness. `run_tests.sh` runs in **two phases**: -1. A 3-reflector trunk mesh + a satellite-mode reflector exercising `test_trunk.py` (31 tests). -2. A 4-reflector twin topology exercising `test_twin.py` (10 tests). +1. A 3-reflector trunk mesh + a satellite-mode reflector exercising `test_trunk.py` (32 tests). +2. A 4-reflector twin topology exercising `test_twin.py` (11 tests). A separate harness (`run_redis_tests.sh`) runs `test_redis.py` (13 tests) against a single-reflector + Redis stack. See [Redis Integration Tests](#redis-integration-tests) below. @@ -22,11 +22,11 @@ bash run_tests.sh This will: 1. Generate the default configs and `docker-compose.test.yml` from `topology.py` 2. Build and start the 3-reflector mesh -3. Run 31 automated trunk/satellite/MQTT tests (`test_trunk.py`) +3. Run 32 automated trunk/satellite/MQTT tests (`test_trunk.py`) 4. Enter an interactive prompt to manually test any TG number 5. Tear down the default mesh 6. Regenerate with `--topology twin` (4-reflector twin topology) -7. Rebuild the mesh and run 10 automated twin-protocol tests (`test_twin.py`) +7. Rebuild the mesh and run 11 automated twin-protocol tests (`test_twin.py`) 8. Restore the default topology files and tear everything down To regenerate configs without running tests: @@ -212,6 +212,7 @@ each filter independently of the other trunk fixtures. | # | Test | What it verifies | |---|------|-----------------| | 27 | `MsgTrunkNodeList` emission | Connecting a V2 client triggers a debounced node-list send to trunk peers; the harness receives a `MsgTrunkNodeList` (type 121) containing the new client | +| 27b | Trunk peer roster in `/status` | A client authenticated on the primary reflector appears in a peer's `/status.trunks[SECTION].nodes`; disappears after disconnect | ### Twin Protocol (HA-pair) @@ -229,6 +230,7 @@ Run separately on the twin topology (`test_twin.py`). See `docs/TWIN_PROTOCOL.md | 8 | Audio mirror end-to-end | A V2 client on ref1 transmits on TG 26201; a V2 client on ref2 receives UDP audio and a flush marker, exercising the full `TGHandler.talkerUpdated` → `TwinLink.onLocalAudio` → `MsgTrunkAudio` → `broadcastUdpMsg` path | | 9 | Satellite + twin handshake | A satellite connects to ref1 (the `TWIN_SATELLITE_PARENT`) and is listed in `/status.satellites` after the two-way hello | | 10 | Satellite sees twin-mirrored audio | A V2 client on ref2 transmits on TG 26201; the satellite attached to ref1 receives `TalkerStart` and `MsgTrunkAudio` — verifies `TwinLink::handleMsgTrunkAudio` re-forwards to satellites, not just talker state | +| 11 | Twin partner roster in `/status` | A V2 client authenticated on ref1 appears under ref2's `/status.twin.nodes`; disappears after disconnect. Exercises `MsgTrunkNodeList` over the `[TWIN]` socket and `TwinLink::m_partner_nodes` | ## Redis Integration Tests