mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-06 18:08:00 +00:00
Detect if NTP is active on native
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -428,10 +428,18 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ARCH_PORTDUINO
|
#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;
|
struct timeval tv;
|
||||||
tv.tv_sec = time(NULL);
|
tv.tv_sec = time(NULL);
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
perhapsSetRTC(RTCQualityDevice, &tv);
|
perhapsSetRTC(ourQuality, &tv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
powerMonInit();
|
powerMonInit();
|
||||||
|
|||||||
Reference in New Issue
Block a user