firmware wip - replace double quotes with single ones , its less confusing for geany ide
This commit is contained in:
parent
805ec41ffd
commit
0f8ff91d37
1 changed files with 79 additions and 55 deletions
|
@ -86,8 +86,8 @@ IPAddress WIFIip(192,168,4,20);
|
|||
IPAddress WIFInetmask(255,255,255,0);
|
||||
IPAddress WIFIgateway(192,168,4,254);
|
||||
IPAddress WIFIdns(0,0,0,0);
|
||||
char WebUiUsername[16] = "cangrow";
|
||||
char WebUiPassword[32] = "cangrow";
|
||||
//char WebUiUsername[16] = "cangrow";
|
||||
//char WebUiPassword[32] = "cangrow";
|
||||
|
||||
//
|
||||
// System
|
||||
|
@ -166,6 +166,9 @@ ESP8266WebServer webserver(80);
|
|||
|
||||
/*
|
||||
* HTML constants for header, footer, css, ...
|
||||
* Note: I know of the existence of SPIFFS and ESPHtmlTemplateProcessor,
|
||||
* but to keep things simple for compiling and upload for others, I decided
|
||||
* to not use those.
|
||||
*/
|
||||
|
||||
// Template: const char HTMLexamplepage[] PROGMEM = R"EOF()EOF";
|
||||
|
@ -173,10 +176,10 @@ const char HTMLheader[] PROGMEM = R"EOF(
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset='UTF-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>CanGrow</title>
|
||||
<!-- <link rel="stylesheet" href="/style.css"> -->
|
||||
<!-- <link rel='stylesheet' href='/style.css'> -->
|
||||
<style>
|
||||
/* Having the whole CSS here ensures it's all the time present*/
|
||||
body {
|
||||
|
@ -257,7 +260,7 @@ const char HTMLheader[] PROGMEM = R"EOF(
|
|||
.nav li a , .nav span {
|
||||
color: #ddd;
|
||||
display: block;
|
||||
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
|
||||
font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
|
||||
font-size:0.8em;
|
||||
padding: 10px 20px;
|
||||
text-decoration: none;
|
||||
|
@ -284,7 +287,7 @@ const char HTMLheader[] PROGMEM = R"EOF(
|
|||
</style>
|
||||
<script>
|
||||
function highlightActiveMenu(menuEntry) {
|
||||
document.getElementById(menuEntry).classList.add("activeMenu");
|
||||
document.getElementById(menuEntry).classList.add('activeMenu');
|
||||
}
|
||||
|
||||
function replaceStr(dst, content) {
|
||||
|
@ -293,16 +296,16 @@ const char HTMLheader[] PROGMEM = R"EOF(
|
|||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<ul class="nav">
|
||||
<li><a id="MenuGrowName" href="/">🌱 CanGrow</a></li>
|
||||
<li><a id="MgrowSettings" href="/growSettings">Grow settings</a></li>
|
||||
<li><a id="MsystemSettings" href="/systemSettings">System settings</a></li>
|
||||
<li><a id="MwifiSettings" href="/wifiSettings">WiFi settings</a></li>
|
||||
<li><a id="Mhelp" href="/help">Help</a></li>
|
||||
<li><span id="MenuTime" class="MenuTime"></span></li>
|
||||
<li><a id="CanGrowVer" href='https://git.la10cy.net/DeltaLima/CanGrow' target="_blank">CanGrow</a></li>
|
||||
<ul class='nav'>
|
||||
<li><a id='MenuGrowName' href='/'>🌱 CanGrow</a></li>
|
||||
<li><a id='MgrowSettings' href='/growSettings'>Grow settings</a></li>
|
||||
<li><a id='MsystemSettings' href='/systemSettings'>System settings</a></li>
|
||||
<li><a id='MwifiSettings' href='/wifiSettings'>WiFi settings</a></li>
|
||||
<li><a id='Mhelp' href='/help'>Help</a></li>
|
||||
<li><span id='MenuTime' class='MenuTime'></span></li>
|
||||
<li><a id='CanGrowVer' href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow</a></li>
|
||||
</ul>
|
||||
<div class="center">
|
||||
<div class='center'>
|
||||
|
||||
)EOF";
|
||||
|
||||
|
@ -312,15 +315,6 @@ const char HTMLfooter[] PROGMEM = R"EOF(
|
|||
</html>
|
||||
)EOF";
|
||||
|
||||
/*
|
||||
* I decided to embed CSS into HTMLheader because after
|
||||
* a wifi change triggerd restart of the esp, the the style.css never get deliverd
|
||||
* because the esp restarts after the webpage was delivered. style.css would be a second call
|
||||
* but when the browser sends this, it's too late.
|
||||
const char HTMLstyleCSS[] PROGMEM = R"EOF(
|
||||
|
||||
)EOF";
|
||||
*/
|
||||
|
||||
const char HTMLsuccess[] PROGMEM = R"EOF(
|
||||
<div class='infomsg'>Successfully saved!</div>
|
||||
|
@ -328,8 +322,8 @@ const char HTMLsuccess[] PROGMEM = R"EOF(
|
|||
|
||||
const char HTMLneedRestart[] PROGMEM = R"EOF(
|
||||
<div class='warnmsg'>Restart is required to apply new WiFi settings!
|
||||
<form action="/system/restart">
|
||||
<input type="submit" value="Restart now" />
|
||||
<form action='/system/restart'>
|
||||
<input type='submit' value='Restart now' />
|
||||
</form>
|
||||
</div>
|
||||
)EOF";
|
||||
|
@ -1290,6 +1284,44 @@ void WebHandler() {
|
|||
* return functions, they return things for the web stuff
|
||||
*/
|
||||
|
||||
String returnHTMLheader(String MenuEntry = "") {
|
||||
String header;
|
||||
header += FPSTR(HTMLheader);
|
||||
|
||||
|
||||
|
||||
|
||||
// print actual time in header
|
||||
//~ footer += "<script>replaceStr('CanGrowVer', 'CanGrow v";
|
||||
//~ footer += CanGrowVer;
|
||||
//~ footer += "');\n";
|
||||
//~ footer += "replaceStr('MenuTime', '";
|
||||
//~ footer += timeClient.getFormattedTime();
|
||||
//~ footer += "');\n";
|
||||
//~ footer += "highlightActiveMenu('M";
|
||||
//~ footer += MenuEntry;
|
||||
//~ footer += "');";
|
||||
//~ footer += "</script>";
|
||||
|
||||
//~ // show the GrowName in the menu if set
|
||||
//~ if(strlen(GrowName) > 0){
|
||||
|
||||
|
||||
//~ footer += "<script>replaceStr('MenuGrowName', '🌱 ";
|
||||
//~ footer += GrowName;
|
||||
//~ footer += "');\n";
|
||||
//~ // include the GrowName in the title
|
||||
//~ footer += "document.title = 'CanGrow - ";
|
||||
//~ footer += GrowName;
|
||||
//~ footer += "';";
|
||||
//~ footer += "</script>";
|
||||
//~ }
|
||||
|
||||
//~ footer += FPSTR(HTMLfooter);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
// returns footer with javascript stuff
|
||||
String returnHTMLfooter(String MenuEntry = "") {
|
||||
String footer;
|
||||
|
@ -1418,35 +1450,36 @@ void SysWipe() {
|
|||
}
|
||||
|
||||
|
||||
void WebAuth() {
|
||||
/*
|
||||
* TODO
|
||||
* DOES NOT WORK WHEN CONNECTED TO EXISTING WIFI
|
||||
* IDK WHY
|
||||
*
|
||||
*/
|
||||
char webAuthRealm[] = "CanGrowRealm";
|
||||
if(!webserver.authenticate(WebUiUsername, WebUiPassword)) {
|
||||
String body = FPSTR(HTMLheader);
|
||||
body += "<h1>Login failed.</h1>";
|
||||
body += FPSTR(HTMLfooter);
|
||||
webserver.requestAuthentication(DIGEST_AUTH, webAuthRealm, body);
|
||||
}
|
||||
}
|
||||
|
||||
void WebAuthApi() {
|
||||
/*
|
||||
|
||||
* void WebAuth() {
|
||||
*
|
||||
* char webAuthRealm[] = "CanGrowRealm";
|
||||
* if(!webserver.authenticate(WebUiUsername, WebUiPassword)) {
|
||||
* String body = FPSTR(HTMLheader);
|
||||
* body += "<h1>Login failed.</h1>";
|
||||
* body += FPSTR(HTMLfooter);
|
||||
* webserver.requestAuthentication(DIGEST_AUTH, webAuthRealm, body);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void WebAuthApi() {
|
||||
*
|
||||
* TODO
|
||||
* DOES NOT WORK WHEN CONNECTED TO EXISTING WIFI
|
||||
* IDK WHY
|
||||
*
|
||||
*
|
||||
* char webAuthRealm[] = "CanGrowRealm";
|
||||
* if(!webserver.authenticate(WebUiUsername, WebUiPassword)) {
|
||||
* webserver.requestAuthentication(DIGEST_AUTH, webAuthRealm);
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
char webAuthRealm[] = "CanGrowRealm";
|
||||
if(!webserver.authenticate(WebUiUsername, WebUiPassword)) {
|
||||
webserver.requestAuthentication(DIGEST_AUTH, webAuthRealm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -1454,13 +1487,6 @@ void WebAuthApi() {
|
|||
*
|
||||
*/
|
||||
|
||||
// not really a webpage, but CSS is important for them :p
|
||||
/*
|
||||
void WEBstyleCSS() {
|
||||
webserver.send(200, "text/css", HTMLstyleCSS);
|
||||
}
|
||||
*/
|
||||
|
||||
void WEB404() {
|
||||
String body = FPSTR(HTMLheader);
|
||||
body += "<div class='warnmsg'><h1>404 - not found</h1></div>";
|
||||
|
@ -2147,10 +2173,8 @@ void APIgetSensors() {
|
|||
* TODO LIST / NOTES
|
||||
*
|
||||
*
|
||||
* - Sunrise and Sunset PWM if PWM is set
|
||||
* - avoid using javascript to set the GrowName in the Menu and the time
|
||||
* as well
|
||||
* - rework UseLEDrelais usage
|
||||
* - when PWM for fan is set, set fan speed to regulate humidity and
|
||||
* temperature
|
||||
* - re-organize EEPROM saved values.
|
||||
|
|
Loading…
Reference in a new issue