Thanks for your response. Sorry it took so long to get back to you.
What Iām looking for is the ability to configure the 2 static DNS server IPās inside the wifimanager portal. Tzapuās wifimanager doesnāt have that ability. You can only enter the static IP address, the gateway IP address and the subnet mask in the portal. Maybe Iām doing something wrong, but I canāt get my device to connect to blynk without at least 1 DNS IP address specified in WiFi.config(). I therefore had to modify the Tzapuās wifimanager library myself to achieve what I just described. See below for details.
Within the following function
int WiFiManager::connectWifi(String ssid, String pass)
I replaced
if (_sta_static_ip) {
DEBUG_WM(F("Custom STA IP/GW/Subnet"));
WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn);
DEBUG_WM(WiFi.localIP());
}
with
if (_sta_static_ip) {
DEBUG_WM(F("Custom STA IP/GW/Subnet"));
//***** Added section for DNS config option *****
if (_sta_static_dns1 && _sta_static_dns2) {
DEBUG_WM(F("dns1 and dns2 set"));
WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn, _sta_static_dns1, _sta_static_dns2);
}
else if (_sta_static_dns1) {
DEBUG_WM(F("only dns1 set"));
WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn, _sta_static_dns1);
}
else {
DEBUG_WM(F("No DNS server set"));
WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn);
}
//***** End added section for DNS config option *****
DEBUG_WM(WiFi.localIP());
}
Then I modified this function
void WiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns_address_1, IPAddress dns_address_2) {
_sta_static_ip = ip;
_sta_static_gw = gw;
_sta_static_sn = sn;
_sta_static_dns1 = dns_address_1; //***** Added argument *****
_sta_static_dns2 = dns_address_2; //***** Added argument *****
}
I then added the DNS options to the portal form inside the following function
void WiFiManager::handleWifi(boolean scan) {
like so
//***** Added for DNS address options *****
page += item;
item = FPSTR(HTTP_FORM_PARAM);
item.replace("{i}", "dns1");
item.replace("{n}", "dns1");
item.replace("{p}", "DNS Address 1");
item.replace("{l}", "15");
item.replace("{v}", _sta_static_dns1.toString());
page += item;
item = FPSTR(HTTP_FORM_PARAM);
item.replace("{i}", "dns2");
item.replace("{n}", "dns2");
item.replace("{p}", "DNS Address 2");
item.replace("{l}", "15");
item.replace("{v}", _sta_static_dns2.toString());
//***** End added for DNS address options *****
And also inside the handleWifiSave function like so
//***** Added for DNS Options *****
if (server->arg("dns1") != "") {
DEBUG_WM(F("DNS address 1"));
DEBUG_WM(server->arg("dns1"));
String dns1 = server->arg("dns1");
optionalIPFromString(&_sta_static_dns1, dns1.c_str());
}
if (server->arg("dns2") != "") {
DEBUG_WM(F("DNS address 2"));
DEBUG_WM(server->arg("dns2"));
String dns2 = server->arg("dns2");
optionalIPFromString(&_sta_static_dns2, dns2.c_str());
}
//***** End added for DNS Options *****
Finally, Inside the .h file, I modified the setSTAStaticIPConfig as follows
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns_address_1, IPAddress dns_address_2);
And also added these two private variables
IPAddress _sta_static_dns1;
IPAddress _sta_static_dns2;