WiFiManager - Combine NonBlocking portal AND addParameter I wish to config WiFiManager and addParameter of MQTT topic and local server on its ConfigPortal.
Additionally in a case of a power outage or any, in case of losing WiFi, to continue in a NonBlocking way.
The problem is when combining both features in one sketch, I get some errors.
Entire code is ( please notice comments marked Marker[i] ):
#include &lt;WiFiManager.h&gt;
#define MQTT_SERVER &quot;192.168.3.200&quot;
WiFiManager wm;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  WiFiManagerParameter custom_mqtt_server(&quot;mqtt_server&quot;, &quot;mqtt server&quot;, MQTT_SERVER, 40);
  WiFiManagerParameter custom_mqtt_user(&quot;mqtt_user&quot;, &quot;mqtt user&quot;, &quot;&quot;, 10);
  WiFiManagerParameter custom_mqtt_pwd(&quot;mqtt_pwd&quot;, &quot;mqtt password&quot;, &quot;&quot;, 10);
  WiFiManagerParameter custom_mqtt_topic(&quot;mqtt_topic&quot;, &quot;mqtt topic&quot;, &quot;&quot;, 10);
  WiFiManagerParameter custom_mqtt_group(&quot;mqtt_group&quot;, &quot;mqtt group&quot;, &quot;&quot;, 10);
  WiFiManagerParameter custom_mqtt_root(&quot;mqtt_root&quot;, &quot;mqtt rootTopic&quot;, &quot;&quot;, 10);
  wm.addParameter(&amp;custom_mqtt_server);
  wm.addParameter(&amp;custom_mqtt_user);
  wm.addParameter(&amp;custom_mqtt_pwd);
  wm.addParameter(&amp;custom_mqtt_topic);
  wm.addParameter(&amp;custom_mqtt_group);
  wm.addParameter(&amp;custom_mqtt_root);

  WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
  //  wm.resetSettings();

  //  wm.setConfigPortalTimeout(180);
  // wm.setConfigPortalBlocking(false);  // &lt;--- Marker [#1]

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

  bool res;
  res = wm.autoConnect(&quot;test123&quot;, &quot;password&quot;); // password protected ap
}

void loop() {
  // put your main code here, to run repeatedly:
  //  wm.process(); //&lt;--- Marker [2]
  Serial.println(&quot;hi&quot;);
  delay(100);

}


When Marker[1] &amp; Marker[2] are commented out ConfigPortal works as expected, and in Blocked state - meaning there is no hi's on Serial monitor.

When only Marker[2] is commented out, ConfigPortal is reached, lacking all addParameter fields.

When Marker[1] &amp; Marker[2] are not commented out, ConfigPortal is now reachable, but not having Non-Blocking feature...

What is the purpose of wm.process() ?


Guy
The WiFiManger's autoConnect function starts the configuration web server (and AP) only if connection to configured WiFi network is not established.
If you want to run the WiFiManger's web server to reconfigure WiFi or to set other parameters, you can start the WM web server with the startConfigPortal function.
autoConnect and startConfigPortal are blocking by default. The library has a loop inside this functions which runs until the web server is stopped calling [Exit] action on the configuration web page or the timeout set with setConfigPortalTimeout is reached after last contact from browser.
To run the WM web server 'parallel' to your sketch you can configure it as not blocking with setConfigPortalBlocking(false). Then to allow WM handling of the web server the sketch must periodically call wm.process().
In not blocking mode the [Exit] action on the configuration wen page doesn't stop the web server. The server must be stopped in code.
The parameter definitions must by global in sketch, if you want to run WiFiManager with parameters outside of setup(). Parameters local in setup() don't exist after setup() finishes. WiFiManager detects this and doesn't use the parameters.
The OnDemandWebPortal example and OnDemandNonBlocking example demonstrate startConfigPortal in blocking and not blocking use.