You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having troubles in switching between WiFi's STA and AP mode on my Arduino GIGA R1 board.
In my scenario, I do the following:
I try to connect to some network (STA)
If connection fails, I open AP (with random IP address) to ask credentials from user
Once credentials are retrieved (or on timeout, or on error), repeat from point 1.
So far I found that:
WiFiUDP::endPacket() often fails with error -3003 (NSAPI_ERROR_PARAMETER).
For some unknown reasons, if I call IPAddress nullip = IPAddress(); WiFi.config(nullip, nullip, nullip, nullip); before WiFi.end() before STA connection, the latter is incredibly more likely to succeed.
However, if I do so, WiFiUDP:endPacket() always fails as above.
I found that if I do WiFi = WiFiClass(WiFiInterface::get_default_instance()) after WiFi.end() every time I switch between STA and AP, I have less troubles.
Before AP creation, a random IP address is set as follows:
I used to test my code on a protected network and I experienced fewer problems. Then I had to switch to an open network and a mess arose.
I guess a function like a total reset of the WiFi interface with sockets and everything, so to come back to a status as if the Arduino board was just switched on and no connection was attempted, would be advantageous in switching between STA and AP mode.
Thank you
The text was updated successfully, but these errors were encountered:
giorgiogallina
changed the title
WiFi IP issues, need WiFi::reset()
WiFi IP config issues, need WiFi::reset()
Mar 31, 2025
So far, I have found that I need to call WiFi.disconnect() before WiFi.end(), since the latter does not automatically perform a disconnection. Since I used to invoke WiFi.config(nullip, ...) after explicit disconnection, probably it was not the config that enhanced subsequent probability of successful connection, but rather the explicit disconnection.
[Edit: this is true, but DHCP would not be restored]
These modifications seem to improve my program, yet the WiFiUDP::endPacket() still fails with code -3003.
I'll keep debugging and update this issue with more details, if I discover anything interesting.
Meanwhile, I report that in WiFiClass::end(), the command _softAP = nullptr is invoked even if _sofAP was not stopped ("disconnected"), which may cause issues like some of the ones I was experiencing
On the side, I am wondering if in file ArduinoCore-mbed/libraries/WiFi/src/WiFi.cpp in function WiFiClass::beginAP(...), lines 131-134, a softAPInterface->stop() should be performed before returning.
Moreover, on line 136, the condition result == NSAPI_ERROR_OK seems redundant, isn't it?
Dear developers,
I am having troubles in switching between WiFi's STA and AP mode on my Arduino GIGA R1 board.
In my scenario, I do the following:
So far I found that:
WiFiUDP::endPacket()
often fails with error -3003 (NSAPI_ERROR_PARAMETER
).IPAddress nullip = IPAddress(); WiFi.config(nullip, nullip, nullip, nullip);
beforeWiFi.end()
before STA connection, the latter is incredibly more likely to succeed.WiFiUDP:endPacket()
always fails as above.WiFi = WiFiClass(WiFiInterface::get_default_instance())
afterWiFi.end()
every time I switch between STA and AP, I have less troubles.Before AP creation, a random IP address is set as follows:
I used to test my code on a protected network and I experienced fewer problems. Then I had to switch to an open network and a mess arose.
I guess a function like a total reset of the WiFi interface with sockets and everything, so to come back to a status as if the Arduino board was just switched on and no connection was attempted, would be advantageous in switching between STA and AP mode.
Thank you
The text was updated successfully, but these errors were encountered: