mDNS Performance Fix & mDNS ESP32 Support

This commit is contained in:
BBBits 2021-01-10 22:04:16 +13:00
parent e35cac1ba8
commit f99f413065
6 changed files with 19 additions and 10 deletions

View File

@ -1,4 +1,4 @@
//
// Compat with ESP32
//
#include <mDNS.h>
#include <ESPmDNS.h>

View File

@ -223,7 +223,7 @@
#define KNX_ENHANCED false // [Knx_Enhanced] Enable KNX Enhanced Mode
// -- mDNS ----------------------------------------
#define MDNS_ENABLED false // [SetOption55] Use mDNS (false = Disable, true = Enable)
#define MDNS_ENABLED true // [SetOption55] Use mDNS (false = Disable, true = Enable)
// -- Time - Up to three NTP servers in your region
#define NTP_SERVER1 "pool.ntp.org" // [NtpServer1] Select first NTP server by name or IP address (129.250.35.250)

View File

@ -78,12 +78,15 @@ void MdnsAddServiceHttp(void) {
}
}
#ifdef ESP8266 //Not needed with esp32 mdns
void MdnsUpdate(void) {
if (2 == Mdns.begun) {
MDNS.update();
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MDNS "MDNS.update"));
MDNS.update(); // this is basically passpacket like a webserver
// being called in main loop so no logging
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MDNS "MDNS.update"));
}
}
#endif // ESP8266
#endif // WEBSERVER_ADVERTISE
#endif // USE_DISCOVERY

View File

@ -401,11 +401,6 @@ void WifiCheckIp(void)
memcpy((void*) &Settings.wifi_bssid, (void*) bssid, sizeof(Settings.wifi_bssid));
}
Wifi.status = WL_CONNECTED;
#ifdef USE_DISCOVERY
#ifdef WEBSERVER_ADVERTISE
MdnsUpdate();
#endif // USE_DISCOVERY
#endif // WEBSERVER_ADVERTISE
} else {
WifiSetState(0);
uint8_t wifi_config_tool = Settings.sta_config;

View File

@ -383,6 +383,17 @@ void SleepDelay(uint32_t mseconds) {
void loop(void) {
uint32_t my_sleep = millis();
// check LEAmDNS.h
// MDNS.update() needs to be called in main loop
#ifdef ESP8266 //Not needed with esp32 mdns
#ifdef USE_DISCOVERY
#ifdef WEBSERVER_ADVERTISE
// previously this was only called in WifiCheckIp() and that causes delays in responses to mdns
MdnsUpdate();
#endif // WEBSERVER_ADVERTISE
#endif // USE_DISCOVERY
#endif // ESP8266
XdrvCall(FUNC_LOOP);
XsnsCall(FUNC_LOOP);

View File

@ -123,7 +123,7 @@ String EthernetMacAddress(void);
#undef USE_RF_FLASH
// Not ported (yet)
#undef USE_DISCOVERY
#undef USE_MY92X1
#undef USE_TUYA_MCU
#undef USE_PS_16_DZ