From f99f41306533498f394262ee52410f26f2ab3911 Mon Sep 17 00:00:00 2001 From: BBBits Date: Sun, 10 Jan 2021 22:04:16 +1300 Subject: [PATCH] mDNS Performance Fix & mDNS ESP32 Support --- .../ESP32-to-ESP8266-compat/src/ESP8266mDNS.h | 2 +- tasmota/my_user_config.h | 2 +- tasmota/support_network.ino | 7 +++++-- tasmota/support_wifi.ino | 5 ----- tasmota/tasmota.ino | 11 +++++++++++ tasmota/tasmota_globals.h | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP8266mDNS.h b/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP8266mDNS.h index f679ec5fa..208aefbfc 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP8266mDNS.h +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP8266mDNS.h @@ -1,4 +1,4 @@ // // Compat with ESP32 // -#include +#include diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 8c0c7cac3..5bb814efa 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -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) diff --git a/tasmota/support_network.ino b/tasmota/support_network.ino index 3de3ce10c..0a41b933a 100644 --- a/tasmota/support_network.ino +++ b/tasmota/support_network.ino @@ -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 diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index d70e9afd3..845e115e6 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -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; diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 42567082e..4de13717a 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -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); diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 734e902f6..5c6ac6908 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -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