missedUpdates
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
#include <wizHelper.h>
|
||||
|
||||
|
||||
static t_seconds seconds = { .seconds = 0, .valid = false };
|
||||
static t_seconds seconds = { .seconds = 0, .missedUpdates = 0, .valid = false };
|
||||
|
||||
|
||||
static void networkSecondsHandler(void *handle) {
|
||||
@ -20,15 +20,18 @@ static void networkSecondsHandler(void *handle) {
|
||||
if (tmpSeconds != 0) {
|
||||
coloredMsg(LOG_YELLOW, "nsh, success, time is %lu", tmpSeconds);
|
||||
seconds.seconds = tmpSeconds;
|
||||
seconds.missedUpdates = 0;
|
||||
seconds.valid = true;
|
||||
} else {
|
||||
coloredMsg(LOG_YELLOW, "nsh, failed");
|
||||
seconds.missedUpdates += 1;
|
||||
}
|
||||
} else if (tryAgain || ((seconds.seconds % 3600) == 0)) {
|
||||
coloredMsg(LOG_YELLOW, "nsh, periodically querying time");
|
||||
uint64_t tmpSeconds = wizSntpQuery();
|
||||
if (tmpSeconds != 0) {
|
||||
coloredMsg(LOG_YELLOW, "nsh, success, network time is %lu", tmpSeconds);
|
||||
seconds.missedUpdates = 0;
|
||||
tryAgain = false;
|
||||
if (seconds.seconds != tmpSeconds) {
|
||||
coloredMsg(LOG_YELLOW, "nsh, local time updated");
|
||||
@ -38,6 +41,7 @@ static void networkSecondsHandler(void *handle) {
|
||||
}
|
||||
} else {
|
||||
coloredMsg(LOG_YELLOW, "nsh, failed, trying again ...");
|
||||
seconds.missedUpdates += 1;
|
||||
tryAgain = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user