LegacyAdapter already translates incoming v1 requests to v2 internal commands, but v2 handler replies used v2-only conventions (namespaced type strings, data nested under "data", UPPERCASE status enum, object-keyed strike_counters). A v1-only Flutter app polling system.status never recognised the reply, hit its own 5s request timeout, and its catch block explicitly set the UI to "unavailable" — even though the device was playing correctly and had already replied in time. Not a connectivity bug; a pure reply-schema mismatch. Adds LegacyResponseAdapter, the reply-side mirror of LegacyAdapter: a narrow, allowlisted translator that rewrites a CommandResult back into v1 shape, but only for replies to requests whose original envelope version was 1. Wired into WebSocket, MQTT, and HTTP's general command path by capturing envelope.version before CommandBus::dispatch() overwrites it to 2. v2 clients and all other reply types are untouched, byte-for-byte. This is deliberately temporary migration scaffolding for the v1→v2 tablet rollout window, not new permanent architecture — designed to be deleted alongside LegacyAdapter in one PR once fleet telemetry shows zero v1 requests. Full rationale and removal steps in docs/architecture/legacy-response-adapter.md. Verified: pio run across all four environments (vesper-std-v1, agnus-v1, agnus-mini-v1, bespoke-rs485-v1). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Transport Layer
Summary
The Transport layer adapts five communication protocols — MQTT, WebSocket, HTTP, UART, and the settings web server — to a common interface consumed by the CommandBus. Each transport is responsible for receiving raw input from its protocol, parsing it into a CommandEnvelope, injecting a reply lambda that routes the response back over the same protocol, and calling CommandBus::dispatch(). For unsolicited events, the bus calls each transport's broadcast() method. Transports have no knowledge of what handlers do; handlers have no knowledge of which transport a command arrived on. The transport identity is recorded in CommandEnvelope::transport for the rare cases where a handler needs it (e.g. identify is WebSocket-only).
ITransport Interface
All transports implement ITransport:
| Method | Description |
|---|---|
virtual void begin() = 0 |
Initialise the transport. Called once from CommunicationRouter::begin(). |
virtual void loop() = 0 |
Service the event loop. No-op for event-driven transports; required for UART polling. |
virtual bool isHealthy() const = 0 |
Health check used by HealthMonitor / CommunicationRouter::isHealthy(). |
virtual String name() const = 0 |
Human-readable name for logging (e.g. "MQTT", "WebSocket"). |
virtual void broadcast(const String& msg) = 0 |
Push a pre-serialised JSON string to all clients. No-op for stateless transports (HTTP, WebServerTransport). |
Transports at a Glance
| Transport | Protocol | Endpoint / Topic | Persistent connection | Broadcast |
|---|---|---|---|---|
MQTTTransport |
MQTT (AsyncMqttClient) | vesper/{uid}/control (RX), vesper/{uid}/data (TX) |
Yes (broker) | Yes — publishes to data topic |
WebSocketTransport |
WebSocket | /ws |
Yes (per client) | Yes — all or targeted clients |
HTTPTransport |
HTTP REST | POST /api/command, GET /api/ping, GET /api/status |
No | No-op |
UARTTransport |
UART (Serial2) | GPIO 12 TX / 13 RX @ 115200 | Yes (slave device) | Yes — sends to UART slave |
WebServerTransport |
HTTP (settings UI) | GET /settings, POST /api/set-mode, POST /api/reboot |
No | No-op |
See the subdirectory README for each transport for details.