feat(comms): Stages 3–6 — transport layer, router simplification, legacy adapter, WebServerTransport
## Stage 3 — Transport Layer
- MQTTTransport: wraps MQTTAsyncClient, implements ITransport
- WebSocketTransport: wraps WebSocketServer + ClientManager; broadcastToMasters/Secondary
- HTTPTransport: first-class HTTP identity (no more 0xFFFFFFFF fake WS client); registers
POST /api/command, GET /api/ping, GET /api/status; reply lambda captures AsyncWebServerRequest*
- UARTTransport: wraps UARTCommandHandler; UART whitelist enforced before dispatch
## Stage 4 — CommunicationRouter simplification
- Router now owns CommandBus + 4 transports; registerHandlers() wires all 10 domain handlers
- Old CommandHandler marked DEPRECATED on disk, no longer called
- HTTPRequestHandler no longer instantiated (replaced by HTTPTransport)
- ResponseBuilder::fromResult() factory method added
- main.cpp: all setXxxReference() calls moved before begin(); HealthMonitor + OutputManager wired
## Stage 5 — Legacy Adapter
- LegacyAdapter.hpp/cpp: 35 v1→v2 command mappings (simple 1:1, action-based, boolean splits)
- CommandBus::dispatch() applies translation when envelope.version == 1
## Stage 6 — WebServerTransport (4th transport, absorbs SettingsWebServer)
- WebServerTransport implements ITransport; registered in CommunicationRouter::begin()
- GET /settings: HTML settings page (PROGMEM template unchanged)
- POST /api/set-mode: routes network.set_config {permanent_ap_mode} through CommandBus
- POST /api/reboot: routes system.restart through CommandBus
- NetworkHandler::handleSetConfig: handles permanent_ap_mode field independently
- SettingsWebServer member removed from CommunicationRouter; src/SettingsWebServer/ is dead
code, deletable in a follow-up PR once SettingsPage.h is moved
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// LegacyAdapter — v1 → v2 command translation
|
||||
//
|
||||
// When a client sends { "v": 1 } (or omits "v"), the envelope arrives here
|
||||
// before reaching the CommandBus registry. The adapter maps the old flat/
|
||||
// umbrella command shape to the new namespaced v2 command.
|
||||
//
|
||||
// Translation logic:
|
||||
// 1. If the v1 message has an "action" field inside contents, combine
|
||||
// cmd + action → v2 flat command name, then strip "action" from contents.
|
||||
// 2. If no action, map the top-level cmd name directly (e.g. "ping" → "ping").
|
||||
// 3. Special cases:
|
||||
// - clock_setup → set_enabled uses contents["enabled"] bool to pick
|
||||
// clock.enable vs clock.disable
|
||||
// - system → set_mqtt_enabled uses contents["enabled"] bool to pick
|
||||
// mqtt.enable vs mqtt.disable
|
||||
// - system_info → sync_time_to_lcd is remapped to system.get_time
|
||||
// (LCD now uses request/response; old push model retired)
|
||||
//
|
||||
// To delete legacy support in one PR: remove the #include and the single
|
||||
// call in CommandBus::dispatch(), then delete this file.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "CommandEnvelope.hpp"
|
||||
|
||||
// Translate an envelope whose version == 1 into its v2 equivalent.
|
||||
// Mutates envelope.command and (where needed) envelope.contents in place.
|
||||
// Sets envelope.version = 2 on return.
|
||||
// No-op if the command is already valid v2 (unknown v1 commands are left
|
||||
// unchanged so the bus returns a proper "Unknown command" error).
|
||||
void translateLegacyEnvelope(CommandEnvelope& envelope);
|
||||
Reference in New Issue
Block a user