mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-19 00:04:25 +01:00
sphinx-key: don't hold flash lock during config server
This commit is contained in:
@@ -59,7 +59,7 @@ fn main() -> Result<()> {
|
|||||||
let flash_arc = Arc::new(Mutex::new(flash_per));
|
let flash_arc = Arc::new(Mutex::new(flash_per));
|
||||||
// BUTTON thread
|
// BUTTON thread
|
||||||
button_loop(pins.gpio9, led_tx.clone(), flash_arc.clone());
|
button_loop(pins.gpio9, led_tx.clone(), flash_arc.clone());
|
||||||
let mut flash = flash_arc.lock().unwrap();
|
let flash = flash_arc.lock().unwrap();
|
||||||
if let Ok(exist) = flash.read_config() {
|
if let Ok(exist) = flash.read_config() {
|
||||||
let seed = flash.read_seed().expect("no seed...");
|
let seed = flash.read_seed().expect("no seed...");
|
||||||
let id = flash.read_id().expect("no id...");
|
let id = flash.read_id().expect("no id...");
|
||||||
@@ -117,12 +117,14 @@ fn main() -> Result<()> {
|
|||||||
led_tx.send(Status::WifiAccessPoint).unwrap();
|
led_tx.send(Status::WifiAccessPoint).unwrap();
|
||||||
println!("=============> START SERVER NOW AND WAIT <==============");
|
println!("=============> START SERVER NOW AND WAIT <==============");
|
||||||
let stored_seed = flash.read_seed().ok();
|
let stored_seed = flash.read_seed().ok();
|
||||||
|
drop(flash);
|
||||||
match start_config_server_and_wait(
|
match start_config_server_and_wait(
|
||||||
peripherals.modem,
|
peripherals.modem,
|
||||||
default_nvs.clone(),
|
default_nvs.clone(),
|
||||||
stored_seed.is_some(),
|
stored_seed.is_some(),
|
||||||
) {
|
) {
|
||||||
Ok((_wifi, config, seed_opt)) => {
|
Ok((_wifi, config, seed_opt)) => {
|
||||||
|
let mut flash = flash_arc.lock().unwrap();
|
||||||
flash.write_config(config).expect("could not store config");
|
flash.write_config(config).expect("could not store config");
|
||||||
if stored_seed.is_none() {
|
if stored_seed.is_none() {
|
||||||
match seed_opt {
|
match seed_opt {
|
||||||
@@ -138,7 +140,6 @@ fn main() -> Result<()> {
|
|||||||
unsafe { esp_idf_sys::esp_restart() };
|
unsafe { esp_idf_sys::esp_restart() };
|
||||||
}
|
}
|
||||||
Err(msg) => {
|
Err(msg) => {
|
||||||
drop(flash);
|
|
||||||
log::error!("{}", msg);
|
log::error!("{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user