diff --git a/rust/src/main.rs b/rust/src/main.rs index 31e55f4..e6c074b 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -100,21 +100,6 @@ impl WaitType { } } -#[derive(Serialize, Deserialize, Debug, PartialEq, Default)] -/// Light State tracking data for mqtt -struct LightState { - /// is enabled in config - enabled: bool, - /// led is on - active: bool, - /// led should not be on at this time of day - out_of_work_hour: bool, - /// the battery is low so do not use led - battery_low: bool, - /// the sun is up - is_day: bool, -} - #[derive(Serialize, Deserialize, Debug, PartialEq, Default)] ///mqtt struct to track pump activities struct PumpInfo { @@ -467,7 +452,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> { .unwrap_or(BatteryState::Unknown); info!("Battery state is {:?}", battery_state); - let mut light_state = LightState { + let mut light_state = mqtt::LightState { enabled: board.board_hal.get_config().night_lamp.enabled, ..Default::default() }; diff --git a/rust/src/mqtt.rs b/rust/src/mqtt.rs index 9a01897..b9db8fa 100644 --- a/rust/src/mqtt.rs +++ b/rust/src/mqtt.rs @@ -15,6 +15,16 @@ use mcutie::{ }; use portable_atomic::AtomicBool; use embassy_sync::once_lock::OnceLock; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug, PartialEq, Default)] +pub struct LightState { + pub enabled: bool, + pub active: bool, + pub out_of_work_hour: bool, + pub battery_low: bool, + pub is_day: bool, +} static MQTT_CONNECTED_EVENT_RECEIVED: AtomicBool = AtomicBool::new(false); static MQTT_ROUND_TRIP_RECEIVED: AtomicBool = AtomicBool::new(false);