Make portal timeout configurable (#658)
This commit is contained in:
parent
f614034056
commit
e71963d439
|
@ -37,7 +37,7 @@ framework = arduino
|
|||
lib_deps =
|
||||
AsyncTCP = https://github.com/pbolduc/AsyncTCP.git@^1.2.0
|
||||
https://github.com/ESPresense/ESPAsyncWebServer.git
|
||||
https://github.com/ESPresense/AsyncWiFiSettings.git#1.0.2
|
||||
https://github.com/ESPresense/AsyncWiFiSettings.git#1.0.3
|
||||
https://github.com/ESPresense/SoftFilters.git
|
||||
https://github.com/ESPresense/NimBLE-Arduino.git
|
||||
marvinroger/AsyncMqttClient@^0.9.0
|
||||
|
|
|
@ -5,9 +5,14 @@
|
|||
#define CHECK_FOR_UPDATES_INTERVAL 900000
|
||||
#endif
|
||||
|
||||
// Number of ms to keep up captive portal before retrying connecting
|
||||
#ifndef CAPTIVE_PORTAL_TIMEOUT
|
||||
#define CAPTIVE_PORTAL_TIMEOUT 300000
|
||||
// Number of seconds to wait for a Station Wifi connection to be established
|
||||
#ifndef DEFAULT_WIFI_TIMEOUT
|
||||
#define DEFAULT_WIFI_TIMEOUT 120
|
||||
#endif
|
||||
|
||||
// Number of seconds to keep up captive portal (SoftAP) before rebooting
|
||||
#ifndef DEFAULT_PORTAL_TIMEOUT
|
||||
#define DEFAULT_PORTAL_TIMEOUT 300
|
||||
#endif
|
||||
|
||||
#define UPDATE_STARTED -255
|
||||
|
|
38
src/main.cpp
38
src/main.cpp
|
@ -114,29 +114,12 @@ void setupNetwork() {
|
|||
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
|
||||
GUI::Connected(false, false);
|
||||
|
||||
unsigned int connectProgress = 0;
|
||||
AsyncWiFiSettings.onWaitLoop = [&connectProgress]() {
|
||||
GUI::Wifi(connectProgress++);
|
||||
SerialImprov::Loop(true);
|
||||
return 50;
|
||||
};
|
||||
unsigned int portalProgress = 0;
|
||||
AsyncWiFiSettings.onPortalWaitLoop = [&portalProgress]() {
|
||||
GUI::Portal(portalProgress++);
|
||||
SerialImprov::Loop(false);
|
||||
|
||||
if (millis() > CAPTIVE_PORTAL_TIMEOUT)
|
||||
ESP.restart();
|
||||
|
||||
return 50;
|
||||
};
|
||||
AsyncWiFiSettings.onHttpSetup = HttpWebServer::Init;
|
||||
|
||||
#ifdef VERSION
|
||||
AsyncWiFiSettings.info("ESPresense Version: " + String(VERSION));
|
||||
#endif
|
||||
room = AsyncWiFiSettings.string("room", ESPMAC, "Room");
|
||||
auto wifiTimeout = AsyncWiFiSettings.integer("wifi_timeout", 45, "Seconds to wait for WiFi before captive portal (-1 = forever)");
|
||||
auto wifiTimeout = AsyncWiFiSettings.integer("wifi_timeout", DEFAULT_WIFI_TIMEOUT, "Seconds to wait for WiFi before captive portal (-1 = forever)");
|
||||
auto portalTimeout = 1000UL * AsyncWiFiSettings.integer("portal_timeout", DEFAULT_PORTAL_TIMEOUT, "Seconds to wait in captive portal before rebooting");
|
||||
std::vector<String> ethernetTypes = {"None", "WT32-ETH01", "ESP32-POE", "WESP32", "QuinLED-ESP32", "TwilightLord-ESP32", "ESP32Deux", "KIT-VE", "LilyGO-T-ETH-POE"};
|
||||
ethernetType = AsyncWiFiSettings.dropdown("eth", ethernetTypes, 0, "Ethernet Type");
|
||||
|
||||
|
@ -200,6 +183,23 @@ void setupNetwork() {
|
|||
|
||||
#endif
|
||||
|
||||
unsigned int connectProgress = 0;
|
||||
AsyncWiFiSettings.onWaitLoop = [&connectProgress]() {
|
||||
GUI::Wifi(connectProgress++);
|
||||
SerialImprov::Loop(true);
|
||||
return 50;
|
||||
};
|
||||
unsigned int portalProgress = 0;
|
||||
AsyncWiFiSettings.onPortalWaitLoop = [&portalProgress, portalTimeout]() {
|
||||
GUI::Portal(portalProgress++);
|
||||
SerialImprov::Loop(false);
|
||||
|
||||
if (millis() > portalTimeout)
|
||||
ESP.restart();
|
||||
|
||||
return 50;
|
||||
};
|
||||
AsyncWiFiSettings.onHttpSetup = HttpWebServer::Init;
|
||||
AsyncWiFiSettings.hostname = "espresense-" + kebabify(room);
|
||||
|
||||
bool success = false;
|
||||
|
|
Loading…
Reference in New Issue