mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-21 21:22:31 +03:00
WiFi - static IP auto gw,mask,dns as in Arduino libraries (#9031)
This commit is contained in:
@ -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;
|
||||
if (!dns.isSet()) {
|
||||
dns = gw;
|
||||
}
|
||||
return config(local_ip, dns, gw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change DNS for static IP configuration
|
||||
* @param dns1 Static DNS server 1
|
||||
|
@ -46,6 +46,11 @@ class ESP8266WiFiSTAClass: public LwipIntf {
|
||||
//to detect Arduino arg order, and handle it correctly. Be aware that the Arduino default value handling doesn't
|
||||
//work here (see Arduino docs for gway/subnet defaults). In other words: at least 3 args must always be given.
|
||||
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = INADDR_ANY, IPAddress dns2 = INADDR_ANY);
|
||||
|
||||
// two and one parameter version. 2nd parameter is DNS like in Arduino
|
||||
// IPv4 only
|
||||
bool config(IPAddress local_ip, IPAddress dns = INADDR_ANY);
|
||||
|
||||
bool setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY);
|
||||
|
||||
bool reconnect();
|
||||
|
Reference in New Issue
Block a user