feat: multi-board HAL guards, RFRemote subsystem, Player/OTA improvements
Multi-board variant support: - variants/vesper.hpp: enable HAS_RF=1, define RF_RX_PIN=22 - variants/agnus.hpp: enable HAS_RF=1, RF_RX_PIN=22, correct HAS_RTC=0 - main.cpp, Player, HealthMonitor, OTAManager, ConfigManager: wrap all RTC/SD/RF-dependent code in #if HAS_RTC / HAS_SD_CARD / HAS_RF guards so Agnus builds cleanly without those peripherals RFRemote subsystem (new): - src/RFRemote/: RF receiver driver (GPIO RF_RX_PIN) + command handler - Registered with HealthMonitor and CommunicationRouter when HAS_RF=1 Player improvements: - uid -> pid rename throughout (Player, BuiltInMelodies, api-reference) - loadMelodyInRAM() now returns bool - playerControlTaskFn task added — defers stop/pause/resume out of timer callback (Tmr Svc) to avoid stack overflows - setDependencies() accepts nullptr FileManager for SD-less boards OTAManager: - Consume download_url from server metadata response instead of constructing firmware path locally - HTTP redirect following enabled (setFollowRedirects) - HAS_RTC guards on TimeKeeper references platformio.ini: - Add rc-switch library for RF remote support - Remove BOARD_TYPE/BOARD_NAME/BOARD_VERSION flags (moved to variant headers) - MQTT_SECRET placeholders only — no secrets in source Docs: - docs/architecture/codebase-refactor-plan.md: new migration strategy doc - docs/reference/api-reference.md: updated for pid, note_assignments, download_url - Remove stale docs: ota-telemetry-api.md, platformio-commands.md, firmware-variants.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
#include "../../Logging/Logging.hpp"
|
||||
#include "../../Player/Player.hpp"
|
||||
#include "../../FileManager/FileManager.hpp"
|
||||
#if HAS_RTC
|
||||
#include "../../TimeKeeper/TimeKeeper.hpp"
|
||||
#endif
|
||||
#include "../../FirmwareValidator/FirmwareValidator.hpp"
|
||||
#include "../../Telemetry/Telemetry.hpp"
|
||||
#include "../../HealthMonitor/HealthMonitor.hpp"
|
||||
@@ -24,14 +26,19 @@
|
||||
// Domain handlers
|
||||
#include "../Handlers/PlaybackHandler/PlaybackHandler.hpp"
|
||||
#include "../Handlers/RelayHandler/RelayHandler.hpp"
|
||||
#if HAS_RTC
|
||||
#include "../Handlers/ClockHandler/ClockHandler.hpp"
|
||||
#include "../Handlers/SystemHandler/SystemHandler.hpp"
|
||||
#endif
|
||||
#include "../Handlers/FirmwareHandler/FirmwareHandler.hpp"
|
||||
#include "../Handlers/NetworkHandler/NetworkHandler.hpp"
|
||||
#include "../Handlers/FileHandler/FileHandler.hpp"
|
||||
#include "../Handlers/LoggingHandler/LoggingHandler.hpp"
|
||||
#include "../Handlers/TelemetryHandler/TelemetryHandler.hpp"
|
||||
#include "../Handlers/MQTTHandler/MQTTHandler.hpp"
|
||||
#if HAS_RF
|
||||
#include "../../RFRemote/RFRemoteHandler.hpp"
|
||||
#endif
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Constructor
|
||||
@@ -169,9 +176,11 @@ void CommunicationRouter::setFileManagerReference(FileManager* fm) {
|
||||
}
|
||||
}
|
||||
|
||||
#if HAS_RTC
|
||||
void CommunicationRouter::setTimeKeeperReference(Timekeeper* tk) {
|
||||
_timeKeeper = tk;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CommunicationRouter::setFirmwareValidatorReference(FirmwareValidator* fv) {
|
||||
_firmwareValidator = fv;
|
||||
@@ -189,6 +198,12 @@ void CommunicationRouter::setOutputManagerReference(OutputManager* om) {
|
||||
_outputManager = om;
|
||||
}
|
||||
|
||||
#if HAS_RF
|
||||
void CommunicationRouter::setRFRemoteReference(RFRemote* rf) {
|
||||
_rfRemote = rf;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// registerHandlers()
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
@@ -197,7 +212,9 @@ void CommunicationRouter::registerHandlers() {
|
||||
// Log any missing optional dependencies so issues surface at boot, not later.
|
||||
if (!_player) LOG_ERROR(TAG, "registerHandlers: _player is null — PlaybackHandler, RelayHandler, FirmwareHandler, SystemHandler skipped");
|
||||
if (!_fileManager) LOG_ERROR(TAG, "registerHandlers: _fileManager is null — FileHandler skipped");
|
||||
#if HAS_RTC
|
||||
if (!_timeKeeper) LOG_ERROR(TAG, "registerHandlers: _timeKeeper is null — ClockHandler skipped");
|
||||
#endif
|
||||
if (!_firmwareValidator) LOG_ERROR(TAG, "registerHandlers: _firmwareValidator is null — FirmwareHandler skipped");
|
||||
if (!_telemetry) LOG_ERROR(TAG, "registerHandlers: _telemetry is null — TelemetryHandler and SystemHandler skipped");
|
||||
if (!_healthMonitor) LOG_WARNING(TAG, "registerHandlers: _healthMonitor is null — system.health unavailable");
|
||||
@@ -213,17 +230,21 @@ void CommunicationRouter::registerHandlers() {
|
||||
_bus.registerHandler(std::make_unique<RelayHandler>(_configManager, *_outputManager, *_player));
|
||||
}
|
||||
|
||||
#if HAS_RTC
|
||||
// Clock
|
||||
if (_timeKeeper) {
|
||||
_bus.registerHandler(std::make_unique<ClockHandler>(_configManager, *_timeKeeper));
|
||||
}
|
||||
#endif
|
||||
|
||||
// System — requires player, telemetry, healthMonitor, timeKeeper, clientManager
|
||||
#if HAS_RTC
|
||||
if (_player && _telemetry && _healthMonitor && _timeKeeper) {
|
||||
_bus.registerHandler(std::make_unique<SystemHandler>(
|
||||
_configManager, *_player, *_telemetry, *_healthMonitor,
|
||||
*_timeKeeper, _clientManager));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Firmware / OTA
|
||||
if (_firmwareValidator && _player) {
|
||||
@@ -250,6 +271,13 @@ void CommunicationRouter::registerHandlers() {
|
||||
// MQTT control (enable / disable)
|
||||
_bus.registerHandler(std::make_unique<MQTTHandler>(_configManager, _mqttClient));
|
||||
|
||||
#if HAS_RF
|
||||
// RF remote control
|
||||
if (_rfRemote) {
|
||||
_bus.registerHandler(std::make_unique<RFRemoteHandler>(*_rfRemote));
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_INFO(TAG, "All domain handlers registered on CommandBus");
|
||||
}
|
||||
|
||||
@@ -323,11 +351,19 @@ size_t CommunicationRouter::getWebSocketClientCount() const {
|
||||
}
|
||||
|
||||
bool CommunicationRouter::isHealthy() const {
|
||||
if (!_player || !_fileManager || !_timeKeeper) {
|
||||
LOG_WARNING(TAG, "Unhealthy — missing subsystem references (player=%d fileManager=%d timeKeeper=%d)",
|
||||
_player != nullptr, _fileManager != nullptr, _timeKeeper != nullptr);
|
||||
#if HAS_RTC
|
||||
if (!_player || !_timeKeeper) {
|
||||
LOG_WARNING(TAG, "Unhealthy — missing subsystem references (player=%d timeKeeper=%d)",
|
||||
_player != nullptr, _timeKeeper != nullptr);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (!_player) {
|
||||
LOG_WARNING(TAG, "Unhealthy — missing subsystem references (player=%d)",
|
||||
_player != nullptr);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (!_networking.isConnected()) {
|
||||
LOG_WARNING(TAG, "Unhealthy — no network connection");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user