mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
chore: restructure preference loading with userprefs::Manager::all() instead of individual calls
This commit is contained in:
parent
e11bef1eff
commit
a3a94ad50a
1 changed files with 19 additions and 33 deletions
|
|
@ -380,6 +380,14 @@ fn wrapped_main() -> ! {
|
||||||
let prefs = prefs_thread_clone.lock().unwrap();
|
let prefs = prefs_thread_clone.lock().unwrap();
|
||||||
let netmgr = net::NetManager::new();
|
let netmgr = net::NetManager::new();
|
||||||
|
|
||||||
|
let all_prefs = match prefs.all() {
|
||||||
|
Ok(p) => p,
|
||||||
|
Err(error) => {
|
||||||
|
log::error!("cannot read preference store: {:?}", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if !pddb_poller.is_mounted_nonblocking() {
|
if !pddb_poller.is_mounted_nonblocking() {
|
||||||
continue
|
continue
|
||||||
|
|
@ -387,46 +395,24 @@ fn wrapped_main() -> ! {
|
||||||
|
|
||||||
log::debug!("pddb ready, loading preferences now!");
|
log::debug!("pddb ready, loading preferences now!");
|
||||||
|
|
||||||
match prefs.radio_on_on_boot_or_default() {
|
match all_prefs.radio_on_on_boot {
|
||||||
Ok(value) => if let true = value {
|
true => netmgr.connection_manager_wifi_off_and_stop(),
|
||||||
netmgr.connection_manager_wifi_off_and_stop()
|
false => netmgr.connection_manager_wifi_on(),
|
||||||
} 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| {
|
}.unwrap_or_else(|error| {
|
||||||
log::error!("cannot set radio status: {:?}", error)
|
log::error!("cannot set radio status: {:?}", error)
|
||||||
});
|
});
|
||||||
|
|
||||||
match prefs.connect_known_networks_on_boot_or_default() {
|
match all_prefs.connect_known_networks_on_boot {
|
||||||
Ok(value) => if let true = value {
|
true => netmgr.connection_manager_run(),
|
||||||
netmgr.connection_manager_run()
|
false => netmgr.connection_manager_stop(),
|
||||||
} 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| {
|
}.unwrap_or_else(|error| {
|
||||||
log::error!("cannot set radio status: {:?}", error)
|
log::error!("cannot start connection manager: {:?}", error)
|
||||||
});
|
});
|
||||||
|
|
||||||
match prefs.autobacklight_on_boot_or_default() {
|
match all_prefs.autobacklight_on_boot {
|
||||||
Ok(value) => if let true = value {
|
true => send_message(status_cid, Message::new_scalar(
|
||||||
send_message(status_cid, Message::new_scalar(
|
StatusOpcode::EnableAutomaticBacklight.to_usize().unwrap(), 0,0,0,0)),
|
||||||
StatusOpcode::EnableAutomaticBacklight.to_usize().unwrap(), 0,0,0,0))
|
false => Ok(xous::Result::Ok),
|
||||||
} else {
|
|
||||||
send_message(status_cid, Message::new_scalar(
|
|
||||||
StatusOpcode::DisableAutomaticBacklight.to_usize().unwrap(), 0,0,0,0))
|
|
||||||
},
|
|
||||||
Err(error) => {
|
|
||||||
log::error!("cannot read preference value for autobacklight_on_boot: {:?}", error);
|
|
||||||
Ok(xous::Result::Ok)
|
|
||||||
}
|
|
||||||
}.unwrap_or_else(|error| {
|
}.unwrap_or_else(|error| {
|
||||||
log::error!("cannot set autobacklight status: {:?}", error);
|
log::error!("cannot set autobacklight status: {:?}", error);
|
||||||
xous::Result::Ok
|
xous::Result::Ok
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue