From 23ba25c6652906bdedb7b3c8761a8f4fe9f99f4f Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 29 Aug 2022 14:31:05 +0200 Subject: [PATCH] Refactor WifiHostByName() --- tasmota/tasmota_support/support_wifi.ino | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index d1fd40d95..9bce4cda4 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -819,17 +819,23 @@ void wifiKeepAlive(void) { bool WifiHostByName(const char* aHostname, IPAddress& aResult) { #ifdef ESP8266 if (WiFi.hostByName(aHostname, aResult, Settings->dns_timeout)) { - return true; + // Host name resolved + if (0xFFFFFFFF != (uint32_t)aResult) { + 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)) { - return true; + // Host name resolved + if (0xFFFFFFFF != (uint32_t)aResult) { + return true; + } } } else { - // Use this instead of WiFi.hostByName or connect(host_name,.. to block less if DNS server is not found + // Use this instead of WiFi.hostByName or connect(host_name,.. to block less if DNS server is not found uint32_t dns_address = (!TasmotaGlobal.global_state.eth_down) ? Settings->eth_ipv4_address[3] : Settings->ipv4_address[3]; DnsClient.begin((IPAddress)dns_address); if (1 == DnsClient.getHostByName(aHostname, aResult)) {