mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
now changes when time is set
fix logic
This commit is contained in:
parent
d5063d1ff0
commit
4319ac4f45
1 changed files with 6 additions and 5 deletions
|
|
@ -178,10 +178,10 @@ pub(crate) fn ntp_updater(time_conn: xous::CID) {
|
||||||
let trng = trng::Trng::new(&xns).unwrap();
|
let trng = trng::Trng::new(&xns).unwrap();
|
||||||
let netmgr = net::NetManager::new();
|
let netmgr = net::NetManager::new();
|
||||||
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
||||||
let now = SystemTime::now();
|
let mut now = SystemTime::now();
|
||||||
let mut last_update = 0;
|
let mut force_update = true;
|
||||||
loop {
|
loop {
|
||||||
if last_update == 0 || (now.elapsed().unwrap().as_secs() - last_update) > 3600 * 24 { // once a day in real time
|
if force_update || now.elapsed().unwrap().as_secs() > 3600 * 24 { // once a day in real time
|
||||||
// check if we have a network connection. if not, repeat the loop, after a short delay
|
// check if we have a network connection. if not, repeat the loop, after a short delay
|
||||||
match netmgr.get_ipv4_config() {
|
match netmgr.get_ipv4_config() {
|
||||||
Some(conf) => {
|
Some(conf) => {
|
||||||
|
|
@ -220,7 +220,8 @@ pub(crate) fn ntp_updater(time_conn: xous::CID) {
|
||||||
0, 0,
|
0, 0,
|
||||||
)
|
)
|
||||||
).expect("couldn't set time");
|
).expect("couldn't set time");
|
||||||
last_update = now.elapsed().unwrap().as_secs();
|
now = SystemTime::now();
|
||||||
|
force_update = false;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// if NTP server is down, wait a bit longer and try again
|
// if NTP server is down, wait a bit longer and try again
|
||||||
|
|
@ -232,4 +233,4 @@ pub(crate) fn ntp_updater(time_conn: xous::CID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue