How to connect to wifi network while in APSTA mode?

lukedukeusa
Posts: 3
Joined: Wed Feb 23, 2022 11:48 pm

How to connect to wifi network while in APSTA mode?

Postby lukedukeusa » Sat Mar 12, 2022 2:23 am

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?

mschultz
Posts: 8
Joined: Mon Apr 26, 2021 6:41 pm

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

Postby mschultz » Tue Mar 15, 2022 6:01 pm

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?

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

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

Postby maldus » Tue Jun 20, 2023 7:32 am

This is still relevant. Is it possible?

boarchuz
Posts: 575
Joined: Tue Aug 21, 2018 5:28 am

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

Postby boarchuz » Tue Jun 20, 2023 10:37 pm

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();

juan3211
Posts: 3
Joined: Tue Mar 06, 2018 7:33 am

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

Postby juan3211 » Wed Feb 28, 2024 9:42 pm

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

Who is online

Users browsing this forum: Baidu [Spider] and 118 guests