fix(mqtt): re-arm STATUS_INTERVAL timer with reset() instead of setEnable(true)

The periodic full-status republish was firing only once at startup. The
expiry lambda re-armed via m_mqtt_status_timer.setEnable(true), but
Async::Timer::setEnable() is guarded by `if (do_enable && !m_is_enabled)`
and m_is_enabled is never reset to false on expiry — so the call was a
no-op, the application erased the entry from its dispatch map, and the
timer never fired again regardless of STATUS_INTERVAL.

reset() does an unconditional delTimer+addTimer, which is what was
intended.

The pre-existing test_29_mqtt_full_status accepted ">=1 message, retained
or fresh", so the always-present retained snapshot from the very first
fire was enough to make it pass. New test_43_full_status_periodic_republish
filters out msg.retain==True and requires >=3 fresh publishes within a 4s
window with STATUS_INTERVAL=1000, plus an inter-arrival cadence check.
This commit is contained in:
Audric committed 2026-04-30 01:58:09 +02:00
1 parent d8df8cf70b
commit 2e1095e3da
2 files changed
+83 -1

No files matched your search

+1 -1
View File
@@ -510,7 +510,7 @@ bool Reflector::initialize(Async::Config &cfg)
{
refreshStatus();
m_mqtt->publishFullStatus(m_status);
m_mqtt_status_timer.setEnable(true);
m_mqtt_status_timer.reset();
});
}
}