1
0
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:
LaborEtArs
2019-01-30 03:24:59 +01:00
committed by Develo
parent a0108fe69b
commit 3f267bd238

View File

@ -22,8 +22,11 @@
*
*/
#include <Schedule.h>
#include "LEAmDNS_Priv.h"
namespace esp8266 {
/*
@ -87,28 +90,30 @@ MDNSResponder::~MDNSResponder(void) {
*/
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)) {
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& 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) {
(void) pEvent;
_restart();
// Ensure that _restart() runs in USER context
schedule_function(std::bind(&MDNSResponder::_restart, this));
});
bResult = _restart();
}
DEBUG_EX_ERR(if (!bResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ?: "-")); } );
}
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;
}