Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFiSTA - method setDNS as in WiFi libraries by Arduino #8854

Merged
merged 1 commit into from
Nov 10, 2023
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
13 changes: 13 additions & 0 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,19 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
return err == ESP_OK;
}

/**
* Change DNS server for static IP configuration
* @param dns1 Static DNS server 1
* @param dns2 Static DNS server 2 (optional)
*/
bool WiFiSTAClass::setDNS(IPAddress dns1, IPAddress dns2)
{
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL)
return false;
esp_err_t err = set_esp_interface_dns(ESP_IF_WIFI_STA, dns1, dns2);
return err == ESP_OK;
}

/**
* is STA interface connected?
* @return true if STA is connected to an AP
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class WiFiSTAClass
wl_status_t begin();

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

bool reconnect();
bool disconnect(bool wifioff = false, bool eraseap = false);
Expand Down