extract rtc module, extract tank module, fix backupview refresh, switch to embedded storage for eeprom

This commit is contained in:
2025-06-25 01:18:36 +02:00
parent 5fb8705d9a
commit 6b711e29fc
14 changed files with 851 additions and 869 deletions

View File

@@ -8,7 +8,7 @@ use crate::{
plant_state::{MoistureSensorState, PlantState},
BOARD_ACCESS,
};
use anyhow::bail;
use anyhow::{bail, Context};
use chrono::DateTime;
use core::result::Result::Ok;
use embedded_svc::http::Method;
@@ -60,7 +60,7 @@ pub struct TestPump {
#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct WebBackupHeader {
timestamp: std::string::String,
size: usize,
size: u16,
}
#[derive(Deserialize)]
@@ -208,10 +208,9 @@ fn backup_info(
};
serde_json::to_string(&wbh)?
}
Err(_) => {
//TODO make better
Err(err) => {
let wbh = WebBackupHeader {
timestamp: "no backup".to_owned(),
timestamp: err.to_string(),
size: 0,
};
serde_json::to_string(&wbh)?
@@ -286,7 +285,12 @@ fn tank_info(
let mut board = BOARD_ACCESS.lock().unwrap();
let tank_info = determine_tank_state(&mut board);
//should be multsampled
let water_temp = board.board_hal.water_temperature_c();
let water_temp = board
.board_hal
.get_tank_sensor()
.context("no sensor")
.and_then(|f| f.water_temperature_c());
Ok(Some(serde_json::to_string(&tank_info.as_mqtt_info(
&board.board_hal.get_config().tank,
&water_temp,