add default values , add restart after wifi change
This commit is contained in:
parent
38a4847a23
commit
19cd6c1288
1 changed files with 40 additions and 13 deletions
|
@ -64,15 +64,15 @@ char WebUiPassword[32] = "cangrow";
|
|||
// System
|
||||
//
|
||||
// configured - if true, run setup assistant
|
||||
bool configured;
|
||||
bool configured = false;
|
||||
// NTP Offset
|
||||
int ntpOffset;
|
||||
int ntpOffset = 0;
|
||||
// MoistureSensor_Type - contains which moisture sensor to use
|
||||
// 1: analog capacitive sensor
|
||||
// 2: I2C chirp sensor from catnip electronics
|
||||
byte MoistureSensor_Type;
|
||||
// SoilmoistureLow - contains the value , when soil moisture is assumed to be low,
|
||||
byte SoilmoistureLow;
|
||||
byte SoilmoistureLow = 20;
|
||||
// UsePump - is the pump used? bool
|
||||
bool UsePump;
|
||||
// UseFan - is the fan used? bool
|
||||
|
@ -97,17 +97,17 @@ unsigned long GrowStart;
|
|||
// DayOfGrow contains on which day the grow is
|
||||
byte DayOfGrow;
|
||||
// DaysVeg - contains how many days to be in vegetation phase
|
||||
byte DaysVeg;
|
||||
byte DaysVeg = 35;
|
||||
// DaysBloom - contains how many days to be in bloom phase
|
||||
byte DaysBloom;
|
||||
byte DaysBloom = 49;
|
||||
// LighthoursVeg - contains how many hours the Growlight is on in Veg
|
||||
byte LighthoursVeg;
|
||||
byte LighthoursVeg = 16;
|
||||
// LighthoursBloom - contains how many hours the Growlight is on in Bloom
|
||||
byte LighthoursBloom;
|
||||
byte LighthoursBloom = 12;
|
||||
// SunriseHour - contains to which hour of day the growlight turns on
|
||||
byte SunriseHour;
|
||||
byte SunriseHour = 7;
|
||||
// SunriseHour - contains to which minute of SunriseHour the growlight turns on
|
||||
byte SunriseMinute;
|
||||
byte SunriseMinute = 0;
|
||||
// PINled_PWM - contains the PWM value for dimming the grow light
|
||||
// default is 255 to ensure it is just on for the case UseLEDrelais is true
|
||||
byte PINled_PWM = 255;
|
||||
|
@ -284,7 +284,11 @@ const char HTMLsuccess[] PROGMEM = R"EOF(
|
|||
)EOF";
|
||||
|
||||
const char HTMLneedRestart[] PROGMEM = R"EOF(
|
||||
<div class='warnmsg'>Restart is required to apply new WiFi settings!</div>
|
||||
<div class='warnmsg'>Restart is required to apply new WiFi settings!
|
||||
<form action="/restart">
|
||||
<input type="submit" value="Restart now" />
|
||||
</form>
|
||||
</div>
|
||||
)EOF";
|
||||
|
||||
const char HTMLhelp[] PROGMEM = R"EOF(
|
||||
|
@ -966,6 +970,9 @@ void WebHandler() {
|
|||
webserver.on("/growSettings/save", HTTP_POST, POSTgrowSettings);
|
||||
// help
|
||||
webserver.on("/help", HTTP_GET, WEBhelp);
|
||||
|
||||
// restart when NeedRestart is true
|
||||
webserver.on("/restart", HTTP_GET, WebRestart);
|
||||
// does not work atm TODO
|
||||
//webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); });
|
||||
|
||||
|
@ -977,6 +984,21 @@ void WebHandler() {
|
|||
|
||||
}
|
||||
|
||||
void WebRestart() {
|
||||
if(NeedRestart == true) {
|
||||
String body = FPSTR(HTMLheader);
|
||||
body += "<h1>Restarting</h1>";
|
||||
body += "<div class='infomsg'>After restart you will be connected to Wifi<br><b>";
|
||||
body += WIFIssid;
|
||||
body += "</b><br>You get CanGrow's IP-Address from the display or serial console.</div>";
|
||||
body += returnHTMLfooter();
|
||||
webserver.send(200, "text/html", body);
|
||||
Serial.println("Restarting... see you soon space cowboy!");
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WebAuth() {
|
||||
/*
|
||||
|
@ -1081,7 +1103,7 @@ void WEBhelp() {
|
|||
*/
|
||||
|
||||
void WEBroot() {
|
||||
if(FirstRun == true < 1) {
|
||||
if(FirstRun == true) {
|
||||
webserver.sendHeader("Location", String("/wifiSettings"), true);
|
||||
webserver.send(302, "text/plain", "please configure wifiSettings first");
|
||||
} else if(configured == false){
|
||||
|
@ -1247,7 +1269,7 @@ void WEBgrowSettings() {
|
|||
String body = FPSTR(HTMLheader);
|
||||
|
||||
if(strlen(GrowName) < 1) {
|
||||
body += "<h1>Step 3: Grow settings</h1>";
|
||||
body += "<h1>Final step: Grow settings</h1>";
|
||||
body += "<p>Please configure all settings<br>";
|
||||
body += "</p>";
|
||||
}
|
||||
|
@ -1436,7 +1458,12 @@ void POSTsystemSettings() {
|
|||
Serial.print("ntpOffset: ");
|
||||
Serial.println(ntpOffset);
|
||||
|
||||
webserver.sendHeader("Location", String("/systemSettings?success"), true);
|
||||
if(strlen(GrowName) < 1) {
|
||||
webserver.sendHeader("Location", String("/growSettings?success"), true);
|
||||
} else {
|
||||
webserver.sendHeader("Location", String("/systemSettings?success"), true);
|
||||
}
|
||||
|
||||
webserver.send(302, "text/plain", "systemSettings/save: success!");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue