feat(MQTT): rebuild topic spec to v2 (F-062)

Full MQTT topic rebuild per docs/reference/vesper_mqtt_topic_spec_v2.md.
Only the MQTT transport path changed — WebSocket, HTTP, and UART are untouched.

- control/command (in) + control/ack (out, strictly replies) replace the old
  control/data pair; new control/reports for critical unsolicited events
  (bell overload) that don't belong on the strictly-reply ack channel
- status/playback split out for playback transitions only
- status/alerts + status/info renamed to system/alerts + system/info, both
  now correctly retained; new system/logs and system/metrics (diagnostics
  report moved here from system/info, gained bell strike/heat data)
- LWT registered for the first time — status/heartbeat gets
  {"state":"offline","ok":false} on an unclean disconnect; graceful
  disconnect (mqtt.disable) announces offline explicitly since LWT doesn't
  fire on a clean disconnect
- heartbeat payload flattened, gains independently-derived state/ok fields
  (via a new MQTTDriver::setStateProvider() wired from Player+HealthMonitor)
- optional req_id correlation added bus-wide (CommandEnvelope/CommandResult),
  not MQTT-only, since any transport with multiple senders sharing one
  channel has the same problem. Always optional — v1 clients unaffected.
- per-topic ON/OFF switches (ConfigManager::MqttTopicConfig, 8 flags) as
  sub-switches under the existing mqtt.enable/disable master switch, so a
  device can breathe by disabling topics it doesn't need. New
  mqtt.get_topics/mqtt.set_topics commands; command switch applies live.

Bumped to v2.2.0. Verified: pio run -e vesper-std-v1 -e agnus-v1 both build clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-21 10:48:36 +03:00
co-authored by Claude Sonnet 5
parent 20576f12ff
commit 391ecb63fc
26 changed files with 1053 additions and 330 deletions
+31 -1
View File
@@ -89,6 +89,31 @@ public:
bool enabled = true; // 🔘 MQTT enabled by default (can be toggled via command)
};
/**
* @struct MqttTopicConfig
* @brief Per-topic ON/OFF switches for MQTT v2 publishing (loaded from SD/NVS)
*
* These only take effect while MqttConfig::enabled (the master switch) is
* true — turning the master off stops everything regardless of these flags.
* While the master is on, each flag independently gates whether its topic
* publishes at all, so a device can "breathe" by disabling topics it
* doesn't need (e.g. a fleet-only install with no phone app can turn off
* control/command + control/ack entirely).
*
* `command` gates BOTH control/command (inbound subscribe) and control/ack
* (outbound reply) together — see docs/reference/vesper_mqtt_topic_spec_v2.md.
*/
struct MqttTopicConfig {
bool command = true; // control/command (subscribe) + control/ack (reply)
bool heartbeat = true; // status/heartbeat
bool playback = true; // status/playback
bool reports = true; // control/reports (bell overload etc. — critical, unsolicited)
bool alerts = true; // system/alerts
bool info = true; // system/info
bool logs = true; // system/logs (also gated by log.set_mqtt level — see Logging)
bool metrics = true; // system/metrics
};
/**
* @struct HardwareConfig
* @brief Hardware-specific settings (compiled per HWID)
@@ -220,9 +245,10 @@ public:
uint8_t serialLogLevel = 3; // INFO
uint8_t sdLogLevel = 2; // WARNING
uint8_t mqttLogLevel = 2; // WARNING
bool mqttEnabled = true; // MQTT enabled by default
bool mqttEnabled = true; // MQTT enabled by default (master switch)
bool bellsEnabled = true; // Master bell mechanism ON/OFF (blocks playback + clock alerts)
String otaChannel = "stable"; // OTA release channel: "stable" | "beta" | "development"
MqttTopicConfig mqttTopics; // Per-topic MQTT publish switches (only apply while mqttEnabled)
};
private:
@@ -452,6 +478,10 @@ public:
bool getBellsEnabled() const { return generalConfig.bellsEnabled; }
String getOtaChannel() const { return generalConfig.otaChannel; }
void setOtaChannel(const String& channel) { generalConfig.otaChannel = channel; }
// Per-topic MQTT switches (only take effect while getMqttEnabled() is true — see MqttTopicConfig)
const MqttTopicConfig& getMqttTopicConfig() const { return generalConfig.mqttTopics; }
void setMqttTopicConfig(const MqttTopicConfig& cfg) { generalConfig.mqttTopics = cfg; }
bool loadGeneralConfig();
bool saveGeneralConfig();
#if !HAS_SD_CARD