Skip to content

LEAmDNS_Fixes_1_3 #5689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 30, 2019
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