docs: peer-client liveness MQTT topics + protocol additions
- docs/MQTT.md: new peer/<id>/client/<call>/* topics, retained-rx migration, MQTT_NAME twin-mode requirement, retained-store growth note (housekeeping deferred per Task 11). - docs/PEER_PROTOCOL.md: MsgPeerClient* types 125-128 with routing (satellite+twin only, not trunk). - CLAUDE.md: refresh trunk/peer message overview to reflect rename and new types.
This commit is contained in:
1 parent
db16676c16
commit
c19f7d7752
2 files changed
+212
-13
No files matched your search
+165
-12
@@ -53,7 +53,9 @@ use `TOPIC_PREFIX/#` to receive everything, or subscribe to specific subtrees.
|
||||
|
||||
### Talker events
|
||||
|
||||
Published when a client or trunk peer starts or stops talking on a talk group.
|
||||
Published when a **locally connected** client starts or stops talking on a talk
|
||||
group. Peer-side talker events are published under the `peer/` subtree (see
|
||||
below).
|
||||
|
||||
```
|
||||
{TOPIC_PREFIX}/talker/{tg}/start
|
||||
@@ -65,12 +67,15 @@ Payload:
|
||||
{"callsign": "ON4ABC", "source": "local"}
|
||||
```
|
||||
|
||||
`source` is `"local"` when the talker is a directly connected client, or
|
||||
`"trunk"` when the talker is on a remote reflector reached via trunk.
|
||||
These topics are **local-only** — they fire only for clients directly connected
|
||||
to this reflector. Non-retained. Dashboards that want every talker on the mesh
|
||||
(local + peer) must also subscribe to `peer/+/talker/+/start` and
|
||||
`peer/+/talker/+/stop` (see [Per-peer client topics](#per-peer-client-topics)).
|
||||
|
||||
### Client events
|
||||
|
||||
Published when a SvxLink node authenticates or disconnects.
|
||||
Published when a SvxLink node authenticates or disconnects from **this**
|
||||
reflector.
|
||||
|
||||
```
|
||||
{TOPIC_PREFIX}/client/{callsign}/connected
|
||||
@@ -87,10 +92,14 @@ Disconnected payload:
|
||||
{}
|
||||
```
|
||||
|
||||
Both are non-retained. On disconnect, the reflector also clears the retained
|
||||
`client/{callsign}/rx` and `client/{callsign}/status` topics (zero-length
|
||||
retained publish).
|
||||
|
||||
### Receiver (RX) status events
|
||||
|
||||
Published on every signal strength update from a connected node. Each node can
|
||||
have multiple receivers — the payload contains all of them keyed by receiver ID.
|
||||
Published on signal-strength updates from a connected node. Each node can have
|
||||
multiple receivers — the payload contains all of them keyed by receiver ID.
|
||||
|
||||
```
|
||||
{TOPIC_PREFIX}/client/{callsign}/rx
|
||||
@@ -109,6 +118,99 @@ Payload:
|
||||
| `sql_open` | boolean | Whether the squelch is open |
|
||||
| `active` | boolean | Whether the receiver is actively selected |
|
||||
|
||||
This topic is **retained** (changed from non-retained in the peer-client
|
||||
liveness update — see migration note below). It is debounced at 500 ms per
|
||||
callsign to avoid excessive broker write churn from 50 Hz rx-update rates.
|
||||
|
||||
### Per-client status events
|
||||
|
||||
Published when the reflector's internal per-client status blob changes (receiver
|
||||
configuration, QTH data, monitored TGs, etc.).
|
||||
|
||||
```
|
||||
{TOPIC_PREFIX}/client/{callsign}/status
|
||||
```
|
||||
|
||||
Payload: the same rich per-client JSON blob that appears inside `nodes/local`
|
||||
under the node's callsign key. **Retained.** Cleared on client disconnect.
|
||||
|
||||
This is new in the peer-client liveness update. Previously the status blob was
|
||||
only accessible via the full `nodes/local` snapshot; this topic surfaces it
|
||||
per-client so dashboards can subscribe per-callsign.
|
||||
|
||||
### Per-peer client topics
|
||||
|
||||
When this reflector is connected to a satellite or twin partner, it republishes
|
||||
per-client liveness events received from that peer under its own MQTT broker.
|
||||
|
||||
```
|
||||
{TOPIC_PREFIX}/peer/{peer_id}/client/{callsign}/connected
|
||||
{TOPIC_PREFIX}/peer/{peer_id}/client/{callsign}/disconnected
|
||||
{TOPIC_PREFIX}/peer/{peer_id}/client/{callsign}/rx
|
||||
{TOPIC_PREFIX}/peer/{peer_id}/client/{callsign}/status
|
||||
{TOPIC_PREFIX}/peer/{peer_id}/talker/{tg}/start
|
||||
{TOPIC_PREFIX}/peer/{peer_id}/talker/{tg}/stop
|
||||
```
|
||||
|
||||
`{peer_id}` is the satellite's configured ID (or twin's `MQTT_NAME`).
|
||||
|
||||
**Routing:** these topics fire only for satellite and twin links. Trunk peers
|
||||
continue to exchange only `MsgPeerNodeList` snapshots and talker events — they
|
||||
do not emit `MsgPeerClient*` messages. Future trunk-axis enablement is a
|
||||
purely additive change.
|
||||
|
||||
| Topic | Retained | Notes |
|
||||
|-------|----------|-------|
|
||||
| `peer/.../client/.../connected` | No | Fired when peer's client authenticates |
|
||||
| `peer/.../client/.../disconnected` | No | Fired on peer client disconnect |
|
||||
| `peer/.../client/.../rx` | **Yes** | 500 ms sender-debounced rx blob |
|
||||
| `peer/.../client/.../status` | **Yes** | Rich status blob (same format as local `client/.../status`) |
|
||||
| `peer/.../talker/.../start` | No | Peer-namespaced talker start |
|
||||
| `peer/.../talker/.../stop` | No | Peer-namespaced talker stop |
|
||||
|
||||
`connected` payload:
|
||||
```json
|
||||
{"tg": 2626, "ip": "10.0.0.5"}
|
||||
```
|
||||
|
||||
`disconnected` payload:
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
`rx` and `status` payloads are JSON strings with the same schema as their
|
||||
local equivalents (`client/.../rx` and `client/.../status`).
|
||||
|
||||
**Retained-store growth note.** When a peer client disconnects, the retained
|
||||
`peer/{peer_id}/client/{callsign}/rx` and `.../status` topics survive in the
|
||||
broker until cleared. The reflector **does not automatically clear** them on
|
||||
peer disconnect — this cleanup is deferred (a libmosquitto thread-safety issue
|
||||
blocks automatic in-process clearing; tracked as a future improvement).
|
||||
Dashboards should correlate rx/status topics with the current `nodes/{peer_id}`
|
||||
snapshot to suppress display of callsigns no longer in that roster. Out-of-band
|
||||
broker housekeeping (e.g. a periodic retained-message audit script) is the
|
||||
recommended hygiene strategy at scale.
|
||||
|
||||
**Dashboard subscription patterns.** To receive every talker on the mesh:
|
||||
```
|
||||
talker/+/start
|
||||
talker/+/stop
|
||||
peer/+/talker/+/start
|
||||
peer/+/talker/+/stop
|
||||
```
|
||||
|
||||
To receive per-client liveness for all peers:
|
||||
```
|
||||
client/+/connected
|
||||
client/+/disconnected
|
||||
client/+/rx
|
||||
client/+/status
|
||||
peer/+/client/+/connected
|
||||
peer/+/client/+/disconnected
|
||||
peer/+/client/+/rx
|
||||
peer/+/client/+/status
|
||||
```
|
||||
|
||||
### Trunk events
|
||||
|
||||
Published when a trunk link's outbound or inbound connection goes up or down.
|
||||
@@ -169,8 +271,8 @@ The payload is identical to the HTTP `/status` JSON response.
|
||||
{TOPIC_PREFIX}/status
|
||||
```
|
||||
|
||||
This is the only topic published with MQTT **retain** enabled, so new
|
||||
subscribers immediately receive the last known state.
|
||||
Published with MQTT **retain** enabled so new subscribers immediately receive
|
||||
the last known state.
|
||||
|
||||
---
|
||||
|
||||
@@ -181,15 +283,66 @@ subscribers immediately receive the last known state.
|
||||
| `talker/...` | 0 | No |
|
||||
| `client/.../connected` | 0 | No |
|
||||
| `client/.../disconnected` | 0 | No |
|
||||
| `client/.../rx` | 0 | No |
|
||||
| `client/.../rx` | 0 | **Yes** ¹ |
|
||||
| `client/.../status` | 0 | **Yes** |
|
||||
| `trunk/...` | 0 | No |
|
||||
| `nodes/local` | 0 | **Yes** |
|
||||
| `nodes/<peer_id>` | 0 | **Yes** |
|
||||
| `peer/.../client/.../connected` | 0 | No |
|
||||
| `peer/.../client/.../disconnected` | 0 | No |
|
||||
| `peer/.../client/.../rx` | 0 | **Yes** ¹ |
|
||||
| `peer/.../client/.../status` | 0 | **Yes** |
|
||||
| `peer/.../talker/...` | 0 | No |
|
||||
| `status` | 0 | **Yes** |
|
||||
|
||||
QoS 0 (fire-and-forget) is used throughout. Event messages are ephemeral — a
|
||||
missed talker start is covered by the next periodic status dump. Retain on
|
||||
`status` ensures late-joining subscribers get a baseline immediately.
|
||||
¹ `rx` topics are debounced at 500 ms per callsign. Native rx-update rate is
|
||||
~50 Hz; debounce keeps roughly 1 in 25 updates. Adequate for human-readable
|
||||
dashboards; a non-debounced data path would be needed for automated signal
|
||||
strength logging (not currently implemented).
|
||||
|
||||
**Migration note for `client/.../rx`:** this topic changed from non-retained to
|
||||
retained in the peer-client liveness update. Existing subscribers see no
|
||||
behavior change (they will receive a retained bootstrap value on subscribe,
|
||||
which they may not have before). Zero-length retained publish on client
|
||||
disconnect clears the entry immediately.
|
||||
|
||||
QoS 0 (fire-and-forget) is used throughout. Missed event messages are covered
|
||||
by the next periodic `status` dump or the retained `nodes/*` snapshots.
|
||||
|
||||
---
|
||||
|
||||
## Twin-mode and `MQTT_NAME`
|
||||
|
||||
When two twin reflectors share a single MQTT broker, each must publish under a
|
||||
disjoint topic subtree. Set `MQTT_NAME` in the `[MQTT]` section on both sides:
|
||||
|
||||
```ini
|
||||
# Reflector A
|
||||
[MQTT]
|
||||
HOST=mqtt.example.com
|
||||
PORT=1883
|
||||
USERNAME=reflector
|
||||
PASSWORD=secret
|
||||
TOPIC_PREFIX=svxreflector
|
||||
MQTT_NAME=refA
|
||||
|
||||
# Reflector B
|
||||
[MQTT]
|
||||
HOST=mqtt.example.com
|
||||
PORT=1883
|
||||
USERNAME=reflector
|
||||
PASSWORD=secret
|
||||
TOPIC_PREFIX=svxreflector
|
||||
MQTT_NAME=refB
|
||||
```
|
||||
|
||||
With `MQTT_NAME` set, every topic is published under
|
||||
`{TOPIC_PREFIX}/{MQTT_NAME}/...` (e.g. `svxreflector/refA/nodes/local`).
|
||||
Without `MQTT_NAME`, topics are published directly under `{TOPIC_PREFIX}/...`.
|
||||
|
||||
**Startup validation:** if a `[TWIN_x]` section is present **and** `[MQTT]` is
|
||||
configured, the reflector aborts startup if `MQTT_NAME` is empty. This prevents
|
||||
silent retained-topic collisions between the two twins on a shared broker.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user