Skip to content

Commit aa649b9

Browse files
committed
Tweak http update response
1 parent a27f84f commit aa649b9

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

esp8266-ledclock/esp8266-ledclock.ino

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ESP8266WebServer server (80);
2626
String clockName = "";
2727
String w_ssid;
2828
String w_psk;
29+
String httpUpdateResponse;
2930
long timezone;
3031
IPAddress timeServer(129, 6, 15, 28);
3132
time_t prevDisplay = 0;
@@ -41,38 +42,38 @@ void handleRoot() {
4142
s.replace("@@NTPINT@@", String(syncInterval));
4243
s.replace("@@SYNCSTATUS@@", timeStatus() == timeSet ? "OK" : "Overdue");
4344
s.replace("@@CLOCKNAME@@", clockName);
45+
s.replace("@@UPDATERESPONSE@@", httpUpdateResponse);
46+
httpUpdateResponse = "";
4447
server.send(200, "text/html", s);
4548
}
4649

4750
void handleForm() {
48-
String response = "The following was changed:\r\n\r\n";
4951
String update_wifi = server.arg("update_wifi");
5052
String t_ssid = server.arg("ssid");
5153
String t_psk = server.arg("psk");
5254
timeServer = parseIP(server.arg("ntpsrv"));
5355
if (update_wifi == "1") {
54-
response += "Wifi SSID set to: " + t_ssid + "\r\n";
55-
response += "Wifi PSK set to : " + t_psk + "\r\n";
5656
w_ssid = t_ssid;
5757
w_psk = t_psk;
5858
}
5959
String tz = server.arg("timezone");
6060

6161
if (tz.length()) {
62-
response += "The timezone set to: " + tz + "h\r\n";
6362
timezone = tz.toInt();
6463
}
65-
response += "The NTP server is set to: " + ipToString(timeServer) + "\r\n";
6664
setTime(getNtpTime());
6765

6866
String syncInt = server.arg("ntpint");
6967
syncInterval = syncInt.toInt();
70-
response += "The NTP sync interval is: " + syncInt + "s\r\n";
7168

7269
clockName = server.arg("clockname");
73-
response += "Clock name is: " + clockName;
7470

75-
server.send(200, "text/plain", response);
71+
httpUpdateResponse = "The configuration was updated.";
72+
73+
//server.send(200, "text/plain", response);
74+
server.sendHeader("Location", "/");
75+
server.send(302, "text/plain", "Moved");
76+
//handleRoot();
7677
saveSettings();
7778
if (update_wifi == "1") {
7879
delay(500);

esp8266-ledclock/mainPage.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ const char MAIN_page[] PROGMEM = R"=====(
77
body {font-family: helvetica,arial,sans-serif;}
88
table {border-collapse: collapse; border: 1px solid black;}
99
td {padding: 0.25em;}
10+
.title { font-size: 2em; font-weight: bold;}
11+
.name {padding: 0.5em;}
1012
.heading {font-weight: bold; background: #c0c0c0; padding: 0.5em;}
13+
.update {color: #dd3333; font-size: 0.75em;}
1114
</style>
1215
</head>
13-
<h1>NTP Clock</h1>
16+
<div class=title>NTP Clock</div>
17+
<div class=name>Location: @@CLOCKNAME@@</div>
1418
<form method="post" action="/form">
1519
<table>
1620
<tr><td colspan=2 class=heading>Status</td></tr>
@@ -31,7 +35,7 @@ const char MAIN_page[] PROGMEM = R"=====(
3135
<p/>
3236
<input type="submit" value="Update">
3337
</form>
34-
38+
<div class="update">@@UPDATERESPONSE@@</div>
3539
</html>
3640
)=====";
3741

0 commit comments

Comments
 (0)