-->
Page 1 of 1

[FIXED] Disconnecting from one AP and connecting to another

PostPosted: Thu Sep 08, 2016 12:24 pm
by RichardS
[FIXED read the whole thread to see how....]

So I am current connected to AP X and I want to disconnect X and connect to AP Y, so I use

Code: Select allWiFi.disconnect();
while (WiFi.status() == WL_CONNECTED) delay(1000);


to make sure I am disconnected from X.

Why does this cause a WDT I am delay()ing....

Any other better methods?

As a side note.... sometimes it does not WDT and it gets to the famous

Code: Select all    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial..print(".");
      if (++cnt == 40) {
        break;
      }
    }


type loop, where I bailout if not connected in 20 seconds, however sometimes the "." is printed very fast across the terminal almost like delay() is broken.....

Thoughts? Is it all related?

RichardS

Re: Disconnecting from one AP and connecting to another

PostPosted: Thu Sep 08, 2016 3:45 pm
by RichardS
Yep still at this, and no luck, so easy, but so hard!

Done all sorts of WAY more complicated things and this is biting me.

RichardS

[FIXED] Disconnecting from one AP and connecting to another

PostPosted: Thu Sep 08, 2016 11:30 pm
by RichardS
Fixed it, I was using ticker() and within the async nature of the function call of the timer going off it would disconnect and reconnect and it does not like this! Now the ticker function just sets a flag that I detect in the loop and call the function in a sync fashion.

So the delay function is now happy also, I need to look up if your allowed to use delay() in the function that ticker calls :-)

RichardS

Re: [FIXED] Disconnecting from one AP and connecting to anot

PostPosted: Thu Sep 08, 2016 11:34 pm
by RichardS
So it is a no-no to call delay() in a ticker() function call....

https://github.com/esp8266/Arduino/issues/668

RichardS