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
+14 -11
View File
@@ -28,6 +28,7 @@
#include <vector>
#include <nvs_flash.h>
#include <nvs.h>
#include "../Version.hpp"
class ConfigManager {
public:
@@ -38,15 +39,14 @@ public:
/**
* @struct DeviceConfig
* @brief Factory-set device identity (NVS storage)
*
*
* These values are set once during manufacturing and stored in NVS.
* fwVersion is updated automatically after OTA updates (SD storage).
* fwVersion is NOT stored — it is always read from the compiled FW_VERSION constant.
*/
struct DeviceConfig {
String deviceUID = ""; // 🏷️ Factory-set UID (NVS) - NO DEFAULT
String hwType = ""; // 🔧 Factory-set hardware type (NVS) - NO DEFAULT
String hwType = ""; // 🔧 Factory-set hardware type (NVS) - NO DEFAULT
String hwVersion = ""; // 📐 Factory-set hardware revision (NVS) - NO DEFAULT
String fwVersion = "0"; // 📋 Current firmware version (SD) - auto-updated (integer string)
};
/**
@@ -133,9 +133,12 @@ public:
* Universal defaults for all devices.
*/
struct UpdateConfig {
String fallbackServerUrl = "http://firmware.bonamin.space"; // 🛡️ Universal fallback - OK as is
int timeout = 10000; // ⏱️ Universal timeout - OK as is
int retries = 3; // 🔄 Universal retries - OK as is
String fallbackServerUrls[2] = {
"http://firmware.bellsystems.net", // 🥇 Primary fallback
"http://firmware.bonamin.space" // 🥈 Secondary fallback
};
int timeout = 10000; // ⏱️ Universal timeout - OK as is
int retries = 3; // 🔄 Universal retries - OK as is
};
/**
@@ -313,10 +316,10 @@ public:
String getDeviceUID() const { return deviceConfig.deviceUID; }
String getHwType() const { return deviceConfig.hwType; }
String getHwVersion() const { return deviceConfig.hwVersion; }
String getFwVersion() const { return deviceConfig.fwVersion; }
/** @brief Set firmware version (auto-updated after OTA) */
void setFwVersion(const String& version) { deviceConfig.fwVersion = version; }
// Firmware version is owned by the binary — always returns the compiled-in constant.
String getFwVersion() const { return FW_VERSION; }
// No-op: version is compiled in, not stored. Kept for call-site compatibility.
void setFwVersion(const String&) {}
// Configuration update methods for app commands
void updateTimeConfig(long gmtOffsetSec, int daylightOffsetSec);