ItKindaWorks / ESPHelper

A library to make using WiFi & MQTT on the ESP8266 easy.
GNU General Public License v3.0
327 stars 67 forks source link

about example configAndStatusAPDemo.ino #24

Closed skybox99 closed 4 years ago

skybox99 commented 6 years ago

This example suitable for new esp unit or location change scenario. But, in regular using situation, wifi signal unstable or AP temporary offline will cause esp falling into broadcasting mode and stay offline forever. So, I thought esp should be auto back online or auto reconnect, in order to maintain normal operation. below is my enhancements

  1. add timeout object Metro broadcastModeTimeout = Metro(180000);
  2. reconnect AP when broadcasting mode timout add code in function manageESPHelper()
    
    if ((wifiStatus == BROADCAST) && broadcastModeTimeout.check())
    {
      Serial.println("BROADCAST mode timeout and reset ESP");
      ESP.reset();
      delay(5000);
    }   
  3. broadcast timeout timer reset after broadcastmode activated add code in function checkForWifiTimeout() after myESP.broadcastMode() broadcastModeTimeout.reset();

In my simple test, it's ok. I hope someone can make it better. I had try updateNetwork(), but i failed.

ItKindaWorks commented 4 years ago

This is a great idea and has been added to that demo in the latest version!