fix: DNSServer Lib - improper startup code in WiFi mode (#10366)
* DNSServer: fix improper startup code in WiFi mode When running on WiFi-AP mode server's start() method returned true while in fact UDP listening socket was never created Regression introduced in #8760 Closes #10330 * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
55bd1d5ee2
commit
b05f18dad5
2 changed files with 10 additions and 3 deletions
|
|
@ -39,7 +39,11 @@ void setup() {
|
||||||
|
|
||||||
// by default DNSServer is started serving any "*" domain name. It will reply
|
// 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)
|
// 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
|
// serve a simple root page
|
||||||
server.on("/", handleRoot);
|
server.on("/", handleRoot);
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,13 @@ bool DNSServer::start() {
|
||||||
#if SOC_WIFI_SUPPORTED
|
#if SOC_WIFI_SUPPORTED
|
||||||
if (WiFi.getMode() & WIFI_AP) {
|
if (WiFi.getMode() & WIFI_AP) {
|
||||||
_resolvedIP = WiFi.softAPIP();
|
_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
|
#endif
|
||||||
return false; // won't run if WiFi is not in AP mode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_udp.close();
|
_udp.close();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue