Can I use STA and AP at the same time ?

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Can I use STA and AP at the same time ?

Postby GeorgeFlorian1 » Mon Oct 28, 2019 10:57 am

Hello !

TL;DR: How can I have AP and STA at the same time, configuring SSID, Password and/or IP Address, Gateway, SubnetMask, DNS while also serving pages using ESPAsyncWebServer to the user giving it the possibility of configuring the previously mentioned parameters and much more.

Right now, my code is separated into two blocks: AP and STA.

While in AP, I give the end-user the possibility of configuring SSID, Password and/or IP Address, Gateway, SubnetMask, DNS.

After the values were entered and saved, the ESP restarts and tries a WiFi.begin(SSID, Password); followed by WiFi.config();

And in STA I have the "functional" code, depending on the project at hand.

I would like to eliminate the ESP.restart() that separates the two WiFi modes and the transition time from one mode to the other. I would like to offer the user a smooth experience while setting up the ESP32.

zekageri
Posts: 43
Joined: Mon Sep 03, 2018 11:04 am

Re: Can I use STA and AP at the same time ?

Postby zekageri » Mon Oct 28, 2019 2:19 pm

You can just use WiFi.mode(WIFI_AP_STA); and than WiFi.begin(SSID,PASSWORD); after the user set it on AP.
Or if it is not working like this, use the WiFi.disconnect() from AP mode and then set AP_STA and start wifi.
If the user configured the right credentials , i assume that they want to switch to the sta network anyway.

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: Can I use STA and AP at the same time ?

Postby GeorgeFlorian1 » Tue Oct 29, 2019 2:00 pm

zekageri wrote:
Mon Oct 28, 2019 2:19 pm
You can just use WiFi.mode(WIFI_AP_STA); and than WiFi.begin(SSID,PASSWORD); after the user set it on AP.
Or if it is not working like this, use the WiFi.disconnect() from AP mode and then set AP_STA and start wifi.
If the user configured the right credentials , i assume that they want to switch to the sta network anyway.
How would that look like ?

Who is online

Users browsing this forum: No registered users and 89 guests