refactor: use mqtt::is_stay_alive() helper instead of direct static access

This commit is contained in:
2026-05-05 21:00:54 +02:00
parent 087d6e20cd
commit d98fe9bb3c

View File

@@ -18,7 +18,7 @@ use hal::PROGRESS_ACTIVE;
use crate::config::{NetworkConfig, PlantConfig}; use crate::config::{NetworkConfig, PlantConfig};
use crate::fat_error::FatResult; use crate::fat_error::FatResult;
use crate::hal::esp::MQTT_STAY_ALIVE;
use crate::log::log; use crate::log::log;
use crate::tank::{determine_tank_state, TankError, TankState, WATER_FROZEN_THRESH}; use crate::tank::{determine_tank_state, TankError, TankState, WATER_FROZEN_THRESH};
use crate::webserver::http_server; use crate::webserver::http_server;
@@ -519,7 +519,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
//TODO //TODO
//mark_app_valid(); //mark_app_valid();
let stay_alive = MQTT_STAY_ALIVE.load(Ordering::Relaxed); let stay_alive = mqtt::is_stay_alive();
info!("Check stay alive, current state is {}", stay_alive); info!("Check stay alive, current state is {}", stay_alive);
if stay_alive { if stay_alive {
@@ -1003,7 +1003,7 @@ async fn wait_infinity(
hal::PlantHal::feed_watchdog(); hal::PlantHal::feed_watchdog();
if wait_type == WaitType::MqttConfig && !MQTT_STAY_ALIVE.load(Ordering::Relaxed) { if wait_type == WaitType::MqttConfig && !mqtt::is_stay_alive() {
reboot_now.store(true, Ordering::Relaxed); reboot_now.store(true, Ordering::Relaxed);
} }
if reboot_now.load(Ordering::Relaxed) { if reboot_now.load(Ordering::Relaxed) {