mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-11 18:54:28 +05:00
fix config portal
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
#include <WiFiManagerParameters.h>
|
#include <WiFiManagerParameters.h>
|
||||||
#include <netif/etharp.h>
|
#include <netif/etharp.h>
|
||||||
|
|
||||||
// Wifimanager
|
|
||||||
WiFiManager wm;
|
WiFiManager wm;
|
||||||
WiFiManagerParameter* wmHostname;
|
WiFiManagerParameter* wmHostname;
|
||||||
WiFiManagerParameter* wmMqttServer;
|
WiFiManagerParameter* wmMqttServer;
|
||||||
@@ -22,6 +22,7 @@ IntParameter* wmIndoorSensorPin;
|
|||||||
SeparatorParameter* wmSep1;
|
SeparatorParameter* wmSep1;
|
||||||
SeparatorParameter* wmSep2;
|
SeparatorParameter* wmSep2;
|
||||||
|
|
||||||
|
|
||||||
class WifiManagerTask : public Task {
|
class WifiManagerTask : public Task {
|
||||||
public:
|
public:
|
||||||
WifiManagerTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {}
|
WifiManagerTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {}
|
||||||
@@ -40,6 +41,7 @@ protected:
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
wm.setDebugOutput(settings.debug);
|
wm.setDebugOutput(settings.debug);
|
||||||
|
//wm.setDebugOutput(settings.debug, WM_DEBUG_VERBOSE);
|
||||||
|
|
||||||
wmHostname = new WiFiManagerParameter("hostname", "Hostname", settings.hostname, 80);
|
wmHostname = new WiFiManagerParameter("hostname", "Hostname", settings.hostname, 80);
|
||||||
wm.addParameter(wmHostname);
|
wm.addParameter(wmHostname);
|
||||||
@@ -94,20 +96,20 @@ protected:
|
|||||||
wm.setAPClientCheck(true);
|
wm.setAPClientCheck(true);
|
||||||
wm.setConfigPortalBlocking(false);
|
wm.setConfigPortalBlocking(false);
|
||||||
wm.setSaveParamsCallback(saveParamsCallback);
|
wm.setSaveParamsCallback(saveParamsCallback);
|
||||||
wm.setConfigPortalTimeout(180);
|
wm.setConfigPortalTimeout(wm.getWiFiIsSaved() ? 180 : 0);
|
||||||
//wm.setDisableConfigPortal(false);
|
wm.setDisableConfigPortal(false);
|
||||||
|
|
||||||
wm.autoConnect(AP_SSID, AP_PASSWORD);
|
wm.autoConnect(AP_SSID, AP_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
/*if (WiFi.status() != WL_CONNECTED && !wm.getWebPortalActive() && !wm.getConfigPortalActive()) {
|
|
||||||
wm.autoConnect(AP_SSID);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (connected && WiFi.status() != WL_CONNECTED) {
|
if (connected && WiFi.status() != WL_CONNECTED) {
|
||||||
connected = false;
|
connected = false;
|
||||||
|
|
||||||
|
if (wm.getWebPortalActive()) {
|
||||||
|
wm.stopWebPortal();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_TELNET
|
#ifdef USE_TELNET
|
||||||
TelnetStream.stop();
|
TelnetStream.stop();
|
||||||
#endif
|
#endif
|
||||||
@@ -117,10 +119,15 @@ protected:
|
|||||||
} else if (!connected && WiFi.status() == WL_CONNECTED) {
|
} else if (!connected && WiFi.status() == WL_CONNECTED) {
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
||||||
|
wm.setConfigPortalTimeout(180);
|
||||||
if (wm.getConfigPortalActive()) {
|
if (wm.getConfigPortalActive()) {
|
||||||
wm.stopConfigPortal();
|
wm.stopConfigPortal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wm.getWebPortalActive()) {
|
||||||
|
wm.startWebPortal();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_TELNET
|
#ifdef USE_TELNET
|
||||||
TelnetStream.begin();
|
TelnetStream.begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -128,10 +135,6 @@ protected:
|
|||||||
INFO_F("[wifi] Connected. IP address: %s, RSSI: %d\n", WiFi.localIP().toString().c_str(), WiFi.RSSI());
|
INFO_F("[wifi] Connected. IP address: %s, RSSI: %d\n", WiFi.localIP().toString().c_str(), WiFi.RSSI());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WiFi.status() == WL_CONNECTED && !wm.getWebPortalActive() && !wm.getConfigPortalActive()) {
|
|
||||||
wm.startWebPortal();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
if (connected && millis() - lastArpGratuitous > 60000) {
|
if (connected && millis() - lastArpGratuitous > 60000) {
|
||||||
arpGratuitous();
|
arpGratuitous();
|
||||||
|
|||||||
Reference in New Issue
Block a user