Skip to content

Commit 11e0a5b

Browse files
committed
network_common.cpp: replace blocking getLocalTime(), with non-blocking code. fixes #110
1 parent 9f51dfd commit 11e0a5b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

SmartEVSE-3/src/network_common.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,10 +1499,12 @@ void WiFiSetup(void) {
14991499
void network_loop() {
15001500
static unsigned long lastCheck_net = 0;
15011501
static int seconds = 0;
1502+
time_t now;
15021503
if (millis() - lastCheck_net >= 1000) {
15031504
lastCheck_net = millis();
15041505
//this block is for non-time critical stuff that needs to run approx 1 / second
1505-
getLocalTime(&timeinfo, 1000U);
1506+
time(&now); // get seconds since Epoch
1507+
localtime_r(&now, &timeinfo); // convert seconds to localtime
15061508
if (!LocalTimeSet && WIFImode == 1) {
15071509
_LOG_A("Time not synced with NTP yet.\n");
15081510
}

0 commit comments

Comments
 (0)