feat(MQTT): rebuild topic spec to v2 (F-062)
Full MQTT topic rebuild per docs/reference/vesper_mqtt_topic_spec_v2.md.
Only the MQTT transport path changed — WebSocket, HTTP, and UART are untouched.
- control/command (in) + control/ack (out, strictly replies) replace the old
control/data pair; new control/reports for critical unsolicited events
(bell overload) that don't belong on the strictly-reply ack channel
- status/playback split out for playback transitions only
- status/alerts + status/info renamed to system/alerts + system/info, both
now correctly retained; new system/logs and system/metrics (diagnostics
report moved here from system/info, gained bell strike/heat data)
- LWT registered for the first time — status/heartbeat gets
{"state":"offline","ok":false} on an unclean disconnect; graceful
disconnect (mqtt.disable) announces offline explicitly since LWT doesn't
fire on a clean disconnect
- heartbeat payload flattened, gains independently-derived state/ok fields
(via a new MQTTDriver::setStateProvider() wired from Player+HealthMonitor)
- optional req_id correlation added bus-wide (CommandEnvelope/CommandResult),
not MQTT-only, since any transport with multiple senders sharing one
channel has the same problem. Always optional — v1 clients unaffected.
- per-topic ON/OFF switches (ConfigManager::MqttTopicConfig, 8 flags) as
sub-switches under the existing mqtt.enable/disable master switch, so a
device can breathe by disabling topics it doesn't need. New
mqtt.get_topics/mqtt.set_topics commands; command switch applies live.
Bumped to v2.2.0. Verified: pio run -e vesper-std-v1 -e agnus-v1 both build clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
> Command reference for the Vesper Bell Automation System.
|
||||
> Firmware v2 command bus architecture — all transports, all handlers.
|
||||
> Last updated: 2026-03-16
|
||||
> Last updated: 2026-09-21 (MQTT topic spec v2 — see F-062 in feature-catalog.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -16,6 +16,7 @@ Every command sent to Vesper uses this JSON envelope:
|
||||
{
|
||||
"v": 2,
|
||||
"cmd": "namespace.command",
|
||||
"req_id": "abc123",
|
||||
"contents": { ... }
|
||||
}
|
||||
```
|
||||
@@ -24,6 +25,7 @@ Every command sent to Vesper uses this JSON envelope:
|
||||
|---|---|---|
|
||||
| `v` | int | Protocol version. `2` = current. Omit or set `1` for legacy (LegacyAdapter runs). |
|
||||
| `cmd` | string | `namespace.command` format (e.g. `relay.set_durations`). |
|
||||
| `req_id` | string | Optional. Echoed back on the reply for correlation when a caller shares one channel across multiple requests/senders (e.g. MQTT `control/command`). Omit for a reply with no `req_id` field — fully backward compatible. |
|
||||
| `contents` | object | Command payload. May be omitted if command takes no fields. |
|
||||
|
||||
### Response Envelope
|
||||
@@ -32,23 +34,30 @@ Every command sent to Vesper uses this JSON envelope:
|
||||
{
|
||||
"status": "SUCCESS" | "ERROR",
|
||||
"type": "command_name",
|
||||
"req_id": "abc123",
|
||||
"payload": { ... }
|
||||
}
|
||||
```
|
||||
|
||||
`payload` is command-specific. On error, `payload` typically contains a `"message"` string.
|
||||
`payload` is command-specific. On error, `payload` typically contains a `"message"` string. `req_id` is present only if the request included one.
|
||||
|
||||
---
|
||||
|
||||
## Transports
|
||||
|
||||
MQTT uses the v2 topic set — see [vesper_mqtt_topic_spec_v2.md](vesper_mqtt_topic_spec_v2.md) for the full table, per-topic ON/OFF switches, `req_id` correlation, and LWT. WebSocket, HTTP, and UART are unchanged by the v2 MQTT rebuild.
|
||||
|
||||
| Transport | Address | Direction | Notes |
|
||||
|---|---|---|---|
|
||||
| MQTT | `vesper/{device_id}/control` | Inbound commands | Responses go to `vesper/{device_id}/data` |
|
||||
| MQTT | `vesper/{device_id}/data` | Outbound responses + events | Command replies and bell overload notifications |
|
||||
| MQTT | `vesper/{device_id}/status/heartbeat` | Outbound, retained, QoS 1 | Heartbeat every 30s; server updates last_seen |
|
||||
| MQTT | `vesper/{device_id}/status/alerts` | Outbound, QoS 1 | Subsystem state-change events (published on change only) |
|
||||
| MQTT | `vesper/{device_id}/status/info` | Outbound, QoS 0 | General device state events (playback, reboot reason, etc.) |
|
||||
| MQTT | `vesper/{device_id}/control/command` | Inbound commands | Read-only from the board's perspective. Replies go to `control/ack`. |
|
||||
| MQTT | `vesper/{device_id}/control/ack` | Outbound replies | Strictly request/response — nothing unsolicited |
|
||||
| MQTT | `vesper/{device_id}/control/reports` | Outbound, critical unsolicited events | e.g. bell overload — not retained |
|
||||
| MQTT | `vesper/{device_id}/status/heartbeat` | Outbound, retained, QoS 1 | Heartbeat every 30s + LWT; server updates last_seen |
|
||||
| MQTT | `vesper/{device_id}/status/playback` | Outbound, retained, QoS 1 | Playback transitions only |
|
||||
| MQTT | `vesper/{device_id}/system/alerts` | Outbound, retained until cleared, QoS 1 | Subsystem state-change events (published on change only) |
|
||||
| MQTT | `vesper/{device_id}/system/info` | Outbound, retained, QoS 1 | Discrete device state events (boot report, etc.) |
|
||||
| MQTT | `vesper/{device_id}/system/logs` | Outbound, QoS 0 | Mirrors serial log stream |
|
||||
| MQTT | `vesper/{device_id}/system/metrics` | Outbound, QoS 0 | Structured telemetry every 5 min — fleet-health graphing |
|
||||
| WebSocket | `ws://{device_ip}/ws` | Bidirectional | Requires `identify` on connect |
|
||||
| HTTP | `http://{device_ip}/...` | REST | Web console endpoints |
|
||||
| UART | Hardware serial | Bidirectional | Restricted — whitelist only (see below) |
|
||||
@@ -913,13 +922,54 @@ Enable or disable RF reception at runtime.
|
||||
|
||||
### `mqtt.enable` / `mqtt.disable`
|
||||
|
||||
Enable or disable MQTT connectivity.
|
||||
Enable or disable MQTT connectivity (master switch — disconnects/reconnects the broker entirely). `mqtt.disable` publishes a graceful offline heartbeat before disconnecting.
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "mqtt.enable" }
|
||||
{ "v": 2, "cmd": "mqtt.disable" }
|
||||
```
|
||||
|
||||
### `mqtt.get_config`
|
||||
|
||||
Returns broker connection settings.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Returns | `{ "enabled": true, "host": "72.61.191.197", "port": 1883, "user": "...", "use_ssl": false }` |
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "mqtt.get_config" }
|
||||
```
|
||||
|
||||
### `mqtt.get_topics`
|
||||
|
||||
Returns the current state of all 8 per-topic ON/OFF publish switches. See [vesper_mqtt_topic_spec_v2.md](vesper_mqtt_topic_spec_v2.md#per-topic-onoff-switches).
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Returns | `{ "command": true, "heartbeat": true, "playback": true, "reports": true, "alerts": true, "info": true, "logs": true, "metrics": true }` |
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "mqtt.get_topics" }
|
||||
```
|
||||
|
||||
### `mqtt.set_topics`
|
||||
|
||||
Partial update of the per-topic ON/OFF switches — only send the fields you want to change. These only take effect while `mqtt.enable` (the master switch) is on. `command` gates both `control/command` (subscription) and `control/ack` (replies) together, and applies live without a reconnect.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Optional | Any of `command`, `heartbeat`, `playback`, `reports`, `alerts`, `info`, `logs`, `metrics` (bool) — at least one required |
|
||||
|
||||
```json
|
||||
{ "v": 2, "cmd": "mqtt.set_topics", "contents": { "heartbeat": true, "metrics": false } }
|
||||
```
|
||||
|
||||
| Error | Condition |
|
||||
|---|---|
|
||||
| `"No recognised topic fields in contents (command, heartbeat, playback, reports, alerts, info, logs, metrics)"` | No valid boolean fields present |
|
||||
| `"Topic switches changed but failed to save to SD"` | Applied in RAM but persistence failed |
|
||||
|
||||
---
|
||||
|
||||
## Telemetry Namespace — `TelemetryHandler`
|
||||
@@ -971,66 +1021,18 @@ Get heat load per bell channel, cooling status, and overload flags.
|
||||
|
||||
## MQTT Events (Unsolicited)
|
||||
|
||||
These messages are published by the device without a request. See [mqtt-events.md](mqtt-events.md) for the full AsyncAPI-compatible reference.
|
||||
These messages are published by the device without a request, on the v2 topic set (`control/command`+`control/ack`, `control/reports`, `status/heartbeat`, `status/playback`, `system/alerts`, `system/info`, `system/logs`, `system/metrics`). Full field-level reference, per-topic switches, LWT, and `req_id` correlation: [mqtt-events.md](mqtt-events.md) and [vesper_mqtt_topic_spec_v2.md](vesper_mqtt_topic_spec_v2.md).
|
||||
|
||||
| Topic | When | QoS | Retained | Format |
|
||||
| Topic | When | QoS | Retained | Switch |
|
||||
|---|---|---|---|---|
|
||||
| `vesper/{id}/status/heartbeat` | Every 30s | 1 | yes | Heartbeat envelope |
|
||||
| `vesper/{id}/status/alerts` | On subsystem state change only | 1 | no | Alert envelope |
|
||||
| `vesper/{id}/status/info` | On device state change | 0 | no | Info envelope |
|
||||
| `vesper/{id}/data` | Any command response / bell overload | 0 | no | Standard response envelope |
|
||||
|
||||
### Heartbeat Payload
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "INFO",
|
||||
"type": "heartbeat",
|
||||
"payload": {
|
||||
"device_id": "PV-26B18-VS01R-X7KQA",
|
||||
"firmware_version": "142",
|
||||
"timestamp": "Uptime: 5h 23m 45s",
|
||||
"ip_address": "10.0.0.3",
|
||||
"gateway": "10.0.0.1",
|
||||
"uptime_ms": 19425000,
|
||||
"rssi": -62
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Subscribe to `vesper/+/status/heartbeat` to discover all online devices.
|
||||
|
||||
### Alert Payload (`vesper/{id}/status/alerts`)
|
||||
|
||||
Published only when a subsystem state changes. The server should store the active alert set per device and update the display in place rather than appending a log entry.
|
||||
|
||||
```json
|
||||
{ "subsystem": "FileManager", "state": "WARNING", "msg": "ConfigManager health check failed" }
|
||||
```
|
||||
|
||||
On recovery:
|
||||
```json
|
||||
{ "subsystem": "FileManager", "state": "CLEARED" }
|
||||
```
|
||||
|
||||
`state` values: `WARNING` | `CRITICAL` | `FAILED` | `CLEARED`
|
||||
|
||||
A fault-class boot reset also publishes here — `subsystem: "System"`, e.g.:
|
||||
```json
|
||||
{ "subsystem": "System", "state": "WARNING", "msg": "Device reset due to fault: TASK_WATCHDOG" }
|
||||
```
|
||||
|
||||
### Info Payload (`vesper/{id}/status/info`)
|
||||
|
||||
Published on significant device state changes. `type` identifies the event; `payload` is event-specific.
|
||||
|
||||
```json
|
||||
{ "type": "playback_started", "payload": { "pid": "ormilia_1_8" } }
|
||||
{ "type": "playback_stopped", "payload": {} }
|
||||
{ "type": "boot_reason", "payload": { "reason": "POWERON" } }
|
||||
```
|
||||
|
||||
`boot_reason` is published once, the first time MQTT connects after boot — only for expected reset reasons (`POWERON`, `SOFTWARE`, `DEEPSLEEP_WAKE`, `EXTERNAL_PIN`, `SDIO`, `UNKNOWN`). Fault reasons (`PANIC`, `TASK_WATCHDOG`, `INTERRUPT_WATCHDOG`, `OTHER_WATCHDOG`, `BROWNOUT`) go to `status/alerts` instead (see above).
|
||||
| `vesper/{id}/status/heartbeat` | Every 30s (+ LWT on unclean disconnect) | 1 | yes | `heartbeat` |
|
||||
| `vesper/{id}/status/playback` | On playback transition | 1 | yes | `playback` |
|
||||
| `vesper/{id}/control/reports` | Critical unsolicited events (e.g. bell overload) | 1 | no | `reports` |
|
||||
| `vesper/{id}/system/alerts` | On subsystem state change only | 1 | yes, until cleared | `alerts` |
|
||||
| `vesper/{id}/system/info` | On discrete device state events (e.g. boot report) | 1 | yes | `info` |
|
||||
| `vesper/{id}/system/logs` | Mirrors serial log stream | 0 | no | `logs` |
|
||||
| `vesper/{id}/system/metrics` | Every 5 min — CPU temp, WiFi/OTA state, bell heat | 0 | no | `metrics` |
|
||||
| `vesper/{id}/control/ack` | Reply to every command (strictly request/response) | 1 | no | `command` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user