fix config on submit not updated, fix startup initial always in ap mode
This commit is contained in:
parent
69077239a5
commit
3a2e59874e
@ -117,4 +117,10 @@ impl<'a> BoardInteraction<'a> for Initial<'a> {
|
|||||||
fn test(&mut self) -> Result<()> {
|
fn test(&mut self) -> Result<()> {
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_config(&mut self, config: PlantControllerConfig) -> anyhow::Result<()> {
|
||||||
|
self.config = config;
|
||||||
|
self.esp.save_config(&self.config)?;
|
||||||
|
anyhow::Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ pub trait BoardInteraction<'a> {
|
|||||||
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> Result<()>;
|
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> Result<()>;
|
||||||
fn test_pump(&mut self, plant: usize) -> Result<()>;
|
fn test_pump(&mut self, plant: usize) -> Result<()>;
|
||||||
fn test(&mut self) -> Result<()>;
|
fn test(&mut self) -> Result<()>;
|
||||||
|
fn set_config(&mut self, config: PlantControllerConfig) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FreePeripherals {
|
pub struct FreePeripherals {
|
||||||
|
@ -629,4 +629,10 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
self.esp.delay.delay_ms(10);
|
self.esp.delay.delay_ms(10);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_config(&mut self, config: PlantControllerConfig) -> anyhow::Result<()> {
|
||||||
|
self.config = config;
|
||||||
|
self.esp.save_config(&self.config)?;
|
||||||
|
anyhow::Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,4 +543,10 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
self.esp.delay.delay_ms(10);
|
self.esp.delay.delay_ms(10);
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_config(&mut self, config: PlantControllerConfig) -> anyhow::Result<()> {
|
||||||
|
self.config = config;
|
||||||
|
self.esp.save_config(&self.config)?;
|
||||||
|
anyhow::Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if board.board_hal.get_config().hardware.board == INITIAL {
|
if board.board_hal.get_config().hardware.board == INITIAL && board.board_hal.get_config().network.ssid.is_none(){
|
||||||
let _ = board.board_hal.get_esp().wifi_ap();
|
let _ = board.board_hal.get_esp().wifi_ap();
|
||||||
drop(board);
|
drop(board);
|
||||||
let reboot_now = Arc::new(AtomicBool::new(false));
|
let reboot_now = Arc::new(AtomicBool::new(false));
|
||||||
|
@ -219,9 +219,7 @@ fn set_config(
|
|||||||
let config: PlantControllerConfig = serde_json::from_slice(&all)?;
|
let config: PlantControllerConfig = serde_json::from_slice(&all)?;
|
||||||
|
|
||||||
let mut board = BOARD_ACCESS.lock().expect("board access");
|
let mut board = BOARD_ACCESS.lock().expect("board access");
|
||||||
board.board_hal.get_esp().save_config(&config)?;
|
board.board_hal.set_config(config);
|
||||||
|
|
||||||
//TODO fixme board.config = config;
|
|
||||||
anyhow::Ok(Some("saved".to_owned()))
|
anyhow::Ok(Some("saved".to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user