Add save timestamp support and log interceptor for enhanced debugging
- Introduced `created_at` metadata for saves, enabling timestamp tracking. - Added `InterceptorLogger` to capture logs, aiding in error diagnostics. - Updated web UI to display save creation timestamps. - Improved save/load functionality to maintain compatibility with older formats.
This commit is contained in:
@@ -167,7 +167,11 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
let cur = match board.board_hal.get_rtc_module().get_rtc_time().await {
|
||||
Ok(value) => {
|
||||
{
|
||||
board.board_hal.get_esp().rtc.set_current_time_us(value.timestamp_micros() as u64);
|
||||
board
|
||||
.board_hal
|
||||
.get_esp()
|
||||
.rtc
|
||||
.set_current_time_us(value.timestamp_micros() as u64);
|
||||
}
|
||||
value
|
||||
}
|
||||
@@ -332,7 +336,14 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
match err {
|
||||
TankError::SensorDisabled => { /* unreachable */ }
|
||||
TankError::SensorMissing(raw_value_mv) => {
|
||||
log(LogMessage::TankSensorMissing, raw_value_mv as u32, 0, "", "").await
|
||||
log(
|
||||
LogMessage::TankSensorMissing,
|
||||
raw_value_mv as u32,
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
)
|
||||
.await
|
||||
}
|
||||
TankError::SensorValueError { value, min, max } => {
|
||||
log(
|
||||
@@ -455,7 +466,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
pump_ineffective,
|
||||
result.median_current_ma,
|
||||
result.max_current_ma,
|
||||
result.min_current_ma
|
||||
result.min_current_ma,
|
||||
)
|
||||
.await;
|
||||
} else if !state.pump_in_timeout(plant_config, &timezone_time) {
|
||||
@@ -907,7 +918,7 @@ async fn pump_info(
|
||||
pump_ineffective: bool,
|
||||
median_current_ma: u16,
|
||||
max_current_ma: u16,
|
||||
min_current_ma: u16
|
||||
min_current_ma: u16,
|
||||
) {
|
||||
let pump_info = PumpInfo {
|
||||
enabled: pump_active,
|
||||
@@ -920,7 +931,11 @@ async fn pump_info(
|
||||
|
||||
match serde_json::to_string(&pump_info) {
|
||||
Ok(state) => {
|
||||
board.board_hal.get_esp().mqtt_publish(&pump_topic, &state).await;
|
||||
board
|
||||
.board_hal
|
||||
.get_esp()
|
||||
.mqtt_publish(&pump_topic, &state)
|
||||
.await;
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Error publishing pump state {err}");
|
||||
@@ -1167,7 +1182,7 @@ use embassy_time::WithTimeout;
|
||||
#[esp_rtos::main]
|
||||
async fn main(spawner: Spawner) -> ! {
|
||||
// intialize embassy
|
||||
logger::init_logger_from_env();
|
||||
crate::log::INTERCEPTOR.init();
|
||||
spawner.must_spawn(crate::log::log_task());
|
||||
//force init here!
|
||||
match BOARD_ACCESS.init(
|
||||
|
||||
Reference in New Issue
Block a user