From 03f2e0b6e98c64ea9fa5284c7267f0ca5f6cad14 Mon Sep 17 00:00:00 2001 From: rogg Date: Tue, 23 Aug 2022 20:38:11 -0700 Subject: [PATCH] Use Wifi.hostByName() for ESP8266 Saves ~1K on ESP8266. Also, the check for resolving to 255.255.255.255 is already done by Wifi.hostByName(). --- tasmota/tasmota_support/support_wifi.ino | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index af50e53ac..d1fd40d95 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -817,14 +817,16 @@ void wifiKeepAlive(void) { #endif // ESP8266 bool WifiHostByName(const char* aHostname, IPAddress& aResult) { +#ifdef ESP8266 + if (WiFi.hostByName(aHostname, aResult, Settings->dns_timeout)) { + return true; + } +#else // DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local size_t hostname_len = strlen(aHostname); if (strstr_P(aHostname, PSTR(".local")) == &aHostname[hostname_len] - 6) { if (WiFi.hostByName(aHostname, aResult)) { - // Host name resolved - if (0xFFFFFFFF != (uint32_t)aResult) { - return true; - } + return true; } } else { // Use this instead of WiFi.hostByName or connect(host_name,.. to block less if DNS server is not found @@ -834,6 +836,7 @@ bool WifiHostByName(const char* aHostname, IPAddress& aResult) { return true; } } +#endif AddLog(LOG_LEVEL_DEBUG, PSTR("DNS: Unable to resolve '%s'"), aHostname); return false; }