Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when Scan is cached xxxx ms ago #1386

Closed
jonathanvanpeteghem opened this issue Apr 6, 2022 · 2 comments
Closed

Issue when Scan is cached xxxx ms ago #1386

jonathanvanpeteghem opened this issue Apr 6, 2022 · 2 comments
Labels
bug Validated BUG

Comments

@jonathanvanpeteghem
Copy link

jonathanvanpeteghem commented Apr 6, 2022

First of all a big thanks to Tzapu and of course Tablatronix for doing such a great job! Special thanks to Tablatronix for maintaining this library and make it into something that actually works and is stable. In the last year(s) I saw this lib evolving from something buggy to something that is now actually usable. The problem I have is a minor problem, and is only something you will get in a very specific case.

Basic Infos

Hardware

WiFimanager Branch/Release: Master : latest version to date => v2.0.10-beta

Hardware ESP32: tested both Wrover and Wroom

Description

The basic problem can be replicated by using the on demand config portal example:

When initializing the wifimanager with => WiFiManager wm; as a global object , and when the button is pushed, it is possible to have a problem. The first time the button is pushed, all is ok. The wifinetworks are found. We can select ssid and set password.
Then we save, and the ESP32 connects to the network.

When pushing the button a second time, to go to the config portal, within 60 seconds. => The wifimanger code detects that the networks have been scanned once before (debug : wm:[2] Scan is cached xxxx ms ago)=> no need to scan again => but after that only empty SSID's are given. (in debug you see multiple : wm:[2] DUP AP: )

Note that you can only replicate this: when you move the initialisation of the wm object from local (in the loop where the button is pressed) to global.
In other words it will only happen when the wm object is not trown away after the button is pushed and the wifi is actually connected.
And you need to reconnect withing 60 seconds (wich is obvious and can be found in the wifimanager code : 60000 ms)

Settings in IDE

Module: It will happen with whatever module.

Additional libraries: NONE

Sketch

 * OnDemandConfigPortal.ino
 * example of running the configPortal AP manually, independantly from the captiveportal
 * trigger pin will start a configPortal AP for 120 seconds then turn it off.
 * 
 */
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager

// select which pin will trigger the configuration portal when set to LOW
#define TRIGGER_PIN 0

int timeout = 120; // seconds to run for

WiFiManager wm;    // ==> the lib is called globaly, the wm object is kept in memory => and will be kept alive.

void setup() {
  WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP  
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("\n Starting");
  pinMode(TRIGGER_PIN, INPUT_PULLUP);
}

void loop() {
  // is configuration portal requested?
  if ( digitalRead(TRIGGER_PIN) == LOW) {
    //WiFiManager wm;    ==> placed in comments, the object is now created globaly, so wont be destroyed

    //reset settings - for testing
    //wm.resetSettings();
  
    // set configportal timeout
    wm.setConfigPortalTimeout(timeout);

    if (!wm.startConfigPortal("OnDemandAP")) {
      Serial.println("failed to connect and hit timeout");
      delay(3000);
      //reset and try again, or maybe put it to deep sleep
      ESP.restart();
      delay(5000);
    }

    //if you get here you have connected to the WiFi
    Serial.println("connected...yeey :)");

  }

  // put your main code here, to run repeatedly:
}

Debug Messages

19:36:44.653 > wm:[2] Starting Config Portal 
19:36:44.653 > *wm:[2] Disabling STA 
19:36:44.653 > *wm:[2] Enabling AP 
19:36:44.653 > *wm:[1] StartAP with SSID:  OnDemandAP
19:36:44.653 > *wm:[2] AP has anonymous access!
19:36:44.653 > *wm:[1] AP IP address: 192.168.4.1
19:36:44.653 > *wm:[1] Starting Web Portal
19:36:44.653 > *wm:[2] HTTP server started
19:36:44.653 > *wm:[2] Config Portal Running, blocking, waiting for clients...
19:36:44.653 > *wm:[2] Portal Timeout In 120 seconds
19:36:44.653 > *wm:[2] Portal Timeout In 119 seconds
19:37:03.763 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:03.771 > *wm:[2] <- Request redirected to captive portal
19:37:03.787 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:03.826 > *wm:[2] <- Request redirected to captive portal
19:37:03.965 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:03.973 > *wm:[2] <- Request redirected to captive portal
19:37:04.913 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:04.921 > *wm:[2] <- Request redirected to captive portal
19:37:06.579 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:06.594 > *wm:[2] <- Request redirected to captive portal
19:37:06.611 > *wm:[2] <- HTTP Root 
19:37:06.668 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:07.446 > *wm:[2] <- HTTP Wifi 
19:37:07.456 > *wm:[2] WiFi Scan SYNC started
19:37:12.578 > *wm:[2] WiFi Scan completed in 5119 ms
19:37:12.578 > *wm:[1] 9 networks found
19:37:12.578 > *wm:[2] AP:  -33 dlink
19:37:12.578 > *wm:[2] AP:  -51 CITECT_SKT
19:37:12.578 > *wm:[2] AP:  -60 WiFi-2.4-20D3
19:37:12.586 > *wm:[2] AP:  -67 WiFi-2.4-0F64
19:37:12.586 > *wm:[2] AP:  -78 TP-Link_6464
19:37:12.594 > *wm:[2] AP:  -87 TelenetWiFree
19:37:12.594 > *wm:[2] AP:  -88 telenet-D91F927
19:37:12.594 > *wm:[2] AP:  -94 Proximus Public Wi-Fi
19:37:12.602 > *wm:[2] AP:  -95 Proximus-Home-7568
19:37:12.614 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:12.614 > *wm:[2] <- Request redirected to captive portal
19:37:12.614 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:12.622 > *wm:[2] <- Request redirected to captive portal
19:37:12.630 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:12.630 > *wm:[2] <- Request redirected to captive portal 
19:37:12.886 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:12.903 > *wm:[2] <- Request redirected to captive portal
19:37:13.677 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:13.677 > *wm:[2] <- Request redirected to captive portal
19:37:13.722 > *wm:[2] Portal Timeout In 113 seconds
19:37:13.936 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:13.944 > *wm:[2] <- Request redirected to captive portal
19:37:15.795 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:15.809 > *wm:[2] <- Request redirected to captive portal
19:37:15.852 > *wm:[2] <- HTTP WiFi save  
19:37:15.860 > *wm:[2] processing save
19:37:17.861 > *wm:[2] Connecting as wifi client... 
19:37:17.861 > *wm:[2] setSTAConfig static ip not set, skipping
19:37:17.869 > *wm:[1] Connecting to NEW AP: dlink
19:37:17.869 > *wm:[1] connectTimeout not set, ESP waitForConnectResult...
19:37:23.068 > *wm:[2] Connection result: WL_CONNECTED
19:37:23.068 > *wm:[1] Connect to new AP [SUCCESS]
19:37:23.076 > *wm:[1] Got IP Address:
19:37:23.076 > *wm:[1] 192.168.0.198
19:37:23.084 > *wm:[2] shutdownConfigPortal
19:37:23.084 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:23.084 > *wm:[2] <- Request redirected to captive portal 
19:37:23.101 > *wm:[0] [ERROR] disconnect configportal - softAPdisconnect FAILED
19:37:23.101 > *wm:[2] restoring usermode STA
19:37:24.093 > *wm:[2] wifi status: WL_CONNECTED
19:37:24.093 > *wm:[2] wifi mode: STA
19:37:24.093 > *wm:[2] configportal closed
19:37:24.110 > *wm:[1] config portal exiting
19:37:24.110 > connected...yeey :)
19:37:28.626 > *wm:[2] Starting Config Portal 
19:37:28.634 > *wm:[2] Enabling AP
19:37:28.634 > *wm:[1] StartAP with SSID:  OnDemandAP
19:37:28.634 > *wm:[2] AP has anonymous access!
19:37:29.135 > *wm:[1] AP IP address: 192.168.4.1
19:37:29.135 > *wm:[1] Starting Web Portal
19:37:29.144 > *wm:[2] HTTP server started
19:37:29.144 > *wm:[2] Config Portal Running, blocking, waiting for clients...
19:37:29.152 > *wm:[2] Portal Timeout In 120 seconds
19:37:35.932 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:35.940 > *wm:[2] <- Request redirected to captive portal
19:37:35.972 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:35.980 > *wm:[2] <- Request redirected to captive portal
19:37:36.233 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:36.249 > *wm:[2] <- Request redirected to captive portal
19:37:42.683 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:42.683 > *wm:[2] <- Request redirected to captive portal
19:37:42.701 > *wm:[2] <- HTTP Root 
19:37:42.775 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:43.715 > *wm:[2] <- HTTP Wifi 
19:37:43.715 > *wm:[2] Scan is cached 31143 ms ago
19:37:43.715 > *wm:[1] 9 networks found
19:37:43.723 > *wm:[2] DUP AP:
19:37:43.723 > *wm:[2] DUP AP:
19:37:43.723 > *wm:[2] DUP AP: 
19:37:43.731 > *wm:[2] DUP AP:
19:37:43.731 > *wm:[2] DUP AP:
19:37:43.731 > *wm:[2] DUP AP:
19:37:43.731 > *wm:[2] DUP AP:
19:37:43.731 > *wm:[2] DUP AP:
19:37:43.731 > *wm:[2] AP:  0
19:37:43.739 > *wm:[2] Portal Timeout In 119 seconds
19:37:43.755 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:43.771 > *wm:[2] <- Request redirected to captive portal
19:37:43.779 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:43.787 > *wm:[2] <- Request redirected to captive portal
19:37:44.557 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:44.557 > *wm:[2] <- Request redirected to captive portal
19:37:44.765 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:44.773 > *wm:[2] <- Request redirected to captive portal
19:37:44.773 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:37:44.789 > *wm:[2] <- Request redirected to captive portal
19:38:01.131 > [E][WebServer.cpp:633] _handleRequest(): request handler not found
19:38:01.148 > *wm:[2] <- Request redirected to captive portal
@tablatronix
Copy link
Collaborator

hmm, good find, ill test this

@tablatronix tablatronix added the bug Validated BUG label Apr 6, 2022
@tablatronix
Copy link
Collaborator

changed this 590e212 will be a better fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Validated BUG
Projects
None yet
Development

No branches or pull requests

2 participants