firmware WIP - add style.css 8)
This commit is contained in:
parent
f7c42a906d
commit
be590b2e2d
1 changed files with 40 additions and 7 deletions
|
@ -115,12 +115,19 @@ const bool APhidden = false;
|
||||||
ESP8266WebServer webserver(80);
|
ESP8266WebServer webserver(80);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HTML pages
|
* HTML constants for header, footer, css, ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Template: const char HTMLexamplepage[] PROGMEM = R"EOF()EOF";
|
// Template: const char HTMLexamplepage[] PROGMEM = R"EOF()EOF";
|
||||||
const char HTMLheader[] PROGMEM = R"EOF(
|
const char HTMLheader[] PROGMEM = R"EOF(
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>CanGrow</title>
|
||||||
|
<link rel="stylesheet" href="./style.css">
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
)EOF";
|
)EOF";
|
||||||
|
|
||||||
|
@ -129,6 +136,26 @@ const char HTMLfooter[] PROGMEM = R"EOF(
|
||||||
</html>
|
</html>
|
||||||
)EOF";
|
)EOF";
|
||||||
|
|
||||||
|
const char HTMLstyleCSS[] PROGMEM = R"EOF(
|
||||||
|
body {
|
||||||
|
font-family: helvetica;
|
||||||
|
background-color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:link, a:visited {
|
||||||
|
color: #33ff33;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #ffff00;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:active {
|
||||||
|
color: #da7a0a;
|
||||||
|
}
|
||||||
|
|
||||||
|
)EOF";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Pin assignments
|
* Pin assignments
|
||||||
|
@ -641,6 +668,7 @@ void setup() {
|
||||||
|
|
||||||
// generic handler
|
// generic handler
|
||||||
webserver.on("/wifiConfig/save", HTTP_POST, POSTwifiConfig);
|
webserver.on("/wifiConfig/save", HTTP_POST, POSTwifiConfig);
|
||||||
|
webserver.on("/style.css", HTTP_GET, WEBstyleCSS);
|
||||||
// 404 handling
|
// 404 handling
|
||||||
webserver.onNotFound(WEB404);
|
webserver.onNotFound(WEB404);
|
||||||
|
|
||||||
|
@ -686,20 +714,28 @@ void WebHandler_configured() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// not really a webpage, but CSS is important for them :p
|
||||||
|
void WEBstyleCSS() {
|
||||||
|
webserver.send(200, "text/css", HTMLstyleCSS);
|
||||||
|
}
|
||||||
|
|
||||||
void WEB404() {
|
void WEB404() {
|
||||||
String body = FPSTR(HTMLheader);
|
String body = FPSTR(HTMLheader);
|
||||||
body += "404 - not found";
|
body += "404 - not found";
|
||||||
body += FPSTR(HTMLfooter);
|
body += FPSTR(HTMLfooter);
|
||||||
|
webserver.send(200, "text/html", body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WEBrootUnconfigured() {
|
void WEBrootUnconfigured() {
|
||||||
byte ssidsAvail = WiFi.scanNetworks();
|
byte ssidsAvail = WiFi.scanNetworks();
|
||||||
String body = FPSTR(HTMLheader);
|
String body = FPSTR(HTMLheader);
|
||||||
body += "<h1>unconfigured!</h1>\n";
|
body += "<h1>unconfigured!</h1>\n";
|
||||||
body += "<h1>WiFi config</h1>\n";
|
body += "<h1>WiFi config</h1>\n";
|
||||||
body += "<p>Select your wifi network from the SSID list.<br>Leave IP field empty, to use DHCP.</p>";
|
body += "<p>Select your wifi network from the SSID list.<br>To use DHCP leave IP, Subnet, Gateway and DNS fields blank!</p>";
|
||||||
body += "<form method='post' action='/wifiConfig/save'>\n";
|
body += "<form method='post' action='/wifiConfig/save'>\n";
|
||||||
body += "SSID: <select id='WIFIssid' name='WIFIssid'>\n";
|
body += "SSID: <select id='WIFIssid' name='WIFIssid'>\n";
|
||||||
|
// build option list for selecting wifi
|
||||||
Serial.println("Available Wifis: ");
|
Serial.println("Available Wifis: ");
|
||||||
for(int i = 0 ; i < ssidsAvail; i++) {
|
for(int i = 0 ; i < ssidsAvail; i++) {
|
||||||
String wifiName = WiFi.SSID(i);
|
String wifiName = WiFi.SSID(i);
|
||||||
|
@ -714,13 +750,10 @@ void WEBrootUnconfigured() {
|
||||||
body += "Password: <input type='password' name='WIFIpassword'><br>\n";
|
body += "Password: <input type='password' name='WIFIpassword'><br>\n";
|
||||||
body += "IP: <input type='text' name='WIFIip'><br>\n";
|
body += "IP: <input type='text' name='WIFIip'><br>\n";
|
||||||
body += "Subnet mask: <input type='text' name='WIFInetmask'><br>\n";
|
body += "Subnet mask: <input type='text' name='WIFInetmask'><br>\n";
|
||||||
body += "gateway: <input type='text' name='WIFIgateway'><br>\n";
|
body += "Gateway: <input type='text' name='WIFIgateway'><br>\n";
|
||||||
body += "dns: <input type='text' name='WIFIdns'><br>\n";
|
body += "DNS: <input type='text' name='WIFIdns'><br>\n";
|
||||||
body += "<input type='submit' value='Save'>\n";
|
body += "<input type='submit' value='Save'>\n";
|
||||||
body += "</form>\n";
|
body += "</form>\n";
|
||||||
body += "<p>Available WiFi <pre>\n";
|
|
||||||
|
|
||||||
body += "</pre></p>\n";
|
|
||||||
body += FPSTR(HTMLfooter);
|
body += FPSTR(HTMLfooter);
|
||||||
|
|
||||||
webserver.send(200, "text/html", body);
|
webserver.send(200, "text/html", body);
|
||||||
|
|
Loading…
Reference in a new issue