Skip to content

Commit 6f33525

Browse files
committed
Set time only if valid
1 parent bed249c commit 6f33525

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

esp8266-ledclock/esp8266-ledclock.ino

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,20 @@ void handleForm() {
6161
if (tz.length()) {
6262
timezone = tz.toInt();
6363
}
64-
setTime(getNtpTime());
65-
64+
65+
time_t newTime = getNtpTime();
66+
if (newTime) {
67+
setTime(newTime);
68+
}
6669
String syncInt = server.arg("ntpint");
6770
syncInterval = syncInt.toInt();
6871

6972
clockName = server.arg("clockname");
70-
7173
httpUpdateResponse = "The configuration was updated.";
7274

73-
//server.send(200, "text/plain", response);
7475
server.sendHeader("Location", "/");
7576
server.send(302, "text/plain", "Moved");
76-
//handleRoot();
77+
7778
saveSettings();
7879
if (update_wifi == "1") {
7980
delay(500);

esp8266-ledclock/ntp.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ byte sendBuffer[] = {
1212
String ipToString(IPAddress ip) {
1313
uint32_t addr = ip;
1414
String ret;
15-
//ret = String(addr >> 24) + "." + String(addr >> 16 & 0xff) + "." + String(addr >> 8 & 0xff) + "." + String(addr & 0xff);
1615
ret = String(addr & 0xff) + "." + String(addr >> 8 & 0xff) + "." + String(addr >> 16 & 0xff) + "." + String(addr >> 24);
1716
return ret;
1817
}

0 commit comments

Comments
 (0)