From b5dd23ae9f690f62b2cc4e93ae61efb54d68ed34 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 19 Jun 2022 18:13:26 +0200 Subject: [PATCH] Replace function WiFi.hostByName() --- tasmota/tasmota_support/support.ino | 3 +-- tasmota/tasmota_support/support_wifi.ino | 5 +---- tasmota/tasmota_xdrv_driver/xdrv_38_ping.ino | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tasmota/tasmota_support/support.ino b/tasmota/tasmota_support/support.ino index 343bc6a7f..2e516b737 100755 --- a/tasmota/tasmota_support/support.ino +++ b/tasmota/tasmota_support/support.ino @@ -2452,8 +2452,7 @@ void SyslogAsync(bool refresh) { uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST))); if (syslog_host_hash != current_hash) { IPAddress temp_syslog_host_addr; - int ok = WiFi.hostByName(SettingsText(SET_SYSLOG_HOST), temp_syslog_host_addr); // If sleep enabled this might result in exception so try to do it once using hash - if (!ok || (0xFFFFFFFF == (uint32_t)temp_syslog_host_addr)) { // 255.255.255.255 is assumed a DNS problem + if (!WifiHostByName(SettingsText(SET_SYSLOG_HOST), temp_syslog_host_addr)) { // If sleep enabled this might result in exception so try to do it once using hash TasmotaGlobal.syslog_level = 0; TasmotaGlobal.syslog_timer = SYSLOG_TIMER; AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Loghost DNS resolve failed (%s). " D_RETRY_IN " %d " D_UNIT_SECOND), SettingsText(SET_SYSLOG_HOST), SYSLOG_TIMER); diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index 8d4d371e4..d2c5c7ca9 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -733,10 +733,7 @@ bool WifiHostByName(const char* aHostname, IPAddress& aResult) { // 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)) { - return true; - } - return false; + return (1 == DnsClient.getHostByName(aHostname, aResult)); } void WifiPollNtp() { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_38_ping.ino b/tasmota/tasmota_xdrv_driver/xdrv_38_ping.ino index 5a0ab9097..4390bd1d9 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_38_ping.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_38_ping.ino @@ -244,7 +244,7 @@ extern "C" { // -2: unable to resolve address int32_t t_ping_start(const char *hostname, uint32_t count) { IPAddress ipfull; - if (!WiFi.hostByName(hostname, ipfull)) { + if (!WifiHostByName(hostname, ipfull)) { ipfull = 0xFFFFFFFF; }