-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,6 +339,22 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a | |
return true; | ||
} | ||
|
||
bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress dns) { | ||
|
||
if (!local_ip.isSet()) | ||
return config(INADDR_ANY, INADDR_ANY, INADDR_ANY); | ||
|
||
if (!local_ip.isV4()) | ||
return false; | ||
|
||
IPAddress gw(local_ip); | ||
gw[3] = 1; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JAndrassy
Author
Contributor
|
||
if (!dns.isSet()) { | ||
dns = gw; | ||
} | ||
return config(local_ip, dns, gw); | ||
} | ||
|
||
/** | ||
* Change DNS for static IP configuration | ||
* @param dns1 Static DNS server 1 | ||
|
Just wondering what this function does here.
It is really tricky to assume you have a /24 subnet and even so to assume your router's IP-address is ending with .1
So why is this function added?
There are quite a few ISP issued modem/routers which use .254 as their default gateway IP.
By introducing a function like this, you can be sure people will use it and then some users may need to alter the code to make it work in their setup.
I did a quick Google search and found this list of brands which have their default gateway IP ending with .254:
And for those with a separate (V)LAN for their IoT stuff, it also makes sense to use "the other end" of the range as gateway for that subnet.