Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples Captive Portal not starting with SSID ESP_AP #55

Open
willi-uce opened this issue Dec 30, 2024 · 3 comments
Open

Examples Captive Portal not starting with SSID ESP_AP #55

willi-uce opened this issue Dec 30, 2024 · 3 comments

Comments

@willi-uce
Copy link

In the examples:
// Try to connect to stored SSID, start AP with captive portal if fails after timeout
IPAddress myIP = server.startWiFi(15000);
if (!myIP) {
Serial.println("\n\nNo WiFi connection, start AP and Captive Portal\n");
server.startCaptivePortal("ESP_AP", "123456789", "/setup");
myIP = WiFi.softAPIP();
captiveRun = true;
}

myIP is always 192.168.4.1 when there is no connection to Router, so (!myIP) is never true and Captive Portal is not startet.
But captive portal is running with other name (ESP-...) and without password.

@mano1979
Copy link

I have this issue too. For now i have it partly hardwired in the src files, however this only handles the ssid and not the password (maybe because of my poor programming skills.)

But yes, The ssid and password that are in the .ino sketch are not being used.

@willi-uce
Copy link
Author

I tested some things and my solution is:

In the sketch:
Change
IPAddress myIP = server.startWiFi(15000); to
IPAddress myIP = server.startWiFi(15000, nullptr, true);

When there is no AP or the credentials are wrong then AP ist startet with ("ESP_AP", "123456789" because the returned IP is 0.0.0.0

But when there are no credentials in the ESP AP is starting with another name and without password.
I put the following code in line 675 of AsyncFsWebServer.cpp:

           // If AP not needed because it will be started in sketch
            if (skipAP) return IPAddress(0, 0, 0, 0);

@mano1979: Maybe you can test this ?

@mano1979
Copy link

mano1979 commented Jan 5, 2025

i made the above adjustments to the code and then found my issue. I had manually entered the ssid and passw in the src/.cpp file, but i also left the old line in there. so there were 2 lines doing the same thing. anyway, it works now.

as for your issue, i cannot test it because i don't know how to erase the wifi credentials that are saved. I tried before, and even after multiple flash erase cycles, the wifi credentials stayed in memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants