Skip to content

Commit 9a82f00

Browse files
Merge branch 'master' into SDFS
2 parents edd9476 + 324eb56 commit 9a82f00

File tree

13 files changed

+584
-383
lines changed

13 files changed

+584
-383
lines changed

cores/esp8266/core_esp8266_noniso.c

+2-52
Original file line numberDiff line numberDiff line change
@@ -29,62 +29,12 @@
2929
#include <math.h>
3030
#include "stdlib_noniso.h"
3131

32-
void reverse(char* begin, char* end) {
33-
char *is = begin;
34-
char *ie = end - 1;
35-
while(is < ie) {
36-
char tmp = *ie;
37-
*ie = *is;
38-
*is = tmp;
39-
++is;
40-
--ie;
41-
}
42-
}
43-
4432
char* ltoa(long value, char* result, int base) {
45-
if(base < 2 || base > 16) {
46-
*result = 0;
47-
return result;
48-
}
49-
50-
char* out = result;
51-
long quotient = abs(value);
52-
53-
do {
54-
const long tmp = quotient / base;
55-
*out = "0123456789abcdef"[quotient - (tmp * base)];
56-
++out;
57-
quotient = tmp;
58-
} while(quotient);
59-
60-
// Apply negative sign
61-
if(value < 0)
62-
*out++ = '-';
63-
64-
reverse(result, out);
65-
*out = 0;
66-
return result;
33+
return itoa((int)value, result, base);
6734
}
6835

6936
char* ultoa(unsigned long value, char* result, int base) {
70-
if(base < 2 || base > 16) {
71-
*result = 0;
72-
return result;
73-
}
74-
75-
char* out = result;
76-
unsigned long quotient = value;
77-
78-
do {
79-
const unsigned long tmp = quotient / base;
80-
*out = "0123456789abcdef"[quotient - (tmp * base)];
81-
++out;
82-
quotient = tmp;
83-
} while(quotient);
84-
85-
reverse(result, out);
86-
*out = 0;
87-
return result;
37+
return utoa((unsigned int)value, result, base);
8838
}
8939

9040
char * dtostrf(double number, signed char width, unsigned char prec, char *s) {

doc/installing.rst

+26
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ Instructions - Windows 10
101101
--- boards.txt
102102
--- LICENSE
103103
104+
- Initialize the submodules
105+
106+
.. code:: bash
107+
108+
cd %USERPROFILE%\Documents\hardware\esp8266com\esp8266
109+
git submodules update --init
110+
111+
If error messages about missing files related to ``SoftwareSerial`` are encountered during the build process, it should be because this step was missed and is required.
112+
104113
- Download binary tools
105114
106115
.. code:: bash
@@ -166,6 +175,15 @@ Instructions - Other OS
166175
--- boards.txt
167176
--- LICENSE
168177
178+
- Initialize the submodules
179+
180+
.. code:: bash
181+
182+
cd esp8266
183+
git submodules update --init
184+
185+
If error messages about missing files related to ``SoftwareSerial`` are encountered during the build process, it should be because this step was missed and is required.
186+
169187
- Download binary tools
170188
171189
.. code:: bash
@@ -174,3 +192,11 @@ Instructions - Other OS
174192
python get.py
175193
176194
- Restart Arduino
195+
196+
- When later updating your local library, goto the esp8266 directory and do a git pull
197+
198+
.. code:: bash
199+
200+
cd hardware\esp8266com\esp8266
201+
git status
202+
git pull

libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock/mDNS_Clock.ino

+2-5
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,14 @@ void loop(void) {
316316
MDNS.update();
317317

318318
// Update time (if needed)
319-
//static unsigned long ulNextTimeUpdate = UPDATE_CYCLE;
320-
static clsMDNSTimeFlag timeFlag(UPDATE_CYCLE);
321-
if (timeFlag.flagged()/*ulNextTimeUpdate < millis()*/) {
319+
static esp8266::polledTimeout::periodic timeout(UPDATE_CYCLE);
320+
if (timeout.expired()) {
322321

323322
if (hMDNSService) {
324323
// Just trigger a new MDNS announcement, this will lead to a call to
325324
// 'MDNSDynamicServiceTxtCallback', which will update the time TXT item
326325
MDNS.announce();
327326
}
328-
//ulNextTimeUpdate = (millis() + UPDATE_CYCLE); // Set update 'timer'
329-
timeFlag.restart();
330327
}
331328
}
332329

libraries/ESP8266mDNS/src/LEATimeFlag.h

-60
This file was deleted.

libraries/ESP8266mDNS/src/LEAmDNS.cpp

+17-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ MDNSResponder::MDNSResponder(void)
5555
m_pcHostname(0),
5656
m_pServiceQueries(0),
5757
m_fnServiceTxtCallback(0),
58-
m_pServiceTxtCallbackUserdata(0) {
58+
m_pServiceTxtCallbackUserdata(0),
59+
#ifdef ENABLE_ESP_MDNS_RESPONDER_PASSIV_MODE
60+
m_bPassivModeEnabled(true) {
61+
#else
62+
m_bPassivModeEnabled(false) {
63+
#endif
5964

6065
}
6166

@@ -123,7 +128,7 @@ bool MDNSResponder::begin(const char* p_pcHostname,
123128
*/
124129
bool MDNSResponder::close(void) {
125130

126-
_announce(false);
131+
_announce(false, true);
127132
_resetProbeStatus(false); // Stop probing
128133

129134
_releaseServiceQueries();
@@ -205,6 +210,7 @@ MDNSResponder::hMDNSService MDNSResponder::addService(const char* p_pcName,
205210
}
206211
}
207212
} // else: bad arguments
213+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] addService: %s to add '%s.%s.%s'!\n"), (hResult ? "Succeeded" : "FAILED"), (p_pcName ?: "-"), p_pcService, p_pcProtocol); );
208214
DEBUG_EX_ERR(if (!hResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] addService: FAILED to add '%s.%s.%s'!\n"), (p_pcName ?: "-"), p_pcService, p_pcProtocol); } );
209215
return hResult;
210216
}
@@ -768,13 +774,17 @@ MDNSResponder::hMDNSServiceQuery MDNSResponder::installServiceQuery(const char*
768774
pServiceQuery->m_bLegacyQuery = false;
769775

770776
if (_sendMDNSServiceQuery(*pServiceQuery)) {
777+
pServiceQuery->m_u8SentCount = 1;
778+
pServiceQuery->m_ResendTimeout.reset(MDNS_DYNAMIC_QUERY_RESEND_DELAY);
779+
771780
hResult = (hMDNSServiceQuery)pServiceQuery;
772781
}
773782
else {
774783
_removeServiceQuery(pServiceQuery);
775784
}
776785
}
777-
DEBUG_EX_ERR(if (!hResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] installServiceQuery: FAILED for '%s.%s'!\n"), (p_pcService ?: "-"), (p_pcProtocol ?: "-")); } );
786+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] installServiceQuery: %s for '%s.%s'!\n\n"), (hResult ? "Succeeded" : "FAILED"), (p_pcService ?: "-"), (p_pcProtocol ?: "-")););
787+
DEBUG_EX_ERR(if (!hResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] installServiceQuery: FAILED for '%s.%s'!\n\n"), (p_pcService ?: "-"), (p_pcProtocol ?: "-")); } );
778788
return hResult;
779789
}
780790

@@ -1073,6 +1083,9 @@ bool MDNSResponder::notifyAPChange(void) {
10731083
*/
10741084
bool MDNSResponder::update(void) {
10751085

1086+
if (m_bPassivModeEnabled) {
1087+
m_bPassivModeEnabled = false;
1088+
}
10761089
return _process(true);
10771090
}
10781091

@@ -1083,7 +1096,7 @@ bool MDNSResponder::update(void) {
10831096
*/
10841097
bool MDNSResponder::announce(void) {
10851098

1086-
return (_announce());
1099+
return (_announce(true, true));
10871100
}
10881101

10891102
/*

libraries/ESP8266mDNS/src/LEAmDNS.h

+47-19
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
* Reference:
6666
* Used mDNS messages:
6767
* A (0x01): eg. esp8266.local A OP TTL 123.456.789.012
68-
* AAAA (01Cx): eg. esp8266.local AAAA OP TTL 1234:5678::90
68+
* AAAA (0x1C): eg. esp8266.local AAAA OP TTL 1234:5678::90
6969
* PTR (0x0C, srv name): eg. _http._tcp.local PTR OP TTL MyESP._http._tcp.local
7070
* PTR (0x0C, srv type): eg. _services._dns-sd._udp.local PTR OP TTL _http._tcp.local
7171
* PTR (0x0C, IP4): eg. 012.789.456.123.in-addr.arpa PTR OP TTL esp8266.local
@@ -107,7 +107,8 @@
107107
#include "lwip/udp.h"
108108
#include "debug.h"
109109
#include "include/UdpContext.h"
110-
#include "LEATimeFlag.h"
110+
#include <limits>
111+
#include <PolledTimeout.h>
111112

112113
#include "ESP8266WiFi.h"
113114

@@ -786,8 +787,9 @@ class MDNSResponder {
786787
*/
787788
struct stcProbeInformation {
788789
enuProbingStatus m_ProbingStatus;
789-
uint8_t m_u8ProbesSent;
790-
clsMDNSTimeFlag m_NextProbeTimeFlag;
790+
uint8_t m_u8SentCount; // Used for probes and announcements
791+
esp8266::polledTimeout::oneShot m_Timeout; // Used for probes and announcements
792+
//clsMDNSTimeFlag m_TimeFlag; // Used for probes and announcements
791793
bool m_bConflict;
792794
bool m_bTiebreakNeeded;
793795
MDNSProbeResultCallbackFn m_fnProbeResultCallback;
@@ -842,14 +844,32 @@ class MDNSResponder {
842844
* stcTTL
843845
*/
844846
struct stcTTL {
845-
clsMDNSTimeFlag m_TTLTimeFlag;
846-
bool m_bUpdateScheduled;
847+
/**
848+
* timeoutLevel_t
849+
*/
850+
typedef uint8_t timeoutLevel_t;
851+
/**
852+
* TIMEOUTLEVELs
853+
*/
854+
const timeoutLevel_t TIMEOUTLEVEL_UNSET = 0;
855+
const timeoutLevel_t TIMEOUTLEVEL_BASE = 80;
856+
const timeoutLevel_t TIMEOUTLEVEL_INTERVAL = 5;
857+
const timeoutLevel_t TIMEOUTLEVEL_FINAL = 100;
847858

848-
stcTTL(uint32_t p_u32TTL = 0);
859+
uint32_t m_u32TTL;
860+
esp8266::polledTimeout::oneShot m_TTLTimeout;
861+
timeoutLevel_t m_timeoutLevel;
862+
863+
stcTTL(void);
849864
bool set(uint32_t p_u32TTL);
850865

851-
bool has80Percent(void) const;
852-
bool isOutdated(void) const;
866+
bool flagged(void) const;
867+
bool restart(void);
868+
869+
bool prepareDeletion(void);
870+
bool finalTimeoutLevel(void) const;
871+
872+
unsigned long timeout(void) const;
853873
};
854874
#ifdef MDNS_IP4_SUPPORT
855875
/**
@@ -861,7 +881,7 @@ class MDNSResponder {
861881
stcTTL m_TTL;
862882

863883
stcIP4Address(IPAddress p_IPAddress,
864-
uint32_t p_u32TTL = 0);
884+
uint32_t p_u32TTL = 0);
865885
};
866886
#endif
867887
#ifdef MDNS_IP6_SUPPORT
@@ -872,6 +892,9 @@ class MDNSResponder {
872892
stcIP6Address* m_pNext;
873893
IP6Address m_IPAddress;
874894
stcTTL m_TTL;
895+
896+
stcIP6Address(IPAddress p_IPAddress,
897+
uint32_t p_u32TTL = 0);
875898
};
876899
#endif
877900

@@ -932,13 +955,15 @@ class MDNSResponder {
932955
#endif
933956
};
934957

935-
stcMDNSServiceQuery* m_pNext;
936-
stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
937-
MDNSServiceQueryCallbackFn m_fnCallback;
938-
void* m_pUserdata;
939-
bool m_bLegacyQuery;
940-
bool m_bAwaitingAnswers;
941-
stcAnswer* m_pAnswers;
958+
stcMDNSServiceQuery* m_pNext;
959+
stcMDNS_RRDomain m_ServiceTypeDomain; // eg. _http._tcp.local
960+
MDNSServiceQueryCallbackFn m_fnCallback;
961+
void* m_pUserdata;
962+
bool m_bLegacyQuery;
963+
uint8_t m_u8SentCount;
964+
esp8266::polledTimeout::oneShot m_ResendTimeout;
965+
bool m_bAwaitingAnswers;
966+
stcAnswer* m_pAnswers;
942967

943968
stcMDNSServiceQuery(void);
944969
~stcMDNSServiceQuery(void);
@@ -1012,6 +1037,7 @@ class MDNSResponder {
10121037
WiFiEventHandler m_GotIPHandler;
10131038
MDNSDynamicServiceTxtCallbackFn m_fnServiceTxtCallback;
10141039
void* m_pServiceTxtCallbackUserdata;
1040+
bool m_bPassivModeEnabled;
10151041
stcProbeInformation m_HostProbeInformation;
10161042

10171043
/** CONTROL **/
@@ -1047,7 +1073,8 @@ class MDNSResponder {
10471073
bool _cancelProbingForService(stcMDNSService& p_rService);
10481074

10491075
/* ANNOUNCE */
1050-
bool _announce(bool p_bAnnounce = true);
1076+
bool _announce(bool p_bAnnounce,
1077+
bool p_bIncludeServices);
10511078
bool _announceService(stcMDNSService& p_rService,
10521079
bool p_bAnnounce = true);
10531080

@@ -1064,7 +1091,8 @@ class MDNSResponder {
10641091
IPAddress p_IPAddress);
10651092
bool _sendMDNSServiceQuery(const stcMDNSServiceQuery& p_ServiceQuery);
10661093
bool _sendMDNSQuery(const stcMDNS_RRDomain& p_QueryDomain,
1067-
uint16_t p_u16QueryType);
1094+
uint16_t p_u16QueryType,
1095+
stcMDNSServiceQuery::stcAnswer* p_pKnownAnswers = 0);
10681096

10691097
IPAddress _getResponseMulticastInterface(int p_iWiFiOpModes) const;
10701098

0 commit comments

Comments
 (0)