Replace function WiFi.hostByName()

This commit is contained in:
Theo Arends 2022-06-19 18:13:26 +02:00
parent c988ba1645
commit b5dd23ae9f
3 changed files with 3 additions and 7 deletions

View File

@ -2452,8 +2452,7 @@ void SyslogAsync(bool refresh) {
uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST))); uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST)));
if (syslog_host_hash != current_hash) { if (syslog_host_hash != current_hash) {
IPAddress temp_syslog_host_addr; 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 (!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
if (!ok || (0xFFFFFFFF == (uint32_t)temp_syslog_host_addr)) { // 255.255.255.255 is assumed a DNS problem
TasmotaGlobal.syslog_level = 0; TasmotaGlobal.syslog_level = 0;
TasmotaGlobal.syslog_timer = SYSLOG_TIMER; 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); 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);

View File

@ -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 // 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]; uint32_t dns_address = (!TasmotaGlobal.global_state.eth_down) ? Settings->eth_ipv4_address[3] : Settings->ipv4_address[3];
DnsClient.begin((IPAddress)dns_address); DnsClient.begin((IPAddress)dns_address);
if (1 == DnsClient.getHostByName(aHostname, aResult)) { return (1 == DnsClient.getHostByName(aHostname, aResult));
return true;
}
return false;
} }
void WifiPollNtp() { void WifiPollNtp() {

View File

@ -244,7 +244,7 @@ extern "C" {
// -2: unable to resolve address // -2: unable to resolve address
int32_t t_ping_start(const char *hostname, uint32_t count) { int32_t t_ping_start(const char *hostname, uint32_t count) {
IPAddress ipfull; IPAddress ipfull;
if (!WiFi.hostByName(hostname, ipfull)) { if (!WifiHostByName(hostname, ipfull)) {
ipfull = 0xFFFFFFFF; ipfull = 0xFFFFFFFF;
} }