1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-12-13 20:03:19 +03:00

LEAmDNS Fixes 1.1 (#5619)

* Fixes 1.1

- Better separation of ESP wifi thread code from user thread code
- Added a flag for 'update()'-less use (disabled by default)
- The too fast updates for service queries are fixed
- Switched fully to PolledTimeout; LEATimeFlag not needed anymore (BTW: a const 'expired()' method would be helpful)
- The device should stay visible now even after the first TTL timeout
- Improved service querying (queries five times now)

* Update mDNS_Clock.ino

Removed references to LEATimeFlag.h

* Update mDNS_Clock.ino

Styling
This commit is contained in:
LaborEtArs
2019-01-18 19:59:26 +01:00
committed by Develo
parent 6883beedec
commit 570b9a6b6a
9 changed files with 533 additions and 331 deletions

View File

@@ -65,7 +65,7 @@
* Reference:
* Used mDNS messages:
* A (0x01): eg. esp8266.local A OP TTL 123.456.789.012
* AAAA (01Cx): eg. esp8266.local AAAA OP TTL 1234:5678::90
* AAAA (0x1C): eg. esp8266.local AAAA OP TTL 1234:5678::90
* PTR (0x0C, srv name): eg. _http._tcp.local PTR OP TTL MyESP._http._tcp.local
* PTR (0x0C, srv type): eg. _services._dns-sd._udp.local PTR OP TTL _http._tcp.local
* PTR (0x0C, IP4): eg. 012.789.456.123.in-addr.arpa PTR OP TTL esp8266.local
@@ -107,7 +107,8 @@
#include "lwip/udp.h"
#include "debug.h"
#include "include/UdpContext.h"
#include "LEATimeFlag.h"
#include <limits>
#include <PolledTimeout.h>
#include "ESP8266WiFi.h"
@@ -786,8 +787,9 @@ protected:
*/
struct stcProbeInformation {
enuProbingStatus m_ProbingStatus;
uint8_t m_u8ProbesSent;
clsMDNSTimeFlag m_NextProbeTimeFlag;
uint8_t m_u8SentCount; // Used for probes and announcements
esp8266::polledTimeout::oneShot m_Timeout; // Used for probes and announcements
//clsMDNSTimeFlag m_TimeFlag; // Used for probes and announcements
bool m_bConflict;
bool m_bTiebreakNeeded;
MDNSProbeResultCallbackFn m_fnProbeResultCallback;
@@ -842,14 +844,32 @@ protected:
* stcTTL
*/
struct stcTTL {
clsMDNSTimeFlag m_TTLTimeFlag;
bool m_bUpdateScheduled;
/**
* timeoutLevel_t
*/
typedef uint8_t timeoutLevel_t;
/**
* TIMEOUTLEVELs
*/
const timeoutLevel_t TIMEOUTLEVEL_UNSET = 0;
const timeoutLevel_t TIMEOUTLEVEL_BASE = 80;
const timeoutLevel_t TIMEOUTLEVEL_INTERVAL = 5;
const timeoutLevel_t TIMEOUTLEVEL_FINAL = 100;
stcTTL(uint32_t p_u32TTL = 0);
uint32_t m_u32TTL;
esp8266::polledTimeout::oneShot m_TTLTimeout;
timeoutLevel_t m_timeoutLevel;
stcTTL(void);
bool set(uint32_t p_u32TTL);
bool has80Percent(void) const;
bool isOutdated(void) const;
bool flagged(void) const;
bool restart(void);
bool prepareDeletion(void);
bool finalTimeoutLevel(void) const;
unsigned long timeout(void) const;
};
#ifdef MDNS_IP4_SUPPORT
/**
@@ -861,7 +881,7 @@ protected:
stcTTL m_TTL;
stcIP4Address(IPAddress p_IPAddress,
uint32_t p_u32TTL = 0);
uint32_t p_u32TTL = 0);
};
#endif
#ifdef MDNS_IP6_SUPPORT
@@ -872,6 +892,9 @@ protected:
stcIP6Address* m_pNext;
IP6Address m_IPAddress;
stcTTL m_TTL;
stcIP6Address(IPAddress p_IPAddress,
uint32_t p_u32TTL = 0);
};
#endif
@@ -932,13 +955,15 @@ protected:
#endif
};
stcMDNSServiceQuery* m_pNext;
stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
MDNSServiceQueryCallbackFn m_fnCallback;
void* m_pUserdata;
bool m_bLegacyQuery;
bool m_bAwaitingAnswers;
stcAnswer* m_pAnswers;
stcMDNSServiceQuery* m_pNext;
stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
MDNSServiceQueryCallbackFn m_fnCallback;
void* m_pUserdata;
bool m_bLegacyQuery;
uint8_t m_u8SentCount;
esp8266::polledTimeout::oneShot m_ResendTimeout;
bool m_bAwaitingAnswers;
stcAnswer* m_pAnswers;
stcMDNSServiceQuery(void);
~stcMDNSServiceQuery(void);
@@ -1012,6 +1037,7 @@ protected:
WiFiEventHandler m_GotIPHandler;
MDNSDynamicServiceTxtCallbackFn m_fnServiceTxtCallback;
void* m_pServiceTxtCallbackUserdata;
bool m_bPassivModeEnabled;
stcProbeInformation m_HostProbeInformation;
/** CONTROL **/
@@ -1047,7 +1073,8 @@ protected:
bool _cancelProbingForService(stcMDNSService& p_rService);
/* ANNOUNCE */
bool _announce(bool p_bAnnounce = true);
bool _announce(bool p_bAnnounce,
bool p_bIncludeServices);
bool _announceService(stcMDNSService& p_rService,
bool p_bAnnounce = true);
@@ -1064,7 +1091,8 @@ protected:
IPAddress p_IPAddress);
bool _sendMDNSServiceQuery(const stcMDNSServiceQuery& p_ServiceQuery);
bool _sendMDNSQuery(const stcMDNS_RRDomain& p_QueryDomain,
uint16_t p_u16QueryType);
uint16_t p_u16QueryType,
stcMDNSServiceQuery::stcAnswer* p_pKnownAnswers = 0);
IPAddress _getResponseMulticastInterface(int p_iWiFiOpModes) const;