diff --git a/libraries/ESP8266mDNS/src/LEAmDNS.h b/libraries/ESP8266mDNS/src/LEAmDNS.h index 1c099c68ab..670de02ed0 100644 --- a/libraries/ESP8266mDNS/src/LEAmDNS.h +++ b/libraries/ESP8266mDNS/src/LEAmDNS.h @@ -1030,6 +1030,8 @@ class MDNSResponder esp8266::polledTimeout::oneShotMs m_TTLTimeout; timeoutLevel_t m_timeoutLevel; + using timeoutBase = decltype(m_TTLTimeout); + stcTTL(void); bool set(uint32_t p_u32TTL); @@ -1039,7 +1041,7 @@ class MDNSResponder bool prepareDeletion(void); bool finalTimeoutLevel(void) const; - unsigned long timeout(void) const; + timeoutBase::timeType timeout(void) const; }; #ifdef MDNS_IP4_SUPPORT /** diff --git a/libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp b/libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp index fafe29b98f..786287457d 100644 --- a/libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp +++ b/libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp @@ -1663,22 +1663,19 @@ bool MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::finalTimeoutLevel(vo /* MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout */ -unsigned long MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout(void) const +MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeoutBase::timeType MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout(void) const { - - unsigned long timeout = esp8266::polledTimeout::oneShotMs::neverExpires; - if (TIMEOUTLEVEL_BASE == m_timeoutLevel) // 80% { - timeout = (m_u32TTL * 800L); // to milliseconds + return (m_u32TTL * 800L); // to milliseconds } else if ((TIMEOUTLEVEL_BASE < m_timeoutLevel) && // >80% AND (TIMEOUTLEVEL_FINAL >= m_timeoutLevel)) // <= 100% { - timeout = (m_u32TTL * 50L); + return (m_u32TTL * 50L); } // else: invalid - return timeout; + return MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeoutBase::neverExpires; }