Detect if NTP is active on native

This commit is contained in:
Jonathan Bennett
2025-12-13 12:08:24 -06:00
parent 68250dc937
commit 9ce1a7ff79

View File

@@ -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();