firmware wip - add FirstRun bool
This commit is contained in:
parent
b3c0959521
commit
38a4847a23
1 changed files with 8 additions and 6 deletions
|
@ -36,7 +36,7 @@ float valHumidity;
|
||||||
// valWaterlevel - contains the value of getWaterlevel()
|
// valWaterlevel - contains the value of getWaterlevel()
|
||||||
// do we need a restart? (e.g. after wifi settings change)
|
// do we need a restart? (e.g. after wifi settings change)
|
||||||
bool NeedRestart;
|
bool NeedRestart;
|
||||||
|
bool FirstRun;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -760,6 +760,7 @@ bool loadEEPROM() {
|
||||||
|
|
||||||
void wifiConnect() {
|
void wifiConnect() {
|
||||||
Serial.println(":: Connecting to WiFi ::");
|
Serial.println(":: Connecting to WiFi ::");
|
||||||
|
FirstRun = false;
|
||||||
Serial.print("SSID: ");
|
Serial.print("SSID: ");
|
||||||
Serial.println(WIFIssid);
|
Serial.println(WIFIssid);
|
||||||
|
|
||||||
|
@ -795,7 +796,7 @@ void wifiConnect() {
|
||||||
|
|
||||||
void wifiAp() {
|
void wifiAp() {
|
||||||
Serial.println(":: Creating Accesspoint ::");
|
Serial.println(":: Creating Accesspoint ::");
|
||||||
|
FirstRun = true;
|
||||||
// configure WiFi Access Point
|
// configure WiFi Access Point
|
||||||
WiFi.softAPConfig(WIFIip, WIFIgateway, WIFInetmask);
|
WiFi.softAPConfig(WIFIip, WIFIgateway, WIFInetmask);
|
||||||
// start Access Point
|
// start Access Point
|
||||||
|
@ -805,7 +806,8 @@ void wifiAp() {
|
||||||
Serial.println(APssid);
|
Serial.println(APssid);
|
||||||
Serial.print("CanGrow IP address: ");
|
Serial.print("CanGrow IP address: ");
|
||||||
Serial.println(WiFi.softAPIP());
|
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() {
|
void WEBroot() {
|
||||||
if(strlen(WIFIssid) < 1) {
|
if(FirstRun == true < 1) {
|
||||||
webserver.sendHeader("Location", String("/wifiSettings"), true);
|
webserver.sendHeader("Location", String("/wifiSettings"), true);
|
||||||
webserver.send(302, "text/plain", "please configure wifiSettings first");
|
webserver.send(302, "text/plain", "please configure wifiSettings first");
|
||||||
} else if(configured == false){
|
} else if(configured == false){
|
||||||
|
@ -1108,7 +1110,7 @@ void WEBroot() {
|
||||||
void WEBwifiSettings() {
|
void WEBwifiSettings() {
|
||||||
byte ssidsAvail = WiFi.scanNetworks();
|
byte ssidsAvail = WiFi.scanNetworks();
|
||||||
String body = FPSTR(HTMLheader);
|
String body = FPSTR(HTMLheader);
|
||||||
if(strlen(WIFIssid) == 0) {
|
if(FirstRun == true) {
|
||||||
body += "<h1>Welcome!</h1>";
|
body += "<h1>Welcome!</h1>";
|
||||||
body += "<p>CanGrow is actually unconfigured. You need to Setup your WiFi first down below.<br>";
|
body += "<p>CanGrow is actually unconfigured. You need to Setup your WiFi first down below.<br>";
|
||||||
body += "<br>After you entered your WiFi connection details, you need to restart and are step closer to your grow 🥦";
|
body += "<br>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() {
|
void WEBsystemSettings() {
|
||||||
// if wifi settings are unconfigured, we cannot proceed with systemSettings
|
// if wifi settings are unconfigured, we cannot proceed with systemSettings
|
||||||
if(strlen(WIFIssid) < 1) {
|
if(FirstRun == true) {
|
||||||
webserver.sendHeader("Location", String("/wifiSettings"), true);
|
webserver.sendHeader("Location", String("/wifiSettings"), true);
|
||||||
webserver.send(302, "text/plain", "please configure wifiSettings first");
|
webserver.send(302, "text/plain", "please configure wifiSettings first");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue