fix(CommunicationRouter): republish status/playback on every MQTT (re)connect (F-066)
status/playback is retained but was only published on a Player transition. After a power loss mid-melody the Player boots straight into STOPPED with no transition, so the broker kept serving the old "playing" forever. The MQTT on-connect callback now publishes Player::getPlaybackSnapshot() on every CONNECT (not just the first after boot) — "idle" after a reboot, the live state after a plain reconnect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,12 @@ void CommunicationRouter::begin() {
|
||||
|
||||
_mqttClient.setOnConnectCallback([this](bool /*sessionPresent*/) {
|
||||
reportBootOnce();
|
||||
|
||||
// status/playback is retained: if the board lost power (or the link)
|
||||
// mid-melody, the broker would keep serving "playing" indefinitely.
|
||||
// Overwrite it with the Player's real state on EVERY connect — normally
|
||||
// "idle" after a reboot, the live state after a plain reconnect.
|
||||
if (_player) publishPlayback(_player->getPlaybackSnapshot());
|
||||
});
|
||||
|
||||
// Heartbeat state/ok derivation — independently derived per the topic spec,
|
||||
|
||||
Reference in New Issue
Block a user