[GH-ISSUE #652] How to don't be blocked by wifiManager.autoConnect()? #545

Closed
opened 2026-02-28 01:25:47 +03:00 by kerem · 10 comments
Owner

Originally created by @spilz87 on GitHub (Jul 10, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/652

Hello,
I'm using wifiManger library and it works very well for me.
But for my projects, my esp8266s have other stuff to do than wifi stuff (like receive data through serial port and display them on screen) independently of wifi connection.
So I need a way to don't be blocked during wifi connection, more over when there is no wifi in house.
Is it possible to have like a state machine for wifi connection that is call in loop() but doesn't block the use of the esp ?
Sorry for my bad English, I hope you understand what I mean, if no, let me know to try explain differently

Thanks for your help

Originally created by @spilz87 on GitHub (Jul 10, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/652 Hello, I'm using wifiManger library and it works very well for me. But for my projects, my esp8266s have other stuff to do than wifi stuff (like receive data through serial port and display them on screen) independently of wifi connection. So I need a way to don't be blocked during wifi connection, more over when there is no wifi in house. Is it possible to have like a state machine for wifi connection that is call in loop() but doesn't block the use of the esp ? Sorry for my bad English, I hope you understand what I mean, if no, let me know to try explain differently Thanks for your help
kerem 2026-02-28 01:25:47 +03:00
Author
Owner

@d-a-v commented on GitHub (Jul 10, 2018):

I have the same feature request.
For my personal use I added a callback for that purpose: offline-loop
I did not make it a PR. Devs might consider implementing a similar feature for working-offline guys like us :)

edit: the way to use it is to make all offline operations in void loop_offline(), set this function in the above callback, and call it too from within loop(). What I meant is that Devs might propose a better way to do that with official WiFiManager's API.

<!-- gh-comment-id:403982408 --> @d-a-v commented on GitHub (Jul 10, 2018): I have the same feature request. For my personal use I added a callback for that purpose: [offline-loop](https://github.com/tzapu/WiFiManager/compare/master...d-a-v:loop) I did not make it a PR. Devs might consider implementing a similar feature for working-offline guys like us :) *edit:* the way to use it is to make all offline operations in `void loop_offline()`, set this function in the above callback, and call it too from within `loop()`. What I meant is that Devs might propose a better way to do that with official WiFiManager's API.
Author
Owner

@tablatronix commented on GitHub (Jul 11, 2018):

Develoment branch setconfigportalblocking false , process() in loop

<!-- gh-comment-id:404011412 --> @tablatronix commented on GitHub (Jul 11, 2018): Develoment branch setconfigportalblocking false , process() in loop
Author
Owner

@spilz87 commented on GitHub (Jul 11, 2018):

That's the idea, I prefer the way to have a process in loop than to have to separe online and offline part

<!-- gh-comment-id:404144492 --> @spilz87 commented on GitHub (Jul 11, 2018): That's the idea, I prefer the way to have a process in loop than to have to separe online and offline part
Author
Owner

@tablatronix commented on GitHub (Jul 11, 2018):

I am making an example now, It has not been tested yet though.

something like this should work

#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
WiFiManager wm;

void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    
    //reset settings - wipe credentials for testing
    //wm.resetSettings();

    wm.setConfigPortalBlocking(false);

    //automatically connect using saved credentials if they exist
    //If connection fails it starts an access point with the specified name
    if(wm.autoConnect("AutoConnectAP")){
        Serial.println("connected...yeey :)");
    }
    else {
        Serial.println("Configportal running");
    }
}

void loop() {
    wm.process();
    // put your main code here, to run repeatedly:
}
<!-- gh-comment-id:404198886 --> @tablatronix commented on GitHub (Jul 11, 2018): I am making an example now, It has not been tested yet though. something like this should work ```CPP #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager WiFiManager wm; void setup() { // put your setup code here, to run once: Serial.begin(115200); //reset settings - wipe credentials for testing //wm.resetSettings(); wm.setConfigPortalBlocking(false); //automatically connect using saved credentials if they exist //If connection fails it starts an access point with the specified name if(wm.autoConnect("AutoConnectAP")){ Serial.println("connected...yeey :)"); } else { Serial.println("Configportal running"); } } void loop() { wm.process(); // put your main code here, to run repeatedly: } ```
Author
Owner

@d-a-v commented on GitHub (Jul 11, 2018):

Thanks a lot !

<!-- gh-comment-id:404201151 --> @d-a-v commented on GitHub (Jul 11, 2018): Thanks a lot !
Author
Owner

@tablatronix commented on GitHub (Jul 14, 2018):

dup #379

<!-- gh-comment-id:404998940 --> @tablatronix commented on GitHub (Jul 14, 2018): dup #379
Author
Owner

@spilz87 commented on GitHub (Jul 15, 2018):

Hello,
Actually it doesn't really solve all my request :
I need no blocking at all, even during connection.
If I understand well with your exemple, we don't stay blocked if it run portail, but if there is wrong wifi settings, it stay on the conne ruin loop, until connection time out (if set).
For my projects with an oled screen and rotary encoder (like on 3d printer) I need the ESP react to the encoder, connected or trying to connect or not connected. Like a state machine run in loop()

<!-- gh-comment-id:405078949 --> @spilz87 commented on GitHub (Jul 15, 2018): Hello, Actually it doesn't really solve all my request : I need no blocking at all, even during connection. If I understand well with your exemple, we don't stay blocked if it run portail, but if there is wrong wifi settings, it stay on the conne ruin loop, until connection time out (if set). For my projects with an oled screen and rotary encoder (like on 3d printer) I need the ESP react to the encoder, connected or trying to connect or not connected. Like a state machine run in loop()
Author
Owner

@tablatronix commented on GitHub (Jul 15, 2018):

Then don't use autoconnect or use a really short connecttimeout.
Not sure what to tell you more specifically.

<!-- gh-comment-id:405096957 --> @tablatronix commented on GitHub (Jul 15, 2018): Then don't use autoconnect or use a really short connecttimeout. Not sure what to tell you more specifically.
Author
Owner

@spilz87 commented on GitHub (Jul 16, 2018):

you mean by using begin instead of autoconnect ?

<!-- gh-comment-id:405174153 --> @spilz87 commented on GitHub (Jul 16, 2018): you mean by using begin instead of autoconnect ?
Author
Owner

@tablatronix commented on GitHub (Jul 16, 2018):

Yeah and manually check connect status and start configportal in your code so you have better control.

<!-- gh-comment-id:405222901 --> @tablatronix commented on GitHub (Jul 16, 2018): Yeah and manually check connect status and start configportal in your code so you have better control.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#545
No description provided.