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

fix: DNSServer Lib - improper startup code in WiFi mode #10366

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ void setup() {

// by default DNSServer is started serving any "*" domain name. It will reply
// AccessPoint's IP to all DNS request (this is required for Captive Portal detection)
dnsServer.start();
if (dnsServer.start()) {
Serial.println("Started DNS server in captive portal-mode");
} else {
Serial.println("Err: Can't start DNS server!");
}

// serve a simple root page
server.on("/", handleRoot);
Expand Down
7 changes: 5 additions & 2 deletions libraries/DNSServer/src/DNSServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ bool DNSServer::start() {
#if SOC_WIFI_SUPPORTED
if (WiFi.getMode() & WIFI_AP) {
_resolvedIP = WiFi.softAPIP();
return true;
} else {
return false; // won't run if WiFi is not in AP mode, or no WiFi
}
#else
return false; // for other non WiFi-AP networking an overloaded method must be used to get device's IP
// start(uint16_t port, const String &domainName, const IPAddress &resolvedIP)
#endif
return false; // won't run if WiFi is not in AP mode
}

_udp.close();
Expand Down
Loading