more changes and linking

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

View File

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