diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino
index f16ffde..4e9d6ee 100644
--- a/Arduino/CanGrow/CanGrow.ino
+++ b/Arduino/CanGrow/CanGrow.ino
@@ -80,7 +80,7 @@ char WebUiPassword[32] = "cangrow";
// configured - if false, let the user configure system settings first
bool configured = false;
// NTP Offset
-int ntpOffset;
+byte ntpOffset;
// MoistureSensor_Type - contains which moisture sensor to use
// 1: analog capacitive sensor
// 2: I2C chirp sensor from catnip electronics
@@ -314,7 +314,7 @@ const char HTMLsuccess[] PROGMEM = R"EOF(
const char HTMLneedRestart[] PROGMEM = R"EOF(
Restart is required to apply new WiFi settings!
-
@@ -998,8 +998,8 @@ void loop() {
// first we call webserver handle client
webserver.handleClient();
- // do every second
- if(currentRuntime - outputPrevTime >= 1000) {
+ // do every second when everything is configured
+ if( (configured == true) && (strlen(GrowName) > 0) && (currentRuntime - outputPrevTime >= 1000) ){
// debug output
Serial.print("secondsSunrise: ");
Serial.println(secondsSunrise);
@@ -1058,7 +1058,9 @@ void WebHandler() {
webserver.on("/help", HTTP_GET, WEBhelp);
// restart when NeedRestart is true
- webserver.on("/restart", HTTP_GET, WebRestart);
+ webserver.on("/system/restart", HTTP_GET, SysRestart);
+ // wipe eeprom triggered from WebGui
+ webserver.on("/system/wipe", HTTP_GET, SysWipe);
// does not work atm TODO
//webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); });
@@ -1071,12 +1073,13 @@ void WebHandler() {
// switching MOSFETs
webserver.on("/switch", HTTP_POST, POSTswitchMOSFET);
+
}
-void WebRestart() {
+void SysRestart() {
String body = FPSTR(HTMLheader);
// TODO only debug and development solution, remove this later
- if(true) {
+ if( (webserver.hasArg("confirmed")) || (NeedRestart == true) ) {
body += "Restarting
";
body += "After restart CanGrow will be connected to WiFi SSID
";
body += WIFIssid;
@@ -1087,9 +1090,32 @@ void WebRestart() {
delay(1000);
ESP.restart();
} else {
- body += "Not allowed
";
+ body += "Restart CanGrow
";
+ body += "Do you want to restart CanGrow?";
+ body += "
Please confirm.";
+ body += "";
+ body += "
";
body += returnHTMLfooter();
- webserver.send(405, "text/html", body);
+ webserver.send(200, "text/html", body);
+ }
+}
+
+void SysWipe() {
+ String body = FPSTR(HTMLheader);
+ // TODO only debug and development solution, remove this later
+ if(webserver.hasArg("confirmed")) {
+ body += "!! Wiping CanGrow's EEPROM !!
Device will restart in a few seconds.";
+ body += returnHTMLfooter();
+ webserver.send(200, "text/html", body);
+ wipeEEPROM();
+ } else {
+ body += "Wipeing EEPROM
";
+ body += "All settings will be removed!!
";
+ body += "
Please confirm wiping the EEPROM";
+ body += "";
+ body += "
";
+ body += returnHTMLfooter();
+ webserver.send(200, "text/html", body);
}
}
@@ -1261,8 +1287,8 @@ void WEBroot() {
body += returnStrDateFromEpoch(GrowStart);
body += "
";
body += "Day of Grow: ";
- body += DayOfGrow;
- body += "
";
+ body += int(ceil(float((timeClient.getEpochTime() - GrowStart) / 60 / 60 / 24))) ;
+ body += "
";
body += "Soil Moisture: ";
body += getSoilmoisture(MoistureSensor_Type);
body += " %
";
@@ -1343,10 +1369,34 @@ void WEBwifiSettings() {
if(webserver.hasArg("success")) {
body += FPSTR(HTMLsuccess);
}
+
+ if(FirstRun == false) {
+ body += "Current Settings:
";
+ body += "WiFi SSID: ";
+ body += WIFIssid;
+ body += "
\n";
+ body += "Use DHCP: ";
+ body += WIFIuseDHCP;
+ body += "
\n";
+ body += "IP address: ";
+ body += WiFi.localIP().toString();
+ body += "
\n";
+ body += "Subnet mask: ";
+ body += WiFi.subnetMask().toString();
+ body += "
\n";
+ body += "Gateway: ";
+ body += WiFi.gatewayIP().toString();
+ body += "
\n";
+ body += "DNS: ";
+ body += WiFi.dnsIP().toString();
+ body += "
\n";
+ }
+
body += "Select your wifi network from the SSID list.
To use DHCP leave IP, Subnet, Gateway and DNS fields blank!
";
body += "