add button to restart to wifi configuration

This commit is contained in:
technyon
2022-04-08 22:31:51 +02:00
parent 4303b0d877
commit 17461a2a84
6 changed files with 99 additions and 2 deletions

View File

@@ -26,7 +26,18 @@ void Network::initialize()
// these are stored by the esp library
//wm.resetSettings();
bool res = wm.autoConnect(); // password protected ap
bool res = false;
if(_cookie.isSet())
{
Serial.println(F("Opening WiFi configuration portal."));
res = wm.startConfigPortal();
_cookie.clear();
}
else
{
res = wm.autoConnect(); // password protected ap
}
if(!res) {
Serial.println(F("Failed to connect. Wait for ESP restart."));
@@ -318,3 +329,10 @@ void Network::buildMqttPath(const char* path, char* outPath)
}
outPath[i+1] = 0x00;
}
void Network::restartAndConfigureWifi()
{
_cookie.set();
delay(200);
ESP.restart();
}