refactor: move LightState struct to mqtt module
This commit is contained in:
@@ -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()
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user