refactor: move PumpInfo struct to mqtt module
This commit is contained in:
@@ -115,19 +115,6 @@ struct LightState {
|
|||||||
is_day: bool,
|
is_day: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
|
|
||||||
///mqtt struct to track pump activities
|
|
||||||
struct PumpInfo {
|
|
||||||
enabled: bool,
|
|
||||||
pump_ineffective: bool,
|
|
||||||
median_current_ma: u16,
|
|
||||||
max_current_ma: u16,
|
|
||||||
min_current_ma: u16,
|
|
||||||
error: String,
|
|
||||||
flow_raw: u32,
|
|
||||||
flow_ml: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct PumpResult {
|
pub struct PumpResult {
|
||||||
median_current_ma: u16,
|
median_current_ma: u16,
|
||||||
@@ -1033,7 +1020,7 @@ async fn pump_info(
|
|||||||
flow_raw: u32,
|
flow_raw: u32,
|
||||||
flow_ml: f32,
|
flow_ml: f32,
|
||||||
) {
|
) {
|
||||||
let pump_info = PumpInfo {
|
let pump_info = mqtt::PumpInfo {
|
||||||
enabled: pump_active,
|
enabled: pump_active,
|
||||||
pump_ineffective,
|
pump_ineffective,
|
||||||
median_current_ma,
|
median_current_ma,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use alloc::{format, string::ToString};
|
|||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_net::Stack;
|
use embassy_net::Stack;
|
||||||
|
use embassy_sync::once_lock::OnceLock;
|
||||||
use embassy_time::{Duration, Timer, WithTimeout};
|
use embassy_time::{Duration, Timer, WithTimeout};
|
||||||
use log::info;
|
use log::info;
|
||||||
use mcutie::{
|
use mcutie::{
|
||||||
@@ -15,7 +16,20 @@ use mcutie::{
|
|||||||
QoS, Topic,
|
QoS, Topic,
|
||||||
};
|
};
|
||||||
use portable_atomic::AtomicBool;
|
use portable_atomic::AtomicBool;
|
||||||
use embassy_sync::once_lock::OnceLock;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
|
||||||
|
///mqtt struct to track pump activities
|
||||||
|
pub struct PumpInfo {
|
||||||
|
pub enabled: bool,
|
||||||
|
pub pump_ineffective: bool,
|
||||||
|
pub median_current_ma: u16,
|
||||||
|
pub max_current_ma: u16,
|
||||||
|
pub min_current_ma: u16,
|
||||||
|
pub error: String,
|
||||||
|
pub flow_raw: u32,
|
||||||
|
pub flow_ml: f32,
|
||||||
|
}
|
||||||
|
|
||||||
static MQTT_CONNECTED_EVENT_RECEIVED: AtomicBool = AtomicBool::new(false);
|
static MQTT_CONNECTED_EVENT_RECEIVED: AtomicBool = AtomicBool::new(false);
|
||||||
static MQTT_ROUND_TRIP_RECEIVED: AtomicBool = AtomicBool::new(false);
|
static MQTT_ROUND_TRIP_RECEIVED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user