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:
2026-03-14 22:15:27 +02:00
co-authored by Claude Sonnet 4.6
parent c3dc0a79bc
commit d4bd990e53
33 changed files with 1874 additions and 301 deletions
+6 -42
View File
@@ -256,51 +256,13 @@ bool ConfigManager::saveToSD() {
return success;
}
// Device configuration now only handles firmware version (identity is in NVS)
// Firmware version is now owned by the binary (FW_VERSION in Version.hpp).
// saveDeviceConfig / loadDeviceConfig are no-ops kept for call-site compatibility.
bool ConfigManager::saveDeviceConfig() {
if (!ensureSDCard()) {
return false;
}
StaticJsonDocument<256> doc;
doc["fwVersion"] = deviceConfig.fwVersion;
char buffer[256];
size_t len = serializeJson(doc, buffer, sizeof(buffer));
if (len == 0 || len >= sizeof(buffer)) {
LOG_ERROR(TAG, "ConfigManager - ❌ Failed to serialize device config JSON");
return false;
}
saveFileToSD("/settings", "deviceConfig.json", buffer);
LOG_DEBUG(TAG, "ConfigManager - Device config saved - FwVer: %s", deviceConfig.fwVersion.c_str());
return true;
}
bool ConfigManager::loadDeviceConfig() {
if (!ensureSDCard()) return false;
File file = SD.open("/settings/deviceConfig.json", FILE_READ);
if (!file) {
LOG_WARNING(TAG, "ConfigManager - ⚠️ Device config file not found - using firmware version default");
return false;
}
StaticJsonDocument<512> doc;
DeserializationError error = deserializeJson(doc, file);
file.close();
if (error) {
LOG_ERROR(TAG, "ConfigManager - ❌ Failed to parse device config from SD: %s", error.c_str());
return false;
}
if (doc.containsKey("fwVersion")) {
deviceConfig.fwVersion = doc["fwVersion"].as<String>();
LOG_VERBOSE(TAG, "ConfigManager - Firmware version loaded from SD: %s", deviceConfig.fwVersion.c_str());
}
return true;
}
@@ -790,7 +752,9 @@ std::vector<String> ConfigManager::getUpdateServers() const {
for (const String& server : updateServers) {
servers.push_back(server);
}
servers.push_back(updateConfig.fallbackServerUrl);
for (const String& url : updateConfig.fallbackServerUrls) {
if (!url.isEmpty()) servers.push_back(url);
}
return servers;
}
@@ -1138,7 +1102,7 @@ String ConfigManager::getAllSettingsAsJson() const {
device["uid"] = deviceConfig.deviceUID;
device["hwType"] = deviceConfig.hwType;
device["hwVersion"] = deviceConfig.hwVersion;
device["fwVersion"] = deviceConfig.fwVersion;
device["fwVersion"] = FW_VERSION;
// Network config
JsonObject network = doc.createNestedObject("network");