From 9921377148df078333d36af2ebc88875249a4b67 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 3 Feb 2022 18:46:51 +0800 Subject: [PATCH] make sure the connection manager doesn't race with user settings If the connection manager isn't paused while a user sets up a network, it could decide that the currently partially configured status is crap and then overwrite it with a saved configuration. Pause the connection manager and make the user aware of this situation. --- services/shellchat/src/cmds/wlan.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/shellchat/src/cmds/wlan.rs b/services/shellchat/src/cmds/wlan.rs index 498231a49..683e68b1f 100644 --- a/services/shellchat/src/cmds/wlan.rs +++ b/services/shellchat/src/cmds/wlan.rs @@ -65,7 +65,7 @@ impl<'a> ShellCmdApi<'a> for Wlan { let _ = match env.com.wlan_set_ssid(val.as_str().expect("not valid utf-8")) { Ok(_) => { self.current_ssid = Some(std::string::String::from(val.as_str().unwrap())); - write!(ret, "wlan setssid {}", val).unwrap() + write!(ret, "wlan setssid {}. Connection manager paused during configuration.", val).unwrap() }, Err(_) => write!(ret, "Error: SSID too long for WF200").unwrap(), }; @@ -78,7 +78,7 @@ impl<'a> ShellCmdApi<'a> for Wlan { let _ = match env.com.wlan_set_pass(val.as_str().expect("not valid utf-8")) { Ok(_) => { self.current_pass = Some(std::string::String::from(val.as_str().unwrap())); - write!(ret, "wlan setpass {}", val).unwrap() + write!(ret, "wlan setpass {}. Connection manager paused during configuration.", val).unwrap() }, Err(_) => write!(ret, "Error: passphrase too long for WF200").unwrap(), }; @@ -99,7 +99,7 @@ impl<'a> ShellCmdApi<'a> for Wlan { // for now, we should always call flush at the end of a routine; perhaps in the // future we'll have a timer that automatically syncs the pddb entry.flush().expect("couldn't sync pddb cache"); - write!(ret, "SSID/pass combo saved to PDDB").unwrap(); + write!(ret, "SSID/pass combo saved to PDDB. Connection manager started.").unwrap(); // restart the connection manager now that the key combo has been committed env.netmgr.connection_manager_run().unwrap(); } @@ -137,8 +137,7 @@ impl<'a> ShellCmdApi<'a> for Wlan { "join" => { let _ = match env.com.wlan_join() { Ok(_) => { - write!(ret, "wlan join. Connection manager started.").unwrap(); - env.netmgr.connection_manager_run().unwrap(); + write!(ret, "wlan join. Connection manager still paused, use `save` to resume connection manager.").unwrap(); }, Err(e) => write!(ret, "Error: {:?}", e).unwrap(), };