diff --git a/Cargo.lock b/Cargo.lock index 3a5326836..da0e58750 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3657,6 +3657,7 @@ dependencies = [ "sntpc", "trng", "usb-device-xous", + "userprefs", "utralib", "xous 0.9.12 (registry+https://github.com/rust-lang/crates.io-index)", "xous-api-log", diff --git a/services/status/Cargo.toml b/services/status/Cargo.toml index 5cf488a72..1b7e2b9fb 100644 --- a/services/status/Cargo.toml +++ b/services/status/Cargo.toml @@ -27,6 +27,7 @@ pddb = {path = "../pddb"} net = {path = "../net"} keyboard = {path = "../keyboard"} usb-device-xous = {path="../usb-device-xous"} +userprefs = {path = "../../libs/userprefs"} num-derive = {version = "0.3.3", default-features = false} num-traits = {version = "0.2.14", default-features = false} diff --git a/services/status/src/main.rs b/services/status/src/main.rs index 6e1251356..b4f5bcf44 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -213,12 +213,43 @@ fn wrapped_main() -> ! { } }); + // load system preferences + let prefs = userprefs::Manager::new(); + // ------------------ render initial graphical display, so we don't seem broken on boot let gam = gam::Gam::new(&xns).expect("|status: can't connect to GAM"); let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer"); let susres = susres::Susres::new_without_hook(&xns).unwrap(); let mut netmgr = net::NetManager::new(); + match prefs.radio_on_on_boot() { + Ok(value) => if let true = value { + netmgr.connection_manager_wifi_off_and_stop() + } else { + netmgr.connection_manager_wifi_on() + }, + Err(error) => { + log::error!("cannot read preference value for radio_on_on_boot: {}", error); + Ok(()) + } + }.unwrap_or_else(|error| { + log::error!("cannot set radio status: {}", error) + }); + + match prefs.connect_known_networks_on_boot() { + Ok(value) => if let true = value { + netmgr.connection_manager_run() + } else { + netmgr.connection_manager_stop() + }, + Err(error) => { + log::error!("cannot read preference value for connect_known_networks_on_boot: {}", error); + Ok(()) + } + }.unwrap_or_else(|error| { + log::error!("cannot set radio status: {}", error) + }); + // screensize is controlled by the GAM, it's set in main.rs near the top let screensize = gam .get_canvas_bounds(status_gid)