mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-29 12:16:48 +03:00
* formalization of LEA's mdns rewrite (code), minor changes to polledTimeout * fix typo * Fix mdns examples
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
/*
|
|
* LEATimeFlag.h
|
|
*/
|
|
#ifndef __MDNSTIMEFLAG_H
|
|
#define __MDNSTIMEFLAG_H
|
|
|
|
|
|
#include <limits>
|
|
#include <PolledTimeout.h>
|
|
|
|
|
|
/* Wrapper class around PolledTimeout
|
|
* MDNS requires behavior that is slightly different from the default in PolledTimeout
|
|
*/
|
|
class clsMDNSTimeFlag {
|
|
protected:
|
|
using oneShot = esp8266::polledTimeout::oneShot;
|
|
oneShot m_clsPolledTimeout;
|
|
|
|
public:
|
|
using timeType = oneShot::timeType;
|
|
|
|
clsMDNSTimeFlag(timeType p_Timeout)
|
|
: m_clsPolledTimeout(p_Timeout) {
|
|
}
|
|
clsMDNSTimeFlag()
|
|
: m_clsPolledTimeout(std::numeric_limits<timeType>::max()) {
|
|
}
|
|
|
|
operator bool() const {
|
|
return flagged();
|
|
}
|
|
|
|
bool flagged() const {
|
|
return m_clsPolledTimeout.checkExpired(millis());
|
|
}
|
|
|
|
void restart() {
|
|
m_clsPolledTimeout.reset();
|
|
}
|
|
|
|
void restart(const timeType p_Timeout) {
|
|
m_clsPolledTimeout.reset(p_Timeout);
|
|
}
|
|
|
|
void reset() {
|
|
m_clsPolledTimeout.reset(std::numeric_limits<timeType>::max());
|
|
}
|
|
|
|
timeType getTimeout() const {
|
|
return m_clsPolledTimeout.getTimeout();
|
|
}
|
|
|
|
bool hypotheticalTimeout(const timeType p_Timeout) const {
|
|
return m_clsPolledTimeout.checkExpired(p_Timeout);
|
|
}
|
|
};
|
|
|
|
|
|
#endif // __MDNSTIMEFLAG_H
|