From 1ea89da68524b27061bd86c8e7dcf3df0b367f71 Mon Sep 17 00:00:00 2001 From: Stephen Casner Date: Wed, 16 Jan 2019 17:29:54 -0800 Subject: [PATCH] Improved suppression of repeated log messages when WiFi is down More precise implementation that checks for a change in the interface name and in the DNS server addresses. --- vehicle/OVMS.V3/main/ovms_netmanager.cpp | 31 +++++++++++++++++------- vehicle/OVMS.V3/main/ovms_netmanager.h | 3 ++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/vehicle/OVMS.V3/main/ovms_netmanager.cpp b/vehicle/OVMS.V3/main/ovms_netmanager.cpp index 8ea7f5c0d..58b1ab91a 100644 --- a/vehicle/OVMS.V3/main/ovms_netmanager.cpp +++ b/vehicle/OVMS.V3/main/ovms_netmanager.cpp @@ -190,8 +190,9 @@ OvmsNetManager::OvmsNetManager() { m_dns_modem[i] = (ip_addr_t)ip_addr_any; m_dns_wifi[i] = (ip_addr_t)ip_addr_any; + m_previous_dns[i] = (ip_addr_t)ip_addr_any; } - m_previous_priority = NULL; + m_previous_name[0] = m_previous_name[1] = 0; #ifdef CONFIG_OVMS_SC_GPL_MONGOOSE m_mongoose_task = 0; @@ -445,9 +446,13 @@ void OvmsNetManager::SetDNSServer(ip_addr_t* dnsstore) cserver = std::string(servers,sep,next-sep); sep = next+1; } - ESP_LOGI(TAG, "Set DNS#%d %s",spos,cserver.c_str()); ip4_addr_set_u32(ip_2_ip4(&serverip), ipaddr_addr(cserver.c_str())); serverip.type = IPADDR_TYPE_V4; + if (!ip_addr_cmp(&serverip, &m_previous_dns[spos])) + { + m_previous_dns[spos] = serverip; + ESP_LOGI(TAG, "Set DNS#%d %s",spos,cserver.c_str()); + } dns_setserver(spos++, &serverip); } for (;sposname[0]==search[0])&& (pri->name[1]==search[1])) { - if (pri == m_previous_priority) - return; - m_previous_priority = pri; - ESP_LOGI(TAG, "Interface priority is %c%c%d (" IPSTR "/" IPSTR " gateway " IPSTR ")", - pri->name[0], pri->name[1], pri->num, - IP2STR(&pri->ip_addr.u_addr.ip4), IP2STR(&pri->netmask.u_addr.ip4), IP2STR(&pri->gw.u_addr.ip4)); + if (search[0] != m_previous_name[0] || search[1] != m_previous_name[1]) + { + ESP_LOGI(TAG, "Interface priority is %c%c%d (" IPSTR "/" IPSTR " gateway " IPSTR ")", + pri->name[0], pri->name[1], pri->num, + IP2STR(&pri->ip_addr.u_addr.ip4), IP2STR(&pri->netmask.u_addr.ip4), IP2STR(&pri->gw.u_addr.ip4)); + m_previous_name[0] = search[0]; + m_previous_name[1] = search[1]; + for (int i=0; i