From 5ac4edd5a06e6b9fbd5ee828d16f1d5b0826075a Mon Sep 17 00:00:00 2001 From: ju6ge Date: Tue, 5 May 2026 20:49:39 +0200 Subject: [PATCH] refactor: move Solar struct to mqtt module --- rust/src/main.rs | 8 +------- rust/src/mqtt.rs | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index b77f088..f8d1134 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -84,12 +84,6 @@ enum WaitType { MqttConfig, } -#[derive(Serialize, Deserialize, Debug, PartialEq)] -struct Solar { - current_ma: u32, - voltage_ma: u32, -} - impl WaitType { fn blink_pattern(&self) -> u64 { match self { @@ -870,7 +864,7 @@ async fn publish_mppt_state( ) -> FatResult<()> { let current = board.board_hal.get_mptt_current().await?; let voltage = board.board_hal.get_mptt_voltage().await?; - let solar_state = Solar { + let solar_state = mqtt::Solar { current_ma: current.as_milliamperes() as u32, voltage_ma: voltage.as_millivolts() as u32, }; diff --git a/rust/src/mqtt.rs b/rust/src/mqtt.rs index 7211013..e26c167 100644 --- a/rust/src/mqtt.rs +++ b/rust/src/mqtt.rs @@ -35,6 +35,12 @@ pub struct PumpInfo { pub min_current_ma: u16, } +#[derive(Serialize, Debug, PartialEq)] +pub struct Solar { + pub current_ma: u32, + pub voltage_ma: u32, +} + static MQTT_CONNECTED_EVENT_RECEIVED: AtomicBool = AtomicBool::new(false); static MQTT_ROUND_TRIP_RECEIVED: AtomicBool = AtomicBool::new(false); pub static MQTT_STAY_ALIVE: AtomicBool = AtomicBool::new(false);