diff --git a/src/main.cpp b/src/main.cpp index eb6dea327..45f4eb7b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -428,10 +428,17 @@ void setup() #endif #if ARCH_PORTDUINO + RTCQuality ourQuality = RTCQualityDevice; + + std::string timeCommandResult = exec("timedatectl status | grep synchronized | grep yes -c"); + if (timeCommandResult[0] == '1') { + ourQuality = RTCQualityNTP; + } + struct timeval tv; tv.tv_sec = time(NULL); tv.tv_usec = 0; - perhapsSetRTC(RTCQualityDevice, &tv); + perhapsSetRTC(ourQuality, &tv); #endif powerMonInit();