aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-06-23 21:32:00 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-06-27 09:14:36 +0200
commit640b8fd401eae8ff90bfcbb13f683326f522eabe (patch)
tree9c8cb83f20b83ddcdd1b56f97e10fe8b96acdcec /global-functions.rsc
parentec7adcf78e2533a81c43145023aaeaf3740fe729 (diff)
global-functions: $IsTimeSync: calculate with uptime, drop scheduler
Diffstat (limited to 'global-functions.rsc')
-rw-r--r--global-functions.rsc11
1 files changed, 6 insertions, 5 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index bdab5a2..b8da30b 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -518,17 +518,18 @@
:return true;
}
- :if ([ /system/resource/get uptime ] < 3m || $IsTimeSyncResetNtp = true) do={
+ :if ([ :typeof $IsTimeSyncResetNtp ] = "nothing") do={
+ :set IsTimeSyncResetNtp 0s;
+ }
+ :local Uptime [ /system/resource/get uptime ];
+ :if ($Uptime - $IsTimeSyncResetNtp < 3m) do={
:return false;
}
- :set IsTimeSyncResetNtp true;
+ :set IsTimeSyncResetNtp $Uptime;
/system/ntp/client/set enabled=no;
:delay 20ms;
/system/ntp/client/set enabled=yes;
- /system/scheduler/add name="clear-IsTimeSyncResetNtp" interval=1m \
- on-event=("/system/scheduler/remove clear-IsTimeSyncResetNtp; " . \
- ":global IsTimeSyncResetNtp; :set IsTimeSyncResetNtp;");
:return false;
}