From bbd356d8462bb41f342d6a5973f7c4e5122a98f4 Mon Sep 17 00:00:00 2001 From: bonamin Date: Thu, 15 Oct 2026 22:53:43 +0300 Subject: [PATCH] docs(ApiReference): add mqtt.status; playback/reports QoS 1 (confirmed), other outbound topics QoS 0 Mirrors firmware F-071..F-073 (project-vesper, v2.4.0): - New mqtt.status command (MQTT connection health: connect/disconnect counters, last disconnect reason, forced self-recovery resets and reason, resent_messages). - status/playback and control/reports are QoS 1 with PUBACK tracking (playback republished on reconnect, reports resent); control/ack, alerts and info are QoS 0. Heartbeat unchanged (QoS 1). Verified the page parses with esbuild. Co-Authored-By: Claude Opus 5.5 --- .../developer/ApiReferencePage.jsx | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/engineering/developer/ApiReferencePage.jsx b/frontend/src/pages/engineering/developer/ApiReferencePage.jsx index 8e91458..e7d12af 100644 --- a/frontend/src/pages/engineering/developer/ApiReferencePage.jsx +++ b/frontend/src/pages/engineering/developer/ApiReferencePage.jsx @@ -16,12 +16,12 @@ import Tabs from '@/components/ui/Tabs' // control/command + control/ack which share one switch ("command"). const TRANSPORTS_V2 = [ { transport: 'MQTT', address: 'vesper/{device_id}/control/command', direction: 'Inbound', switch: 'command', notes: 'Read-only from the board\'s perspective — commands in. Replies go to control/ack. Optional req_id for correlation.' }, - { transport: 'MQTT', address: 'vesper/{device_id}/control/ack', direction: 'Outbound, QoS 1', switch: 'command', notes: 'Strictly replies to commands (incl. pong) — nothing unsolicited is ever published here. Echoes req_id when the request sent one.' }, - { transport: 'MQTT', address: 'vesper/{device_id}/control/reports', direction: 'Outbound, QoS 1', switch: 'reports', notes: 'Critical, unsolicited, time-sensitive board-initiated events (bell_overload, playback_failed). Not retained. The phone app should subscribe for playback_failed.' }, + { transport: 'MQTT', address: 'vesper/{device_id}/control/ack', direction: 'Outbound, QoS 0', switch: 'command', notes: 'Strictly replies to commands (incl. pong) — nothing unsolicited is ever published here. Echoes req_id when the request sent one.' }, + { transport: 'MQTT', address: 'vesper/{device_id}/control/reports', direction: 'Outbound, QoS 1 (confirmed, resent after reconnect)', switch: 'reports', notes: 'Critical, unsolicited, time-sensitive board-initiated events (bell_overload, playback_failed). Not retained. The phone app should subscribe for playback_failed.' }, { transport: 'MQTT', address: 'vesper/{device_id}/status/heartbeat', direction: 'Outbound, retained, QoS 1', switch: 'heartbeat', notes: 'Every 30 s. Also carries LWT — broker publishes {"state":"offline","ok":false} on an unclean disconnect.' }, - { transport: 'MQTT', address: 'vesper/{device_id}/status/playback', direction: 'Outbound, retained, QoS 1', switch: 'playback', notes: 'Playback state transitions (loading/playing/paused/stopping/idle) with pid, speed, duration, started_at, source, ts. Published on transition, not polled — plus on every MQTT (re)connect with the current real state, so a stale retained "playing" never outlives a reboot. Source of truth for what the board is doing.' }, - { transport: 'MQTT', address: 'vesper/{device_id}/system/alerts', direction: 'Outbound, retained until cleared, QoS 1', switch: 'alerts', notes: 'Subsystem state changes (WARNING / CRITICAL / FAILED / CLEARED). Published on transition only.' }, - { transport: 'MQTT', address: 'vesper/{device_id}/system/info', direction: 'Outbound, retained, QoS 1', switch: 'info', notes: 'Discrete system events, e.g. boot_report on every boot.' }, + { transport: 'MQTT', address: 'vesper/{device_id}/status/playback', direction: 'Outbound, retained, QoS 1 (confirmed)', switch: 'playback', notes: 'Playback state transitions (loading/playing/paused/stopping/idle) with pid, speed, duration, started_at, source, ts. Published on transition, not polled — plus on every MQTT (re)connect with the current real state, so a stale retained "playing" never outlives a reboot. Source of truth for what the board is doing.' }, + { transport: 'MQTT', address: 'vesper/{device_id}/system/alerts', direction: 'Outbound, retained until cleared, QoS 0', switch: 'alerts', notes: 'Subsystem state changes (WARNING / CRITICAL / FAILED / CLEARED). Published on transition only.' }, + { transport: 'MQTT', address: 'vesper/{device_id}/system/info', direction: 'Outbound, retained, QoS 0', switch: 'info', notes: 'Discrete system events, e.g. boot_report on every boot.' }, { transport: 'MQTT', address: 'vesper/{device_id}/system/logs', direction: 'Outbound, QoS 0', switch: 'logs', notes: 'Full log stream, mirrors serial output. Also gated by the log.set_mqtt level, independently of this switch.' }, { transport: 'MQTT', address: 'vesper/{device_id}/system/metrics', direction: 'Outbound, QoS 0', switch: 'metrics', notes: 'Structured telemetry every 5 min — CPU temp, WiFi/OTA state, stack high-water marks, bell strike/heat data.' }, { transport: 'WebSocket', address: 'ws://{device_ip}/ws', direction: 'Bidirectional', switch: null, notes: 'Send identify on connect. Missing "v" defaults to v1 (legacy adapter). req_id is ignored — replies never carry it.' }, @@ -1086,6 +1086,17 @@ const NAMESPACES = [ example: '{ "v": 2, "cmd": "mqtt.get_config" }', warning: null, }, + { + cmd: 'mqtt.status', + handler: 'MQTTHandler', + transports: ['All'], + description: 'MQTT connection health since boot: connect/disconnect counters, last disconnect reason, and how often the firmware\'s self-recovery had to force a reset. Works on every transport, so send it over WebSocket when the console shows a device offline but the local app still works. *_ago_ms and connected_for_ms are 0 when the event never happened / not connected. last_forced_reset_reason is "connect attempt stuck", "heartbeat PUBACK timeout", "playback PUBACK timeout" or "report PUBACK timeout" (empty if self-recovery never fired). resent_messages counts control/reports messages republished after a reconnect because their PUBACK never came.', + contents: null, + response: '{\n "status": "SUCCESS",\n "type": "mqtt.status",\n "data": {\n "enabled": true,\n "connected": true,\n "connected_for_ms": 5412000,\n "connects": 3,\n "disconnects": 2,\n "reconnect_attempts": 0,\n "last_disconnect_reason": "TCP disconnected",\n "last_disconnect_ago_ms": 5420000,\n "forced_resets": 1,\n "last_forced_reset_reason": "heartbeat PUBACK timeout",\n "last_forced_reset_ago_ms": 5425000,\n "resent_messages": 0,\n "wifi_connected": true,\n "free_heap": 84212\n }\n}', + errors: [], + example: '{ "v": 2, "cmd": "mqtt.status" }', + warning: null, + }, { cmd: 'mqtt.get_topics', handler: 'MQTTHandler', @@ -1923,7 +1934,7 @@ function TransportsV2() { - +
@@ -1944,7 +1955,7 @@ function TransportsV2() {
- +