fix: bug in MDNS handler

This commit is contained in:
ZanzyTHEbar 2023-03-03 13:04:53 +00:00
parent 1313a96da8
commit 4af73d0377
2 changed files with 7 additions and 6 deletions

View File

@ -15,10 +15,10 @@ bool MDNSHandler::startMDNS()
} }
stateManager->setState(MDNSState_e::MDNSState_Starting); stateManager->setState(MDNSState_e::MDNSState_Starting);
MDNS.addService(mdnsConfig->hostname.c_str(), "tcp", 80); MDNS.addService(("_" + mdnsConfig->hostname).c_str(), "_tcp", 80);
char port[20]; char port[20];
//! Add service needs leading _ on ESP32 implementation for some reason (according to the docs) //! Add service needs leading _ on ESP32 implementation for some reason (according to the docs)
MDNS.addServiceTxt(("_" + mdnsConfig->hostname).c_str(), "_tcp", "stream_port", (const char *)Helpers::itoa(80, port, 10)); //! convert int to const char* using a very efficient implemenation of itoa MDNS.addServiceTxt(("_" + mdnsConfig->hostname).c_str(), "_tcp", "stream_port", "80"); //! convert int to const char* using a very efficient implemenation of itoa
log_i("MDNS initialized!"); log_i("MDNS initialized!");
stateManager->setState(MDNSState_e::MDNSState_Started); stateManager->setState(MDNSState_e::MDNSState_Started);
return true; return true;

View File

@ -50,8 +50,9 @@ void setup()
deviceConfig.load(); deviceConfig.load();
wifiHandler._enable_adhoc = ENABLE_ADHOC; wifiHandler._enable_adhoc = ENABLE_ADHOC;
wifiHandler.setupWifi(); wifiHandler.setupWifi();
mdnsHandler.startMDNS();
mdnsStateManager.setState(MDNSState_e::MDNSState_Starting); /* mdnsStateManager.setState(MDNSState_e::MDNSState_Starting);
switch (mdnsStateManager.getCurrentState()) switch (mdnsStateManager.getCurrentState())
{ {
case MDNSState_e::MDNSState_Starting: case MDNSState_e::MDNSState_Starting:
@ -63,7 +64,7 @@ void setup()
break; break;
default: default:
break; break;
} } */
switch (wifiStateManager.getCurrentState()) switch (wifiStateManager.getCurrentState())
{ {