From 9ce1a7ff796bc4f39f5f51dd504a3f587bf58ca8 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 13 Dec 2025 12:08:24 -0600 Subject: [PATCH] Detect if NTP is active on native --- src/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index eb6dea327..f05ee940b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -428,10 +428,18 @@ void setup() #endif #if ARCH_PORTDUINO + RTCQuality ourQuality = RTCQualityDevice; + + std::string timeCommandResult = exec("timedatectl status | grep synchronized | grep yes -c"); + if (timeCommandResult[0] == '1') { + LOG_WARN("Setting time"); + ourQuality = RTCQualityNTP; + } + struct timeval tv; tv.tv_sec = time(NULL); tv.tv_usec = 0; - perhapsSetRTC(RTCQualityDevice, &tv); + perhapsSetRTC(ourQuality, &tv); #endif powerMonInit();