From 53819484fb422cc3c5930c71af3a6867a88c0887 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 d384bd9..4cd72a1 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 { @@ -850,7 +844,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 c330168..6f37678 100644 --- a/rust/src/mqtt.rs +++ b/rust/src/mqtt.rs @@ -27,6 +27,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);