diff --git a/src/config.rs b/src/config.rs index 0fffdd5..32445ab 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,7 +6,7 @@ use esp_hal::peripherals::FLASH; use esp_storage::FlashStorage; use int_enum::IntEnum; use sequential_storage::{ - cache::Cache, + cache::{Cache, Uncached}, map::{Key, MapConfig, MapStorage, SerializationError}, }; @@ -21,18 +21,18 @@ impl ConfigCommand { pub static CONFIG_SERVICE: RpcService = RpcService::new(); -pub fn start_config(spawner: Spawner, flash: FLASH<'static>) { - spawner.spawn(config_handler(flash).unwrap()); -} - -#[embassy_executor::task] -async fn config_handler(flash: FLASH<'static>) { - let mut storage = MapStorage::::new( +pub async fn start_config(spawner: Spawner, flash: FLASH<'static>) { + let storage = MapStorage::::new( BlockingAsync::new(FlashStorage::new(flash)), const { MapConfig::new(0x3F_0000..0x40_0000) }, Cache::new_uncached(), ); + spawner.spawn(config_handler(storage).unwrap()); +} + +#[embassy_executor::task] +async fn config_handler(mut storage: MapStorage>, Cache>) { let mut data_buffer = [0u8; 256]; loop { @@ -40,14 +40,13 @@ async fn config_handler(flash: FLASH<'static>) { match req { ConfigCommand::SetStationCreds() => { - todo!() - // if storage - // .store_item(&mut data_buffer, &ConfigKey::Wifi, ) - // .await - // .is_ok() - // { - // served.respond(()); - // } + if storage + .store_item(&mut data_buffer, &ConfigKey::Wifi, &256) + .await + .is_ok() + { + served.respond(()); + } } } }