Skip to content
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
16 changes: 16 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down