Skip to content

Commit fbfcb80

Browse files
authored
WiFiSTA - method setDNS as in WiFi libraries by Arduino (espressif#8854)
https://www.arduino.cc/reference/en/libraries/wifi/wifi.setdns/
1 parent 0b6d20e commit fbfcb80

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libraries/WiFi/src/WiFiSTA.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,19 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
431431
return err == ESP_OK;
432432
}
433433

434+
/**
435+
* Change DNS server for static IP configuration
436+
* @param dns1 Static DNS server 1
437+
* @param dns2 Static DNS server 2 (optional)
438+
*/
439+
bool WiFiSTAClass::setDNS(IPAddress dns1, IPAddress dns2)
440+
{
441+
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL)
442+
return false;
443+
esp_err_t err = set_esp_interface_dns(ESP_IF_WIFI_STA, dns1, dns2);
444+
return err == ESP_OK;
445+
}
446+
434447
/**
435448
* is STA interface connected?
436449
* @return true if STA is connected to an AP

libraries/WiFi/src/WiFiSTA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class WiFiSTAClass
5656
wl_status_t begin();
5757

5858
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
59+
bool setDNS(IPAddress dns1, IPAddress dns2 = (uint32_t)0x00000000); // sets DNS IP for all network interfaces
5960

6061
bool reconnect();
6162
bool disconnect(bool wifioff = false, bool eraseap = false);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy