Open
Description
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:
- 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);
beforeWiFi.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())
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:
_wifi_ap_ip = IPAddress((char)random(11, 172), (char)random(0, 255), (char)random(0, 255), 0x01);
WiFi.config(_wifi_ap_ip, _wifi_ap_ip, _wifi_ap_ip, IPAddress(255, 255, 255, 0));
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
Metadata
Metadata
Assignees
Labels
No labels