Files
project-vesper/src/Communication/Transport
bonaminandClaude Sonnet 4.6 7e8d91673f fix: builtin aliases, cmd version default, relay compat, NTP UTC, player guards
BuiltInMelodies (F-018):
- 24 builtin_* UID aliases added for backward compat with old device PIDs
- Two new PROGMEM arrays: builtin_catehetical, builtin_mournfull_toll_alternative
- isBuiltInMelody() helper for lightweight PID existence check
- FileManager download-skip now uses isBuiltInMelody() instead of findMelodyByPID()

Command envelope version default (F-020):
- MQTT, UART, WebSocket transports: missing "v" field defaults to 1 (was 2)
- Fixes legacy adapter rejecting commands from app and Node-RED

RelayHandler v1/v2 compat (F-021):
- set_durations and set_outputs accept both nested {"bells":{...}} (v2)
  and flat {...} (v1) payload shapes

NTP UTC fix (F-019):
- configTime(0,0,ntpServer) fetches raw UTC; stored gmtOffset+dstOffset
  applied manually to epoch before writing RTC
- Eliminates double-offset bug from SDK internal timezone handling

Player guards (F-022):
- speed==0 defaults to 300ms instead of producing silent/broken playback
- calculateProjectedRunTime() guards against singleLoopDuration==0

Telemetry (F-023):
- bellMaxLoad default raised 200→500 to eliminate false overload warnings

Version bump: 2.0.1 → 2.0.3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 09:52:39 +03:00
..
2026-03-14 22:16:03 +02:00

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.