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
+66
View File
@@ -0,0 +1,66 @@
#pragma once
#include <Arduino.h>
// ═══════════════════════════════════════════════════════════════════════
// FIRMWARE VERSION
// ═══════════════════════════════════════════════════════════════════════
// Format: MAJOR.MINOR.PATCH (e.g. "2.0.0")
// This is the single source of truth. It is compiled into the binary
// and never stored in NVS — the binary IS the version.
//
// VERSION HISTORY:
// v154 (legacy integer) - Last integer-versioned release
// v2.0.0 - First SemVer release
// ═══════════════════════════════════════════════════════════════════════
#define FW_VERSION "2.0.0"
// ═══════════════════════════════════════════════════════════════════════
// SemVer — lightweight 3-part version struct
// ═══════════════════════════════════════════════════════════════════════
struct SemVer {
uint8_t major;
uint8_t minor;
uint8_t patch;
// Parse "2.0.0" or legacy integer "154" (treated as 0.0.154)
static SemVer parse(const String& s) {
SemVer v{0, 0, 0};
int first = s.indexOf('.');
if (first == -1) {
// Legacy integer format: "154" -> {0, 0, 154}
// Clamp to uint8_t range; values > 255 are stored in minor too
uint16_t n = (uint16_t)s.toInt();
v.minor = (uint8_t)(n / 100);
v.patch = (uint8_t)(n % 100);
return v;
}
int second = s.indexOf('.', first + 1);
v.major = (uint8_t)s.substring(0, first).toInt();
if (second == -1) {
v.minor = (uint8_t)s.substring(first + 1).toInt();
} else {
v.minor = (uint8_t)s.substring(first + 1, second).toInt();
v.patch = (uint8_t)s.substring(second + 1).toInt();
}
return v;
}
bool operator==(const SemVer& o) const {
return major == o.major && minor == o.minor && patch == o.patch;
}
bool operator!=(const SemVer& o) const { return !(*this == o); }
bool operator<(const SemVer& o) const {
if (major != o.major) return major < o.major;
if (minor != o.minor) return minor < o.minor;
return patch < o.patch;
}
bool operator>(const SemVer& o) const { return o < *this; }
bool operator<=(const SemVer& o) const { return !(o < *this); }
bool operator>=(const SemVer& o) const { return !(*this < o); }
bool isZero() const { return major == 0 && minor == 0 && patch == 0; }
String toString() const {
return String(major) + "." + String(minor) + "." + String(patch);
}
};