more changes and linking
This commit is contained in:
		| @@ -24,7 +24,7 @@ debug = false | ||||
| overflow-checks = true | ||||
| panic = "abort" | ||||
| incremental = true | ||||
| opt-level = "z" | ||||
| opt-level = 3 | ||||
|  | ||||
|  | ||||
| [profile.release] | ||||
| @@ -35,7 +35,7 @@ debug = false | ||||
| overflow-checks = true | ||||
| panic = "abort" | ||||
| incremental = true | ||||
| opt-level = "z" | ||||
| opt-level = 3 | ||||
|  | ||||
|  | ||||
| [package.metadata.espflash] | ||||
|   | ||||
| @@ -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>> { | ||||
|   | ||||
| @@ -212,7 +212,8 @@ impl PlantHal { | ||||
|         // | ||||
|         let mut esp = Esp { | ||||
|              mqtt_client: None, | ||||
|             dummy: PhantomData::default() | ||||
|             dummy: PhantomData::default(), | ||||
|             wall_clock_offset : 0 | ||||
|         //     wifi_driver, | ||||
|         //     boot_button | ||||
|          }; | ||||
|   | ||||
| @@ -182,12 +182,8 @@ async fn safe_main() -> anyhow::Result<()> { | ||||
|         .or_else(|err| { | ||||
|             info!("rtc module error: {:?}", err); | ||||
|             board.board_hal.general_fault(true); | ||||
|             board.board_hal.get_esp().time() | ||||
|         }) | ||||
|         .map_err(|err| -> Result<(), _> { | ||||
|             bail!("time error {}", err); | ||||
|         }) | ||||
|         .unwrap(); | ||||
|             anyhow::Ok(board.board_hal.get_esp().time()) | ||||
|         })?; | ||||
|  | ||||
|     //check if we know the time current > 2020 (plausibility checks, this code is newer than 2020) | ||||
|     if cur.year() < 2020 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user