Commit Graph
6 Commits
Author SHA1 Message Date
Audric ccf34adbe6 feat(mqtt): add ts and duration_ms to talker start/stop events
Talker MQTT payloads now carry a Unix-epoch-ms `ts` field on both start
and stop. Stop additionally carries `duration_ms` whenever a matching
start was observed by the same MqttPublisher instance and the resulting
duration is non-negative. Both fields are additive — older consumers
that only read `callsign` continue to work unchanged.

Implementation
- MqttPublisher tracks per-(peer_id, tg) start_ms in a small std::map.
  Local talkers use peer_id="" as the map key. The entry is consumed on
  the matching stop.
- On stop, duration_ms is computed as `now - start_ms`. The field is
  omitted when:
  * no matching start was recorded (e.g. reflector restarted mid-talker)
  * the resulting duration is negative (backwards NTP correction during
    the transmission)
  Both edge cases are documented in docs/MQTT.md.
- Applies symmetrically across the four publish paths:
  onTalkerStart / onTalkerStop / onPeerTalkerStart / onPeerTalkerStop.

Tests
- test_trunk.py::test_18_mqtt_talker_event extended:
  * asserts `ts` is present on start, parses as int, lies within a
    +/- 60s window of the test's local clock.
  * asserts `ts` on stop is >= start ts.
  * asserts `duration_ms` on stop is present, >= the held-talker time
    (~500 ms), and equals stop_ts - start_ts.
- Edge-case behaviour (no-start, backwards clock jump) is guarded in
  code and documented; reaching it from the integration suite would
  require restarting the reflector mid-talker or injecting a clock
  step, so it is not asserted from outside.

Docs
- docs/MQTT.md: payload examples updated for both flat and
  peer-namespaced talker topics; new paragraph spelling out the two
  conditions under which duration_ms is omitted.
- docs/MESSAGING_IDEAS.md: Telegram-bot example extended to also
  handle /stop with a `duration_ms >= 1000` filter (kerchunk
  suppression) and a short note on how `ts`/`duration_ms` map to
  end-to-end pipeline latency and session length.
2026-05-07 17:02:39 +02:00
Audric c19f7d7752 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.
2026-04-29 17:50:31 +02:00
Audric d9ec356f10 mqtt: raise default STATUS_INTERVAL from 1000 ms to 30000 ms
The full-status snapshot is a bootstrap / drift-correction mechanism;
per-event topics (talker, client, trunk, nodes) already deliver every
change live. The retained payload scales with mesh size — at a few
hundred nodes with the rich per-client status blob it is hundreds of
KB, which makes a 1 s republish expensive on broker bandwidth and
reflector CPU. Lower it explicitly via [MQTT] STATUS_INTERVAL only
when a small mesh has a consumer that depends on near-real-time full
snapshots.

Test configs keep STATUS_INTERVAL=1000 to verify retained-status
behaviour in seconds.
2026-04-28 11:30:50 +02:00
Audric bd31369e5e 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/<peer_id> 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.
2026-04-19 00:45:44 +02:00
Audric a2eefac1f2 Add MQTT RX status events and fix periodic status publishing
Periodic MQTT status was missing dynamic fields (trunks, cluster_tgs,
local_prefix, etc.) because they were only rebuilt during HTTP requests.
Extract status-building into refreshStatus() called from both paths.

Add per-client RX status MQTT events (client/{callsign}/rx) published on
every signal strength update, supporting multiple receivers per node.
2026-04-09 12:59:52 +02:00
Audric 483b1ffaa4 Add MQTT documentation to README and docs/MQTT.md 2026-04-08 20:48:37 +02:00