fix: ignore computer sleep for telemetry clock (#577)

* fix: ignore computer sleep for telemetry clock

This uses unix time with regular integer comparisons to prevent the
telemetry clock from needing to wait for 8 hours of the program running.
Now, it only needs to wait 8 real-time hours instead.

* drop telemetry time to 4 hours, tick every 10 minutes
This commit is contained in:
Sylvie Crowe 2024-04-19 18:26:31 -07:00 committed by GitHub
parent 6336f87cf2
commit 8fdcf10cae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,8 +67,8 @@ const WSStateReconnectTime = 30 * time.Second
const WSStatePacketChSize = 20
const InitialTelemetryWait = 30 * time.Second
const TelemetryTick = 30 * time.Minute
const TelemetryInterval = 8 * time.Hour
const TelemetryTick = 10 * time.Minute
const TelemetryInterval = 4 * time.Hour
const MaxWriteFileMemSize = 20 * (1024 * 1024) // 20M
@ -930,12 +930,11 @@ func checkNewReleaseWrapper() {
}
func telemetryLoop() {
var lastSent time.Time
var nextSend int64
time.Sleep(InitialTelemetryWait)
for {
dur := time.Since(lastSent)
if lastSent.IsZero() || dur >= TelemetryInterval {
lastSent = time.Now()
if time.Now().Unix() > nextSend {
nextSend = time.Now().Add(TelemetryInterval).Unix()
sendTelemetryWrapper()
checkNewReleaseWrapper()
}