refactor: consolidate logging and time handling, remove TIME_ACCESS and LOG_ACCESS

This commit is contained in:
2026-04-10 18:53:30 +02:00
parent 301298522b
commit bc25fef5ec
7 changed files with 232 additions and 302 deletions

View File

@@ -1,5 +1,5 @@
use crate::fat_error::{FatError, FatResult};
use crate::hal::{esp_time, PLANT_COUNT};
use crate::hal::PLANT_COUNT;
use crate::log::LogMessage;
use crate::plant_state::{MoistureSensorState, PlantState};
use crate::tank::determine_tank_state;
@@ -174,7 +174,7 @@ pub(crate) async fn get_time<T, const N: usize>(
},
};
let native = esp_time().await.with_timezone(&tz).to_rfc3339();
let native = board.board_hal.get_time().await.with_timezone(&tz).to_rfc3339();
let rtc = match board.board_hal.get_rtc_module().get_rtc_time().await {
Ok(time) => time.with_timezone(&tz).to_rfc3339(),

View File

@@ -1,6 +1,6 @@
use crate::config::PlantControllerConfig;
use crate::fat_error::FatResult;
use crate::hal::{esp_set_time, Detection};
use crate::hal::Detection;
use crate::webserver::read_up_to_bytes_from_request;
use crate::{do_secure_pump, BOARD_ACCESS};
use alloc::string::{String, ToString};
@@ -109,7 +109,8 @@ where
let actual_data = read_up_to_bytes_from_request(request, None).await?;
let time: SetTime = serde_json::from_slice(&actual_data)?;
let parsed = DateTime::parse_from_rfc3339(time.time)?;
esp_set_time(parsed).await?;
let mut board = BOARD_ACCESS.get().await.lock().await;
board.board_hal.set_time(&parsed).await?;
Ok(None)
}