Keep the console responsive during MQTT shutdown

This commit is contained in:
mikecarper committed 2026-10-05 19:05:58 -07:00
1 parent d17519fe7f
commit f05524a4a2
15 files changed
+634 -63

No files matched your search

+5 -1
View File
@@ -12860,8 +12860,12 @@ void __attribute__((noinline)) MyMesh::servicePostMeshLoop() {
expireRecentRepeatersIfDue();
#endif
#if defined(WITH_MQTT_BRIDGE)
// MQTT owns TLS on Core 0; the radio loop only reaps an acknowledged stop.
if (mqtt_bridge && mqtt_bridge->isRunning()) mqtt_bridge->loop();
#endif
#if defined(WITH_ESPNOW_BRIDGE)
// MQTT runs on Core 0. ESP-NOW remains cooperative, including in the
// ESP-NOW remains cooperative, including in the
// combined Full image where both transports share the WiFi station radio.
#if defined(WITH_MQTT_BRIDGE) || defined(WITH_RS232_BRIDGE)
if (espnow_bridge.isRunning()) espnow_bridge.loop();
+22
View File
@@ -1348,6 +1348,7 @@ public:
_alerter.setBridge(nullptr);
return !mqtt_bridge || !mqtt_bridge->isRunning();
}
if (mqtt_bridge && mqtt_bridge->isStopping()) return false;
// Give the WiFi station to MQTT while it associates. ESP-NOW is restarted
// after the AP channel is known, which avoids a raw ESP-NOW-only session
// pinning the station to a different channel.
@@ -1430,6 +1431,9 @@ public:
#endif
bool setBridgeState(bool enable) override {
#ifdef WITH_MQTT_BRIDGE
if (enable && mqtt_bridge && mqtt_bridge->isStopping()) return false;
#endif
#if defined(WITH_MQTT_BRIDGE) && defined(WITH_ESPNOW_BRIDGE)
if (!enable) {
const bool espnow_stopped = setEspNowBridgeState(false);
@@ -1665,6 +1669,24 @@ public:
#endif
}
bool requestMqttBridgeStop() override {
#ifdef WITH_MQTT_BRIDGE
_alerter.setBridge(nullptr);
if (mqtt_bridge) mqtt_bridge->requestStop();
return true;
#else
return false;
#endif
}
bool isMqttBridgeStopping() override {
#ifdef WITH_MQTT_BRIDGE
return mqtt_bridge && mqtt_bridge->isStopping();
#else
return false;
#endif
}
bool syncMqttNtp() override {
#ifdef WITH_MQTT_BRIDGE
if (!mqtt_bridge || !mqtt_bridge->isRunning()) return false;
+2 -1
View File
@@ -2604,7 +2604,8 @@ void MyMesh::loop() {
sampleTelemetryHistory();
#endif
#ifdef WITH_MQTT_BRIDGE
// bridge.loop() is now handled by FreeRTOS task on Core 0 - no need to call it here
// TLS runs on Core 0; the radio loop reaps only an acknowledged CLI stop.
if (bridge && bridge->isRunning()) bridge->loop();
#endif
#ifdef WITH_ESPNOW_BRIDGE
if (espnow_bridge.isRunning()) espnow_bridge.loop();
+14
View File
@@ -610,6 +610,7 @@ public:
_alerter.setBridge(nullptr);
return !bridge || !bridge->isRunning();
}
if (bridge && bridge->isStopping()) return false;
// Give the WiFi station to MQTT while it associates. ESP-NOW is restarted
// after the AP channel is known, which avoids a raw ESP-NOW-only session
// pinning the station to a different channel.
@@ -702,6 +703,9 @@ public:
}
bool setBridgeState(bool enable) override {
#ifdef WITH_MQTT_BRIDGE
if (enable && bridge && bridge->isStopping()) return false;
#endif
#if defined(WITH_MQTT_BRIDGE) && defined(WITH_ESPNOW_BRIDGE)
if (!enable) return setEspNowBridgeState(false) && setMqttBridgeState(false);
const bool mqtt_ok = _prefs.bridge_enabled
@@ -846,6 +850,16 @@ public:
return bridge && bridge->isRunning();
}
bool requestMqttBridgeStop() override {
_alerter.setBridge(nullptr);
if (bridge) bridge->requestStop();
return true;
}
bool isMqttBridgeStopping() override {
return bridge && bridge->isStopping();
}
bool syncMqttNtp() override {
if (!bridge || !bridge->isRunning()) return false;
// Queue the sync onto the MQTT task (Core 0) without blocking: this runs on