From f9091951be0f9cd4702c1cfbf238989e1528c34f Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 17 Sep 2021 08:56:28 -0500 Subject: [PATCH] add non blocking to basic --- examples/Basic/Basic.ino | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/Basic/Basic.ino b/examples/Basic/Basic.ino index daaee37..a32a46f 100644 --- a/examples/Basic/Basic.ino +++ b/examples/Basic/Basic.ino @@ -1,17 +1,22 @@ #include // https://github.com/tzapu/WiFiManager +// wifimanager can run in a blocking mode or a non blocking mode +// Be sure to know how to process loops with no delay() if using non blocking +bool wm_nonblocking = false; + void setup() { WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // it is a good practice to make sure your code sets wifi mode how you want it. // put your setup code here, to run once: Serial.begin(115200); - // WiFi.mode(WiFi_STA); // it is a good practice to make sure your code sets wifi mode how you want it. - //WiFiManager, Local intialization. Once its business is done, there is no need to keep it around WiFiManager wm; + if(wm_nonblocking) wm.setConfigPortalBlocking(false); - //reset settings - wipe credentials for testing + // reset settings - wipe stored credentials for testing + // these are stored by the esp library //wm.resetSettings(); // Automatically connect using saved credentials, @@ -36,6 +41,6 @@ void setup() { } void loop() { - // put your main code here, to run repeatedly: - + if(wm_nonblocking) wm.process(); // avoid delays() in loop when non-blocking and other long running code + // put your main code here, to run repeatedly: }