mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
WiFiSTA - method setDNS as in WiFi libraries by Arduino (#9021)
https://www.arduino.cc/reference/en/libraries/wifi/wifi.setdns/
This commit is contained in:
parent
5bd52d4f86
commit
7fc2caa72f
@ -339,6 +339,29 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change DNS for static IP configuration
|
||||||
|
* @param dns1 Static DNS server 1
|
||||||
|
* @param dns2 Static DNS server 2 (optional)
|
||||||
|
*/
|
||||||
|
bool ESP8266WiFiSTAClass::setDNS(IPAddress dns1, IPAddress dns2) {
|
||||||
|
|
||||||
|
if((WiFi.getMode() & WIFI_STA) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(dns1.isSet()) {
|
||||||
|
// Set DNS1-Server
|
||||||
|
dns_setserver(0, dns1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dns2.isSet()) {
|
||||||
|
// Set DNS2-Server
|
||||||
|
dns_setserver(1, dns2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* will force a disconnect an then start reconnecting to AP
|
* will force a disconnect an then start reconnecting to AP
|
||||||
* @return ok
|
* @return ok
|
||||||
|
@ -45,7 +45,8 @@ class ESP8266WiFiSTAClass: public LwipIntf {
|
|||||||
//The argument order for ESP is not the same as for Arduino. However, there is compatibility code under the hood
|
//The argument order for ESP is not the same as for Arduino. However, there is compatibility code under the hood
|
||||||
//to detect Arduino arg order, and handle it correctly. Be aware that the Arduino default value handling doesn't
|
//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.
|
//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 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
|
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = INADDR_ANY, IPAddress dns2 = INADDR_ANY);
|
||||||
|
bool setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY);
|
||||||
|
|
||||||
bool reconnect();
|
bool reconnect();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user