From efadb696b97b62b4c3defbd1519bf6775ce55ef3 Mon Sep 17 00:00:00 2001 From: Florian <1technophile@users.noreply.github.com> Date: Wed, 30 Jan 2019 20:52:44 +0100 Subject: [PATCH] add wifimanager config portal timeout #350 in case of power outage so as to avoid to pop up the web page before the mqtt server restart --- OpenMQTTGateway.ino | 4 +++- User_config.h | 8 ++++---- tests/Test_config.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OpenMQTTGateway.ino b/OpenMQTTGateway.ino index e9c79b4..5801ad1 100644 --- a/OpenMQTTGateway.ino +++ b/OpenMQTTGateway.ino @@ -496,6 +496,8 @@ void setup_wifimanager(boolean reset_settings){ //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around WiFiManager wifiManager; + //Set timeout before going to portal + wifiManager.setConfigPortalTimeout(WifiManager_ConfigPortalTimeOut) //set config save notify callback wifiManager.setSaveConfigCallback(saveConfigCallback); @@ -695,7 +697,7 @@ void loop() if(RFM69toMQTT()) trc(F("RFM69toMQTT OK")); #endif - #if defined(ESP8266) || defined(ESP32) + #if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) stateMeasures(); #endif } diff --git a/User_config.h b/User_config.h index fa6c35c..c9e24ef 100644 --- a/User_config.h +++ b/User_config.h @@ -26,7 +26,7 @@ along with this program. If not, see . */ /*-------------------VERSION----------------------*/ -#define OMG_VERSION "0.9beta" +#define OMG_VERSION "0.9" /*-------------CONFIGURE WIFIMANAGER-------------(only ESP8266 & SONOFF RFBridge)*/ /* @@ -59,6 +59,7 @@ #define WifiManager_password "your_password" //this is going to be the WPA2-PSK password for the initial setup access point #define WifiManager_ssid "OpenMQTTGateway" //this is the network name of the initial setup access point +#define WifiManager_ConfigPortalTimeOut 120 /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ //MQTT Parameters definition @@ -84,6 +85,7 @@ char mqtt_port[6] = "1883"; //#define ZgatewayRF2 "RF2" //ESP8266, Arduino, ESP32 //#define ZgatewaySRFB "SRFB" // Sonoff RF Bridge //#define Zgateway2G "2G" //ESP8266, Arduino, ESP32 +//#define ZgatewayRFM69 "RFM69" //ESP8266, Arduino, ESP32 //#define ZactuatorONOFF "ONOFF" //ESP8266, Arduino, ESP32, Sonoff RF Bridge //#define ZsensorINA226 "INA226" //ESP8266, Arduino, ESP32 //#define ZsensorHCSR501 "HCSR501" //ESP8266, Arduino, ESP32, Sonoff RF Bridge @@ -92,14 +94,12 @@ char mqtt_port[6] = "1883"; //#define ZsensorTSL2561 "TSL2561" //ESP8266, Arduino, ESP32 //#define ZsensorBME280 "BME280" //ESP8266, Arduino, ESP32 //#define ZsensorDHT "DHT" //ESP8266, Arduino, ESP32, Sonoff RF Bridge -//#define ZgatewayRFM69 "RFM69" //ESP8266, Arduino, ESP32 //#define ZsensorGPIOKeyCode "GPIOKeyCode" //ESP8266, Arduino, ESP32 //#define ZsensorGPIOInput "GPIOInput" //ESP8266, Arduino, ESP32 -//#define ZmqttDiscovery "HADiscovery"//ESP8266, Arduino, EPS32, Sonoff RF Bridge +//#define ZmqttDiscovery "HADiscovery"//ESP8266, Arduino, ESP32, Sonoff RF Bridge /*-------------DEFINE YOUR ADVANCED NETWORK PARAMETERS BELOW----------------*/ //#define MDNS_SD //uncomment if you want to use mdns for discovering automatically your ip server, please note that MDNS with ESP32 can cause the BLE to not work -//#define cleanFS true //uncomment if you want to clean the ESP memory and reenter your credentials #define maxMQTTretry 4 //maximum MQTT connection attempts before going to wifi setup //set minimum quality of signal so it ignores AP's under that quality diff --git a/tests/Test_config.h b/tests/Test_config.h index 76d513c..db717e9 100644 --- a/tests/Test_config.h +++ b/tests/Test_config.h @@ -54,6 +54,7 @@ #define WifiManager_password "your_password" //this is going to be the WPA2-PSK password for the initial setup access point #define WifiManager_ssid "OpenMQTTGateway" //this is the network name of the initial setup access point +#define WifiManager_ConfigPortalTimeOut 120 /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ //MQTT Parameters definition @@ -74,7 +75,6 @@ char mqtt_port[6] = "1883"; /*-------------DEFINE YOUR NETWORK PARAMETERS BELOW----------------*/ //#define MDNS_SD //uncomment if you want to use mdns for discovering automatically your ip server, please note that MDNS with ESP32 can cause the BLE to not work -//#define cleanFS true //uncomment if you want to clean the ESP memory and reenter your credentials #define maxMQTTretry 4 //maximum MQTT connection attempts before going to wifi setup //set minimum quality of signal so it ignores AP's under that quality