File tree 1 file changed +11
-6
lines changed
libraries/ESP8266mDNS/src
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 22
22
*
23
23
*/
24
24
25
+ #include < Schedule.h>
26
+
25
27
#include " LEAmDNS_Priv.h"
26
28
29
+
27
30
namespace esp8266 {
28
31
29
32
/*
@@ -87,28 +90,30 @@ MDNSResponder::~MDNSResponder(void) {
87
90
*/
88
91
bool MDNSResponder::begin (const char * p_pcHostname) {
89
92
90
- bool bResult = ( 0 != m_pcHostname) ;
93
+ bool bResult = false ;
91
94
92
- if (0 == m_pcHostname ) {
95
+ if (0 == m_pUDPContext ) {
93
96
if (_setHostname (p_pcHostname)) {
94
97
95
98
m_GotIPHandler = WiFi.onStationModeGotIP ([this ](const WiFiEventStationModeGotIP& pEvent) {
96
99
(void ) pEvent;
97
- _restart ();
100
+ // Ensure that _restart() runs in USER context
101
+ schedule_function (std::bind (&MDNSResponder::_restart, this ));
98
102
});
99
103
100
104
m_DisconnectedHandler = WiFi.onStationModeDisconnected ([this ](const WiFiEventStationModeDisconnected& pEvent) {
101
105
(void ) pEvent;
102
- _restart ();
106
+ // Ensure that _restart() runs in USER context
107
+ schedule_function (std::bind (&MDNSResponder::_restart, this ));
103
108
});
104
109
105
110
bResult = _restart ();
106
111
}
112
+ DEBUG_EX_ERR (if (!bResult) { DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] begin: FAILED for '%s'!\n " ), (p_pcHostname ?: " -" )); } );
107
113
}
108
114
else {
109
- DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] begin: Ignoring multiple calls (Ignored host domain: '%s')!\n " ), (p_pcHostname ?: " -" )););
115
+ DEBUG_EX_INFO (DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] begin: Ignoring multiple calls to begin (Ignored host domain: '%s')!\n " ), (p_pcHostname ?: " -" )););
110
116
}
111
- DEBUG_EX_ERR (if (!bResult) { DEBUG_OUTPUT.printf_P (PSTR (" [MDNSResponder] begin: FAILED for '%s'!\n " ), (p_pcHostname ?: " -" )); } );
112
117
return bResult;
113
118
}
114
119
You can’t perform that action at this time.
0 commit comments