earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
2.04k stars 423 forks source link

Cannot switch from AP mode to station mode #2266

Closed andnic closed 3 months ago

andnic commented 3 months ago

Clear LwipIntfDev::_netif in LwipIntfDev::end() to allow switching from AP to station modes.

Similar to #884, after starting AP mode it is not possible to switch to station mode. The call to WiFi.begin() completes instantaneously and the AP IP address persists.

Taking clues from #905, the connection state is derived from the presence of an IP address in LwipIntfDev::_netif. Zeroing out _netif in LwipIntfDev::end() remedies the issue and allows switching from station to AP and back successfully.

JAndrassy commented 3 months ago

.end() should not clear the static IP configuration so next begin() can use it. it is this way in other Arduino networking libraries too. please try to find a different way to make AP mode work