Improve form for Setup

This commit is contained in:
Mathieu Maret 2016-03-14 17:36:56 +01:00
parent 25010e63c0
commit cbbf4b2b3d

View File

@ -9,14 +9,31 @@ void handleRoot() {
} }
void handleSetup() { void handleSetup() {
uint8_t mode;
char *confSsid = "";
char *confPassword = "";
char *confHost = "";
char *mqttServer = "";
char *mqttUser = "";
char *mqttPasswd = "";
int mqttPort = 1883;
readEEPROM(mode, &confSsid, &confPassword, &confHost, &mqttServer, &mqttUser, &mqttPasswd, mqttPort);
server.send(200, "text/html", "<form action=\"/save\" method=\"get\">" server.send(200, "text/html", "<form action=\"/save\" method=\"get\">"
"<div><label for=\"ssid\">Wifi SSID :</label> <input type=\"text\" name=\"ssid\" /></div>" "<fieldset>"
"<legend>Wifi configuration:</legend>"
"<div><label for=\"ssid\">Wifi SSID :</label> <input type=\"text\" name=\"ssid\" value=\"" + String(confSsid) + "\" /></div>"
"<div><label for=\"password\">Wifi Password :</label><input type=\"password\" name=\"password\" /> </div>" "<div><label for=\"password\">Wifi Password :</label><input type=\"password\" name=\"password\" /> </div>"
"<div><label for=\"host\">Hostname :</label><input type=\"text\" name=\"host\" /> </div>" "<div><label for=\"host\">Hostname :</label><input type=\"text\" name=\"host\" value=\"" + String(confHost) +"\" /> </div>"
"<div><label for=\"mqttServer\">MQTTServer :</label><input type=\"text\" name=\"mqttServer\" /> </div>" "</fieldset>"
"<div><label for=\"mqttUser\">MQTTUsername :</label><input type=\"text\" name=\"mqttUser\" /> </div>" "<fieldset>"
"<div><label for=\"mqttPasswd\">MQTTPassword :</label><input type=\"text\" name=\"mqttPasswd\" /> </div>" "<legend>MQTT:</legend>"
"<div><label for=\"mqttPort\">MQTTPort :</label><input type=\"text\" name=\"mqttPort\" value=\"1883\" /> </div>" "<div><label for=\"mqttServer\">MQTTServer :</label><input type=\"text\" name=\"mqttServer\" value=\""+ String(mqttServer) +"\" /> </div>"
"<div><label for=\"mqttUser\">MQTTUsername :</label><input type=\"text\" name=\"mqttUser\" value=\""+ String(mqttUser) +"\" /> </div>"
"<div><label for=\"mqttPasswd\">MQTTPassword :</label><input type=\"password\" name=\"mqttPasswd\" /> </div>"
"<div><label for=\"mqttPort\">MQTTPort :</label><input type=\"text\" name=\"mqttPort\" value=\""+ String(mqttPort) +"\" /> </div>"
"</fieldset>"
"<div class=\"button\"> <button type=\"submit\">Save</button></div>" "<div class=\"button\"> <button type=\"submit\">Save</button></div>"
"</form>"); "</form>");
} }