MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / runSync

Method runSync

src/activities/settings/ClockSyncActivity.cpp:59–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void ClockSyncActivity::runSync() {
60 if (WiFi.status() != WL_CONNECTED) {
61 LOG_INF("CLK", "Manual sync requested but WiFi is not connected after selection");
62 state = NO_WIFI;
63 requestUpdate();
64 return;
65 }
66
67 const bool ok = halClock.syncFromNTP();
68 if (!ok) {
69 state = FAILED;
70 requestUpdate();
71 return;
72 }
73
74 // Mark as synced so the auto-sync hook stops firing on future WiFi connects.
75 SETTINGS.clockHasBeenSynced = 1;
76 SETTINGS.saveToFile();
77
78 // Read the freshly synced time back for the user-facing confirmation.
79 char buf[9];
80 if (halClock.formatTime(buf, sizeof(buf), SETTINGS.clockUtcOffsetQ, SETTINGS.clockFormat == 1)) {
81 snprintf(syncedTime, sizeof(syncedTime), "%s", buf);
82 }
83 state = SUCCESS;
84 requestUpdate();
85}
86
87void ClockSyncActivity::loop() {
88 if (state == SYNCING) {

Callers

nothing calls this directly

Calls 3

syncFromNTPMethod · 0.80
formatTimeMethod · 0.80
saveToFileMethod · 0.45

Tested by

no test coverage detected