4 Commits

Author SHA1 Message Date
a8893974a5 refctor: TankInfo structure (consistent layout)
- fix: use tagged enum serialization for TankError
- fix: rename TankInfo fields for consistent naming (volume_ml, pct, water_temp_c)
- renamed some fields for better clarity on contained value
2026-05-10 13:39:18 +02:00
1b2ace0612 refactor: PlantInfo structure (consistent layout)
- fix: use tagged enum serialization for MoistureSensorError and PumpError
- fix: flatten PlantInfo sensors to SensorTelemetry with top-level moisture_pct
2026-05-10 13:39:16 +02:00
9015a6376d refactor: BatteryInfo structure (consistent layout)
- use tagged enum serialization for BatteryError
- flatten BatteryInfo telemetry with consistent field names and typed error
2026-05-10 13:39:15 +02:00
4893cbce55 fix: serialize firmware/state as JSON instead of Debug format 2026-05-10 13:39:11 +02:00
6 changed files with 34 additions and 14 deletions

View File

@@ -120,6 +120,15 @@ pub struct Esp<'a> {
// CPU cores/threads, reconsider this. // CPU cores/threads, reconsider this.
unsafe impl Send for Esp<'_> {} unsafe impl Send for Esp<'_> {}
macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
x
}};
}
impl Esp<'_> { impl Esp<'_> {
pub fn get_time(&self) -> DateTime<Utc> { pub fn get_time(&self) -> DateTime<Utc> {
DateTime::from_timestamp_micros(self.rtc.current_time_us() as i64) DateTime::from_timestamp_micros(self.rtc.current_time_us() as i64)

View File

@@ -282,7 +282,14 @@ pub struct FreePeripherals<'a> {
pub adc1: ADC1<'a>, pub adc1: ADC1<'a>,
} }
use crate::util::mk_static; macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
x
}};
}
impl PlantHal { impl PlantHal {
pub async fn create() -> Result<Mutex<CriticalSectionRawMutex, HAL<'static>>, FatError> { pub async fn create() -> Result<Mutex<CriticalSectionRawMutex, HAL<'static>>, FatError> {

View File

@@ -71,7 +71,6 @@ mod mqtt;
mod network; mod network;
mod plant_state; mod plant_state;
mod tank; mod tank;
mod util;
mod webserver; mod webserver;
extern crate alloc; extern crate alloc;

View File

@@ -110,7 +110,14 @@ async fn publish_inner(subtopic: &str, message: &str) -> FatResult<()> {
} }
} }
use crate::util::mk_static; macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
x
}};
}
pub async fn mqtt_init( pub async fn mqtt_init(
network_config: &'static NetworkConfig, network_config: &'static NetworkConfig,

View File

@@ -3,7 +3,6 @@ use crate::config::NetworkConfig;
use crate::fat_error::{ContextExt, FatError, FatResult}; use crate::fat_error::{ContextExt, FatError, FatResult};
use crate::hal::{PlantHal, HAL}; use crate::hal::{PlantHal, HAL};
use crate::mqtt; use crate::mqtt;
use crate::util::mk_static;
use alloc::string::{String, ToString}; use alloc::string::{String, ToString};
use alloc::sync::Arc; use alloc::sync::Arc;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
@@ -197,6 +196,15 @@ pub(crate) async fn run_dhcp(stack: Stack<'static>, ip: Ipv4Addr) {
} }
} }
macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
x
}};
}
pub async fn wifi_ap( pub async fn wifi_ap(
ssid: String, ssid: String,
interface_ap: Interface<'static>, interface_ap: Interface<'static>,

View File

@@ -1,10 +0,0 @@
macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
x
}};
}
pub(crate) use mk_static;