mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-14 13:41:23 +03:00
LEAmDNS_Fixes_1_3 (#5689)
* LEAmDNS_Fixes_1_3 * Updated LEAmDNSResponder::begin()
This commit is contained in:
@ -22,8 +22,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <Schedule.h>
|
||||||
|
|
||||||
#include "LEAmDNS_Priv.h"
|
#include "LEAmDNS_Priv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace esp8266 {
|
namespace esp8266 {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -87,28 +90,30 @@ MDNSResponder::~MDNSResponder(void) {
|
|||||||
*/
|
*/
|
||||||
bool MDNSResponder::begin(const char* p_pcHostname) {
|
bool MDNSResponder::begin(const char* p_pcHostname) {
|
||||||
|
|
||||||
bool bResult = (0 != m_pcHostname);
|
bool bResult = false;
|
||||||
|
|
||||||
if (0 == m_pcHostname) {
|
if (0 == m_pUDPContext) {
|
||||||
if (_setHostname(p_pcHostname)) {
|
if (_setHostname(p_pcHostname)) {
|
||||||
|
|
||||||
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& pEvent) {
|
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& pEvent) {
|
||||||
(void) pEvent;
|
(void) pEvent;
|
||||||
_restart();
|
// Ensure that _restart() runs in USER context
|
||||||
|
schedule_function(std::bind(&MDNSResponder::_restart, this));
|
||||||
});
|
});
|
||||||
|
|
||||||
m_DisconnectedHandler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected& pEvent) {
|
m_DisconnectedHandler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected& pEvent) {
|
||||||
(void) pEvent;
|
(void) pEvent;
|
||||||
_restart();
|
// Ensure that _restart() runs in USER context
|
||||||
|
schedule_function(std::bind(&MDNSResponder::_restart, this));
|
||||||
});
|
});
|
||||||
|
|
||||||
bResult = _restart();
|
bResult = _restart();
|
||||||
}
|
}
|
||||||
|
DEBUG_EX_ERR(if (!bResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ?: "-")); } );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: Ignoring multiple calls (Ignored host domain: '%s')!\n"), (p_pcHostname ?: "-")););
|
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: Ignoring multiple calls to begin (Ignored host domain: '%s')!\n"), (p_pcHostname ?: "-")););
|
||||||
}
|
}
|
||||||
DEBUG_EX_ERR(if (!bResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ?: "-")); } );
|
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user