Page 1 of 1

How to connect to wifi network while in APSTA mode?

Posted: Sat Mar 12, 2022 2:23 am
by lukedukeusa
Right now I am starting up my esp32-c3 in APSTA mode using esp-idf. This serves a captive portal where a user can select a wifi network and connect to it, similar to how tasmota and wifimanager work. I am able to connect to a network if I call esp_wifi_stop();, then reconfigure, then start the network, but this closes the captive portal. I am would like to start in APSTA mode, but only configure the AP part, then configure the STA later, confirm the STA is working, then shut down the AP, all without rebooting or shutting off wifi or loosing AP connection.

Is this possible and if so how would I do it?

Re: How to connect to wifi network while in APSTA mode?

Posted: Tue Mar 15, 2022 6:01 pm
by mschultz
I am doing something similar (captive portal for Wi-Fi provisioning) in my project and I'd also like an answer to this question.

When operating in APSTA mode, I want to be able to bring up or shut down the AP without affecting the STA connection status, or connect/disconnect the STA without affecting AP operation.

Is this possible?

Re: How to connect to wifi network while in APSTA mode?

Posted: Tue Jun 20, 2023 7:32 am
by maldus
This is still relevant. Is it possible?

Re: How to connect to wifi network while in APSTA mode?

Posted: Tue Jun 20, 2023 10:37 pm
by boarchuz
Yes, you can freely change WiFi mode without needing to completely stop and restart the driver.

eg.

Code: Select all

esp_wifi_start();
esp_wifi_set_mode(AP);
esp_wifi_set_config(AP, &ap_config);
/* ... Receive WiFi credentials from user ... */
esp_wifi_set_mode(APSTA);
esp_wifi_set_config(STA, &user_sta_config);
esp_wifi_connect();
/* ... Connection succeeded, we decide we don't need AP any more ... */
esp_wifi_set_mode(STA);
/* ... Do things, then when done ... */
esp_wifi_disconnect();
esp_wifi_stop();

Re: How to connect to wifi network while in APSTA mode?

Posted: Wed Feb 28, 2024 9:42 pm
by juan3211
Hi, any one from this post has a good source code about this?

I am also trying to make something "similar" to wifimanager but in esp-idf framework.

Thanks a lot