refactor(comms): clean up Communication folder structure
- Delete dead code: CommandHandler (700-line God Class) and
HTTPRequestHandler — both replaced by new architecture in Stage 4
- Create Drivers/ group for the three low-level protocol drivers,
mirroring the Transport/ pattern:
MQTTAsyncClient → Drivers/MQTTDriver (class: MQTTDriver)
WebSocketServer → Drivers/WebSocketDriver (class: WebSocketDriver)
UARTCommandHandler → Drivers/UARTDriver (class: UARTDriver)
- Update all includes and type references across CommunicationRouter,
all three Transport wrappers, and MQTTHandler
- Add -std=gnu++14 + build_unflags to platformio.ini so std::make_unique
compiles on ESP32 (required by CommunicationRouter::registerHandlers)
Build: passing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,7 @@ const size_t UARTTransport::WHITELIST_SIZE =
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
UARTTransport::UARTTransport(UARTCommandHandler& uart, CommandBus& bus)
|
||||
UARTTransport::UARTTransport(UARTDriver& uart, CommandBus& bus)
|
||||
: _uart(uart)
|
||||
, _bus(bus) {
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "../ITransport.hpp"
|
||||
#include "../../UARTCommandHandler/UARTCommandHandler.hpp"
|
||||
#include "../../Drivers/UARTDriver/UARTDriver.hpp"
|
||||
|
||||
class CommandBus;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UARTTransport
|
||||
//
|
||||
// ITransport wrapper around the existing UARTCommandHandler.
|
||||
// ITransport wrapper around the existing UARTDriver.
|
||||
//
|
||||
// The UART port talks to a slave LCD/button board. Only a small whitelist of
|
||||
// commands are accepted from this transport to prevent feedback loops and
|
||||
@@ -31,10 +31,10 @@ class CommandBus;
|
||||
|
||||
class UARTTransport : public ITransport {
|
||||
public:
|
||||
UARTTransport(UARTCommandHandler& uart, CommandBus& bus);
|
||||
UARTTransport(UARTDriver& uart, CommandBus& bus);
|
||||
|
||||
void begin() override;
|
||||
void loop() override; // polls UARTCommandHandler::loop()
|
||||
void loop() override; // polls UARTDriver::loop()
|
||||
bool isHealthy() const override;
|
||||
String name() const override { return "UART"; }
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
void broadcast(const String& message) override;
|
||||
|
||||
private:
|
||||
UARTCommandHandler& _uart;
|
||||
UARTDriver& _uart;
|
||||
CommandBus& _bus;
|
||||
|
||||
// Commands the UART slave is allowed to issue
|
||||
@@ -51,6 +51,6 @@ private:
|
||||
|
||||
bool isWhitelisted(const String& command) const;
|
||||
|
||||
// Invoked by UARTCommandHandler's message callback
|
||||
// Invoked by UARTDriver's message callback
|
||||
void onMessage(JsonDocument& doc);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user