diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 42cd920..7100a3e 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -36,7 +36,7 @@ float valHumidity; // valWaterlevel - contains the value of getWaterlevel() // do we need a restart? (e.g. after wifi settings change) bool NeedRestart; - +bool FirstRun; /* @@ -760,6 +760,7 @@ bool loadEEPROM() { void wifiConnect() { Serial.println(":: Connecting to WiFi ::"); + FirstRun = false; Serial.print("SSID: "); Serial.println(WIFIssid); @@ -795,7 +796,7 @@ void wifiConnect() { void wifiAp() { Serial.println(":: Creating Accesspoint ::"); - + FirstRun = true; // configure WiFi Access Point WiFi.softAPConfig(WIFIip, WIFIgateway, WIFInetmask); // start Access Point @@ -805,7 +806,8 @@ void wifiAp() { Serial.println(APssid); Serial.print("CanGrow IP address: "); Serial.println(WiFi.softAPIP()); - Serial.println("The login credentials for the WebUI are 'cangrow' for username and password"); + // TODO does not work atm, idk why + //Serial.println("The login credentials for the WebUI are 'cangrow' for username and password"); } /* @@ -1079,7 +1081,7 @@ void WEBhelp() { */ void WEBroot() { - if(strlen(WIFIssid) < 1) { + if(FirstRun == true < 1) { webserver.sendHeader("Location", String("/wifiSettings"), true); webserver.send(302, "text/plain", "please configure wifiSettings first"); } else if(configured == false){ @@ -1108,7 +1110,7 @@ void WEBroot() { void WEBwifiSettings() { byte ssidsAvail = WiFi.scanNetworks(); String body = FPSTR(HTMLheader); - if(strlen(WIFIssid) == 0) { + if(FirstRun == true) { body += "

Welcome!

"; body += "

CanGrow is actually unconfigured. You need to Setup your WiFi first down below.
"; body += "
After you entered your WiFi connection details, you need to restart and are step closer to your grow 🥦"; @@ -1154,7 +1156,7 @@ void WEBwifiSettings() { void WEBsystemSettings() { // if wifi settings are unconfigured, we cannot proceed with systemSettings - if(strlen(WIFIssid) < 1) { + if(FirstRun == true) { webserver.sendHeader("Location", String("/wifiSettings"), true); webserver.send(302, "text/plain", "please configure wifiSettings first"); } else {