Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions libraries/ESP8266mDNS/src/LEAmDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
*
*/

#include <Schedule.h>

#include "LEAmDNS_Priv.h"


namespace esp8266 {

/*
Expand Down Expand Up @@ -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;
}

Expand Down