WiFi.begin() interrupts existing ESP-Accesspoint

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

WiFi.begin() interrupts existing ESP-Accesspoint

Postby esp1979 » Mon Mar 21, 2022 11:54 am

Hello all,

I would like to integrate a login procedure into my ESP32 Arduino Sketch as follows:

1. the ESP starts in WIFI_AP_STA mode.
2. the user connects to the accesspoint.
3. the user calls http://192.168.4.1 and gets to the login page.
4. the user enters his WLAN access data into a form and presses a "Connect now" button
5. the ESP connects with WiFi.begin(ssid, password) to the router of the user.
The dynamically generated IP address (WiFi.localIP()) is displayed to the user on the login page.

Problem: After step 5, the connection to the access point (192.168.4.1) breaks down. Apparently WiFi.begin() also terminates the accesspoint.
Of course I can restart the accesspoint in the sketch directly after the WiFi.begin() (with WiFi.softAP(APssid, APpassword); But the short interruption is already enough with make Smartpjhone that they connect again to another favored WLAN network and already one has the user "lost".
So I can't tell the user the IP address as planned in step 6.

How do you do this? Is there a better solution?
How can I execute a WiFi.begin() WITHOUT terminating or restarting the accesspoint of the ESP32?

Thanks for your tips and a good start into the week

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: WiFi.begin() interrupts existing ESP-Accesspoint

Postby chegewara » Mon Apr 11, 2022 11:04 am

The problem is that esp32 in STA mode is connecting to AP on channel that is used by this AP/router, which usually is different than channel on which esp32 is running in AP mode. This means that esp32 has to change channel in AP mode, because it cant work on 2 different channels at the same time.

Im not sure right now if its possible to achieve what you want with esp-idf, or maybe it will behave the same way. What i mean, esp-idf will also disconnect client from esp32 AP for a moment, change channel and reconnect client, but im not sure about web server behavior.

Who is online

Users browsing this forum: No registered users and 68 guests