[GH-ISSUE #1353] EXIT button cannot work in non-blocking mode #1160

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

Originally created by @stacklover on GitHub (Feb 2, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1353

Basic Infos

Hardware

WiFimanager Branch/Release: Master

The EXIT button in the Portal does not work in non blocking mode, because:

void WiFiManager::handleExit() faithfully sets "abort = true",

but "abort" is only checked in the while(1) loop in blocking mode

if one uses non blocking mode it is not checked and there is no method to read this private variable.

I believe it should be handled in the "boolean WiFiManager::process()" function in a similar way it is handled while in blocking mode?

I will try to do that :)

Originally created by @stacklover on GitHub (Feb 2, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1353 ### Basic Infos #### Hardware WiFimanager Branch/Release: Master The EXIT button in the Portal does not work in non blocking mode, because: void WiFiManager::handleExit() faithfully sets "abort = true", but "abort" is only checked in the while(1) loop in blocking mode if one uses non blocking mode it is not checked and there is no method to read this private variable. I believe it should be handled in the "boolean WiFiManager::process()" function in a similar way it is handled while in blocking mode? I will try to do that :)
kerem 2026-02-28 01:28:47 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tablatronix commented on GitHub (Feb 2, 2022):

I guess the question should be, should it work ? Do we want it to ? Or should it be fixed to allow code to decide what to do via a callout maybe ?

hmm

<!-- gh-comment-id:1028224135 --> @tablatronix commented on GitHub (Feb 2, 2022): I guess the question should be, should it work ? Do we want it to ? Or should it be fixed to allow code to decide what to do via a callout maybe ? hmm
Author
Owner

@stacklover commented on GitHub (Feb 2, 2022):

An EXIT button should work the same way in blocking and non-blocking mode, right?
If one could have a callback function to handle it, it should also work the same.
My solution right now is and works how I would expect it to (added stuff between the "++++++":

/**

  • [process description]

  • @access public

  • @return {[type]} [description]
    */
    boolean WiFiManager::process(){
    // process mdns, esp32 not required
    #if defined(WM_MDNS) && defined(ESP8266)
    MDNS.update();
    #endif
    //+++++++++++++++++++++++
    // check for abort set
    if(abort){
    #ifdef WM_DEBUG_LEVEL
    DEBUG_WM(DEBUG_DEV,F("configportal abort"));
    #endif
    shutdownConfigPortal();
    abort = false; // prevent repetitive calling
    }
    //+++++++++++++++++++++++

    if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){
    uint8_t state = processConfigPortal();
    return state == WL_CONNECTED;
    }
    return false;
    }

<!-- gh-comment-id:1028340086 --> @stacklover commented on GitHub (Feb 2, 2022): An EXIT button should work the same way in blocking and non-blocking mode, right? If one could have a callback function to handle it, it should also work the same. My solution right now is and works how I would expect it to (added stuff between the "++++++": /** * [process description] * @access public * @return {[type]} [description] */ boolean WiFiManager::process(){ // process mdns, esp32 not required #if defined(WM_MDNS) && defined(ESP8266) MDNS.update(); #endif //+++++++++++++++++++++++ // check for abort set if(abort){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("configportal abort")); #endif shutdownConfigPortal(); abort = false; // prevent repetitive calling } //+++++++++++++++++++++++ if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){ uint8_t state = processConfigPortal(); return state == WL_CONNECTED; } return false; }
Author
Owner

@tablatronix commented on GitHub (Feb 3, 2022):

I mean do you always want to allow an end user to stop portal?
I might have to add access control mechanism

<!-- gh-comment-id:1028498881 --> @tablatronix commented on GitHub (Feb 3, 2022): I mean do you always want to allow an end user to stop portal? I might have to add access control mechanism
Author
Owner

@tablatronix commented on GitHub (Feb 3, 2022):

#982

<!-- gh-comment-id:1028519703 --> @tablatronix commented on GitHub (Feb 3, 2022): #982
Author
Owner

@stacklover commented on GitHub (Feb 3, 2022):

I think, you miss the point: there is an "EXIT" button automatically presented in the portal. And therefore it should work exactly like an end user expects it to.
It is discussable, whether that button should be displayed optionally, aka "setShowExitButton(bool)", but as long as it is shown it should work.
Currently I am happy having that button and with my small patch it is working as I expect it.

Needless to say, after 2-3 days learning curve, the WiFiManager does exactly what I need for my application:

  • optional(!) WiFi setup (because WiFi connection is optional)
  • optional parameter changing (from factory defaults) in own submenu (setParamsPage(true))
  • the portal is only started when a button is pressed (need physical access to start the portal, it never starts on its own)
  • WiFi stays off unless its configured
  • the application itself continues to run while the portal is open (quite important)

Thanks for this very good project!

<!-- gh-comment-id:1028736657 --> @stacklover commented on GitHub (Feb 3, 2022): I think, you miss the point: there is an "EXIT" button automatically presented in the portal. And therefore it should work exactly like an end user expects it to. It is discussable, whether that button should be displayed optionally, aka "setShowExitButton(bool)", but as long as it is shown it should work. Currently I am happy having that button and with my small patch it is working as I expect it. Needless to say, after 2-3 days learning curve, the WiFiManager does exactly what I need for my application: * optional(!) WiFi setup (because WiFi connection is optional) * optional parameter changing (from factory defaults) in own submenu (setParamsPage(true)) * the portal is only started when a button is pressed (need physical access to start the portal, it never starts on its own) * WiFi stays off unless its configured * the application itself continues to run while the portal is open (quite important) Thanks for this very good project!
Author
Owner

@tablatronix commented on GitHub (Feb 3, 2022):

The menu is customizable, if we let the user add an exit buton say for ondemand use, then we might have to also add security so someone cannot force it to exit when its not allowed.

thanks for the use case, I agree but might add something extra for this for example there is also a close item

<!-- gh-comment-id:1028989171 --> @tablatronix commented on GitHub (Feb 3, 2022): The menu is customizable, if we let the user add an exit buton say for ondemand use, then we might have to also add security so someone cannot force it to exit when its not allowed. thanks for the use case, I agree but might add something extra for this for example there is also a close item
Author
Owner

@stacklover commented on GitHub (Feb 3, 2022):

IMG_1370
This is what I get without doing anything special to have that EXIT button!
If you think, that should not be this way, we have to figure out why it is that way ;)

<!-- gh-comment-id:1029094973 --> @stacklover commented on GitHub (Feb 3, 2022): ![IMG_1370](https://user-images.githubusercontent.com/16916615/152371168-c5c127ae-47aa-4732-8d22-cf848c44b475.PNG) This is what I get without doing anything special to have that EXIT button! If you think, that should not be this way, we have to figure out why it is that way ;)
Author
Owner

@stacklover commented on GitHub (Feb 3, 2022):

ALL I do configure is this:

void wifiman_setup() {
wifiManager.setDebugOutput(true);
wifiManager.setSaveParamsCallback(SaveParamsCallback);
wifiManager.setBreakAfterConfig(true);
wifiManager.setConfigPortalBlocking(false);
wifiManager.setShowPassword(true);
wifiManager.setParamsPage(true);
wifiManager.setDarkMode(true);
// Enter all Custom Parameters
for (PARAMETER *p = parameters; p->name != NULL; p++) {
p->wpar = new WiFiManagerParameter(p->name, p->name);
wifiManager.addParameter(p->wpar);
}

<!-- gh-comment-id:1029097558 --> @stacklover commented on GitHub (Feb 3, 2022): ALL I do configure is this: void wifiman_setup() { wifiManager.setDebugOutput(true); wifiManager.setSaveParamsCallback(SaveParamsCallback); wifiManager.setBreakAfterConfig(true); wifiManager.setConfigPortalBlocking(false); wifiManager.setShowPassword(true); wifiManager.setParamsPage(true); wifiManager.setDarkMode(true); // Enter all Custom Parameters for (PARAMETER *p = parameters; p->name != NULL; p++) { p->wpar = new WiFiManagerParameter(p->name, p->name); wifiManager.addParameter(p->wpar); }
Author
Owner

@tablatronix commented on GitHub (Feb 3, 2022):

Yes i know sorry, I meant changes going forward and fixing this its already marked as bug, I will have a fix today

#1354

<!-- gh-comment-id:1029244379 --> @tablatronix commented on GitHub (Feb 3, 2022): Yes i know sorry, I meant changes going forward and fixing this its already marked as bug, I will have a fix today #1354
Author
Owner

@tablatronix commented on GitHub (Feb 4, 2022):

lol in the code

* HTTPD CALLBACK exit, closes configportal if blocking, if non blocking undefined

<!-- gh-comment-id:1029548051 --> @tablatronix commented on GitHub (Feb 4, 2022): lol in the code ` * HTTPD CALLBACK exit, closes configportal if blocking, if non blocking undefined`
Author
Owner

@stacklover commented on GitHub (Feb 4, 2022):

didn't see that, though I had added a printf there to see whether its called at all ;)

<!-- gh-comment-id:1029774571 --> @stacklover commented on GitHub (Feb 4, 2022): didn't see that, though I had added a printf there to see whether its called at all ;)
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#1160
No description provided.