docs(api-reference): audit against real handlers — playback.play/stop, message/data envelope, ~30 missing commands
The API reference had drifted far from the firmware. Rewritten against the handlers' commands() lists, field parsing and CommandResult::err() strings: - Playback: document playback.play / playback.stop (the bare v2 cmd:"playback"+action form returns "Unknown command"; v1 form still works via LegacyAdapter, and is the only form UART's whitelist accepts). List the fields Player::setMelodyAttributes() actually parses (url, not download_url), how mode/duration interact, the legacy segment_duration/total_duration path, sticky fields, and reply type "playback". - Response envelope: message (string) + data (object), status INFO only on WS broadcasts, no "payload" key; req_id is MQTT-only; v defaults per transport; type exceptions (pong/playback/unknown/parse_error/bad_request). - Add missing commands: relay.set_config/test_bell/test_batch, clock.set_config/set_alerts_config/test_c1/test_c2, system.get_config/ get_all/get_telemetry, ota.set_channel, log.get_config, logs.clear, all telemetry.* and bells.*. Remove nonexistent ota.status/ota.check. - Fix wrong fields: clock.set_alerts is camelCase, clock.set_silence is nested, clock.set_time offsets need both fields, clock.set_timezone has no timezone_name, files.download needs download_url, ota.update defaults to "stable", RF play-slot fields are required (duration 0 rejected), fix legacy map to match LegacyAdapter. - mqtt-events.md: fix the control/command example; note nothing calls CommandBus::broadcast(). Topic spec: req_id is MQTT-only today. Doc-only — no catalog entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+464
-635
File diff suppressed because it is too large
Load Diff
@@ -285,16 +285,18 @@ Structured telemetry for fleet-health graphing — not consumed by the phone app
|
|||||||
### Command (inbound)
|
### Command (inbound)
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{ "v": 2, "cmd": "playback", "req_id": "abc123", "contents": { "action": "stop" } }
|
{ "v": 2, "cmd": "playback.stop", "req_id": "abc123" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Reply (outbound)
|
### Reply (outbound)
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{ "status": "SUCCESS", "type": "playback", "req_id": "abc123", "message": "Command executed" }
|
{ "status": "SUCCESS", "type": "playback", "req_id": "abc123", "message": "Playback command executed" }
|
||||||
```
|
```
|
||||||
|
|
||||||
`req_id` only appears in the reply if the request included one. Bus-wide unsolicited broadcasts (`CommandBus::broadcast()`) also publish here, with the same envelope shape and no `req_id` — but purpose-specific events (playback, alerts, reports, metrics) never use this path; they publish directly to their own topics instead.
|
Reply envelope: `status` (`SUCCESS`/`ERROR`), `type`, optional `req_id`, and either `message` (string — text replies and every error) or `data` (object — structured replies). There is no `payload` key. `req_id` only appears in the reply if the request included one. See [api-reference.md](api-reference.md#response-envelope) for the full envelope rules.
|
||||||
|
|
||||||
|
`CommandBus::broadcast()` would also publish here (same envelope, `status: "INFO"`, no `req_id`), but nothing in the firmware calls it today — purpose-specific events (playback, alerts, reports, metrics) publish directly to their own topics.
|
||||||
|
|
||||||
### Malformed input
|
### Malformed input
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ This lets a device "breathe" — a fleet-monitoring-only install with no phone a
|
|||||||
```
|
```
|
||||||
|
|
||||||
- **Always optional.** A request without `req_id` gets a reply without `req_id` — this is deliberate so v1 clients and any caller not fanning requests out over a shared channel keep working unchanged.
|
- **Always optional.** A request without `req_id` gets a reply without `req_id` — this is deliberate so v1 clients and any caller not fanning requests out over a shared channel keep working unchanged.
|
||||||
- **Bus-wide, not MQTT-only.** `req_id` lives on `CommandEnvelope`/`CommandResult` in the shared `CommandBus` core (see [CommandBus](../../src/Communication/CommandBus/README.md)), not bolted onto MQTT alone — the intent is that any transport where multiple logical senders share one channel (multiple devices on one broker; a future multiplexed transport) can use the same mechanism to route replies.
|
- **Bus-wide plumbing, MQTT-only today.** `req_id` lives on `CommandEnvelope`/`CommandResult` in the shared `CommandBus` core (see [CommandBus](../../src/Communication/CommandBus/README.md)), not bolted onto MQTT alone — the intent is that any transport where multiple logical senders share one channel (multiple devices on one broker; a future multiplexed transport) can use the same mechanism to route replies. Only `MQTTTransport` currently reads it from the request; WebSocket, HTTP and UART ignore it and their replies never carry it.
|
||||||
- **No access control yet.** Any caller can set any `req_id` today. If needed later, safeguards (e.g. restricting who may set one, or validating format) can be added without a wire-format change.
|
- **No access control yet.** Any caller can set any `req_id` today. If needed later, safeguards (e.g. restricting who may set one, or validating format) can be added without a wire-format change.
|
||||||
|
|
||||||
## Malformed Input
|
## Malformed Input
|
||||||
|
|||||||
Reference in New Issue
Block a user