Description
Hello,
Following issue #944, I am still struggling to make things work while alternating WiFi between STA and AP mode.
Everything was working quite nicely, until my smartphone's hotspot (an old OnePlus3T that is slowly dying) suddenly brought up the message <hotspot name> isn't secure - This Wi-Wi network uses an older security standard that is being phased out on my laptop running Windows 11 OS.
-
From that point on, my Arduino cannot connect anymore to that hotspot, and after such failures (SSID & password correct, but
WiFi.begin(SSID, password)
Fails), the AP is created (to get from user new SSID and password) butWiFiUDP::endPacket()
Fails (this is used for captive portal's DNS redirection).
Then, since AP communication fails, STA mode is opened again to retry network connection (will we be luckier?), it fails, and AP is then opened again for a new attempt, but this time evenWiFi.beginAP(...)
Fails. -
If the hotspot is switched off at first step (
WiFi.being()
fails because it cannot find SSID), then AP communication succeeds (no UDP issues). Thus, network credentials are asked to the user and so retrieved. However, after we go back to STA mode and this fails again, AP cannot be opened at all anymore (beginAP()
fails).
Every time I switch between STA and AP mode I do the following:
WiFi.end();
delay(20); // might a delay help?
WiFi = WiFiClass(WiFiInterface::get_default_instance()); // TODO: is it safe? Is it necessary?
delay(35); // might a delay help?
and, obviously, stop WiFiUDP etc.