more changes and linking

This commit is contained in:
Empire 2025-09-13 02:47:53 +02:00
parent 9de85b6e37
commit 4160202cdc
4 changed files with 11 additions and 17 deletions

View File

@ -24,7 +24,7 @@ debug = false
overflow-checks = true overflow-checks = true
panic = "abort" panic = "abort"
incremental = true incremental = true
opt-level = "z" opt-level = 3
[profile.release] [profile.release]
@ -35,7 +35,7 @@ debug = false
overflow-checks = true overflow-checks = true
panic = "abort" panic = "abort"
incremental = true incremental = true
opt-level = "z" opt-level = 3
[package.metadata.espflash] [package.metadata.espflash]

View File

@ -13,7 +13,7 @@ use alloc::{
use core::marker::PhantomData; use core::marker::PhantomData;
use core::net::IpAddr; use core::net::IpAddr;
use core::str::FromStr; use core::str::FromStr;
use embassy_time::Timer; use embassy_time::{Instant, Timer};
#[link_section = ".rtc.data"] #[link_section = ".rtc.data"]
static mut LAST_WATERING_TIMESTAMP: [i64; PLANT_COUNT] = [0; PLANT_COUNT]; static mut LAST_WATERING_TIMESTAMP: [i64; PLANT_COUNT] = [0; PLANT_COUNT];
@ -53,6 +53,7 @@ pub struct MqttClient<'a> {
pub struct Esp<'a> { pub struct Esp<'a> {
pub(crate) mqtt_client: Option<MqttClient<'a>>, pub(crate) mqtt_client: Option<MqttClient<'a>>,
pub(crate) dummy: PhantomData<&'a ()>, pub(crate) dummy: PhantomData<&'a ()>,
pub(crate) wall_clock_offset: u64
//pub(crate) wifi_driver: EspWifi<'a>, //pub(crate) wifi_driver: EspWifi<'a>,
//pub(crate) boot_button: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>, //pub(crate) boot_button: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
} }
@ -87,13 +88,9 @@ impl Esp<'_> {
//self.time() //self.time()
todo!(); todo!();
} }
pub(crate) fn time(&mut self) -> anyhow::Result<DateTime<Utc>> { pub(crate) fn time(&mut self) -> DateTime<Utc> {
bail!("todo"); let wall_clock = Instant::now().as_millis() + self.wall_clock_offset;
// let time = EspSystemTime {}.now().as_millis(); DateTime::from_timestamp_millis(wall_clock as i64).unwrap()
// let smaller_time = time as i64;
// let local_time = DateTime::from_timestamp_millis(smaller_time)
// .ok_or(anyhow!("could not convert timestamp"))?;
// anyhow::Ok(local_time)
} }
pub(crate) async fn wifi_scan(&mut self) -> anyhow::Result<Vec<AccessPointInfo>> { pub(crate) async fn wifi_scan(&mut self) -> anyhow::Result<Vec<AccessPointInfo>> {

View File

@ -212,7 +212,8 @@ impl PlantHal {
// //
let mut esp = Esp { let mut esp = Esp {
mqtt_client: None, mqtt_client: None,
dummy: PhantomData::default() dummy: PhantomData::default(),
wall_clock_offset : 0
// wifi_driver, // wifi_driver,
// boot_button // boot_button
}; };

View File

@ -182,12 +182,8 @@ async fn safe_main() -> anyhow::Result<()> {
.or_else(|err| { .or_else(|err| {
info!("rtc module error: {:?}", err); info!("rtc module error: {:?}", err);
board.board_hal.general_fault(true); board.board_hal.general_fault(true);
board.board_hal.get_esp().time() anyhow::Ok(board.board_hal.get_esp().time())
}) })?;
.map_err(|err| -> Result<(), _> {
bail!("time error {}", err);
})
.unwrap();
//check if we know the time current > 2020 (plausibility checks, this code is newer than 2020) //check if we know the time current > 2020 (plausibility checks, this code is newer than 2020)
if cur.year() < 2020 { if cur.year() < 2020 {