feat: semver versioning, FastAPI OTA integration, health alerts via MQTT
- Version.hpp: extract FW_VERSION from main.cpp into shared header
- OTAManager: replace uint16_t version with SemVer struct; update API URLs
to new FastAPI backend (/api/firmware/{hw_type}/{channel}/latest);
add postDownloadTelemetry() and postFlashTelemetry() for fleet visibility
- ConfigManager: remove fwVersion from DeviceConfig (always read from
FW_VERSION constant); saveDeviceConfig/loadDeviceConfig are now no-ops;
fallbackServerUrl replaced with fallbackServerUrls[2] array
- HealthMonitor: add AlertCallback + setAlertCallback() firing on state
transitions (including CLEARED on recovery)
- CommunicationRouter: wire HealthMonitor alert callback on begin();
add publishAlert() and publishInfo() for MQTT status topics
- MQTTDriver: add _alertsTopic + _infoTopic; add publishDirect() for
absolute topic publishing; migrate heartbeat to JsonDocument
- ResponseBuilder, ClientManager, BellEngine: StaticJsonDocument /
DynamicJsonDocument → JsonDocument; remove dead notifyBellsFired()
- docs: reorganise into architecture/, dev/, features/, reference/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "../FileManager/FileManager.hpp"
|
||||
#include "../Telemetry/Telemetry.hpp"
|
||||
#include "../TimeKeeper/TimeKeeper.hpp"
|
||||
#include "../Version.hpp"
|
||||
|
||||
class ConfigManager; // Forward declaration
|
||||
class Player; // Forward declaration for idle check
|
||||
@@ -83,7 +84,7 @@ public:
|
||||
void checkFirmwareUpdateFromSD(); // Check SD for firmware update
|
||||
bool performManualUpdate(); // Manual update triggered by app
|
||||
bool performManualUpdate(const String& channel); // Manual update from specific channel
|
||||
bool performCustomUpdate(const String& firmwareUrl, const String& checksum = "", size_t fileSize = 0, uint16_t version = 0); // Custom firmware update
|
||||
bool performCustomUpdate(const String& firmwareUrl, const String& checksum = "", size_t fileSize = 0, const String& version = ""); // Custom firmware update
|
||||
|
||||
// Hardware identification
|
||||
String getHardwareVariant() const;
|
||||
@@ -92,8 +93,8 @@ public:
|
||||
// Status and info
|
||||
Status getStatus() const { return _status; }
|
||||
ErrorCode getLastError() const { return _lastError; }
|
||||
uint16_t getCurrentVersion() const;
|
||||
uint16_t getAvailableVersion() const { return _availableVersion; }
|
||||
SemVer getCurrentVersion() const;
|
||||
SemVer getAvailableVersion() const { return _availableVersion; }
|
||||
bool isUpdateAvailable() const { return _updateAvailable; }
|
||||
|
||||
// Callbacks
|
||||
@@ -115,8 +116,8 @@ private:
|
||||
Telemetry* _telemetry; // Telemetry reference for freeze mode
|
||||
Status _status;
|
||||
ErrorCode _lastError;
|
||||
uint16_t _availableVersion;
|
||||
uint16_t _minVersion; // NEW: Minimum required version
|
||||
SemVer _availableVersion;
|
||||
SemVer _minVersion;
|
||||
size_t _expectedFileSize; // NEW: Expected firmware file size
|
||||
bool _updateAvailable;
|
||||
String _availableChecksum;
|
||||
@@ -156,14 +157,20 @@ private:
|
||||
bool checkChannelsMetadata();
|
||||
bool downloadAndInstall();
|
||||
bool downloadAndInstall(const String& channel);
|
||||
bool downloadDirectToFlash(const String& url, size_t expectedSize); // NEW: Direct to flash (bypasses SD)
|
||||
bool downloadToSD(const String& url, const String& expectedChecksum, size_t expectedSize); // OLD: Via SD card
|
||||
bool downloadDirectToFlash(const String& url, size_t expectedSize, const String& fromVersion, const String& toVersion, const String& channel);
|
||||
bool downloadToSD(const String& url, const String& expectedChecksum, size_t expectedSize);
|
||||
bool verifyChecksum(const String& filePath, const String& expectedChecksum);
|
||||
String calculateSHA256(const String& filePath);
|
||||
bool installFromSD(const String& filePath);
|
||||
String buildChannelUrl(const String& channel) const;
|
||||
String buildMetadataUrl(const String& channel) const;
|
||||
String buildFirmwareUrl(const String& channel) const;
|
||||
|
||||
// FastAPI URL builders
|
||||
String buildLatestUrl(const String& baseUrl, const String& hwType, const String& channel) const;
|
||||
String buildVersionInfoUrl(const String& baseUrl, const String& hwType, const String& channel, const String& version) const;
|
||||
String buildFirmwareUrl(const String& baseUrl, const String& hwType, const String& channel, const String& version) const;
|
||||
|
||||
// OTA telemetry — best-effort POSTs, never block or fail the update
|
||||
void postDownloadTelemetry(const String& fromVersion, const String& toVersion, const String& channel);
|
||||
void postFlashTelemetry(const String& fromVersion, const String& toVersion, const String& channel);
|
||||
|
||||
// NEW: Helper methods
|
||||
bool isPlayerActive() const;
|
||||
|
||||
Reference in New Issue
Block a user