From b2a0a24c2d337590717e668b432863df34aff68f Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 10 Dec 2023 16:54:15 +0100 Subject: [PATCH 1/2] Enhancement: mDNS Support in WiFi AP-Mode --- src/wifi/ahoywifi.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 8632de49..65410104 100644 --- a/src/wifi/ahoywifi.cpp +++ b/src/wifi/ahoywifi.cpp @@ -9,6 +9,7 @@ #define F(sl) (sl) #endif #include "ahoywifi.h" +#include // NTP CONFIG #define NTP_PACKET_SIZE 48 @@ -83,6 +84,7 @@ void ahoywifi::tickWifiLoop() { if (mGotDisconnect) { mStaConn = RESET; } + MDNS.update(); return; case IN_AP_MODE: if (WiFi.softAPgetStationNum() == 0) { @@ -180,6 +182,15 @@ void ahoywifi::tickWifiLoop() { mAppWifiCb(true); mGotDisconnect = false; mStaConn = IN_STA_MODE; + + if (!MDNS.begin(mConfig->sys.deviceName)) { + DPRINTLN(DBG_ERROR, F("Error setting up MDNS responder!")); + } else { + DBGPRINT(F("[WiFi] mDNS established: ")); + DBGPRINT(mConfig->sys.deviceName); + DBGPRINTLN(F(".local")); + } + break; case RESET: mGotDisconnect = false; @@ -245,7 +256,6 @@ void ahoywifi::setupStation(void) { WiFi.hostname(mConfig->sys.deviceName); WiFi.mode(WIFI_AP_STA); - DBGPRINT(F("connect to network '")); DBGPRINT(mConfig->sys.stationSsid); DBGPRINTLN(F("' ...")); From 2f51bd10706a20d8678172577c299aef70737e82 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 10 Dec 2023 22:49:55 +0100 Subject: [PATCH 2/2] added ESP32 mDNS support --- src/wifi/ahoywifi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wifi/ahoywifi.cpp b/src/wifi/ahoywifi.cpp index 65410104..d58e3847 100644 --- a/src/wifi/ahoywifi.cpp +++ b/src/wifi/ahoywifi.cpp @@ -9,7 +9,12 @@ #define F(sl) (sl) #endif #include "ahoywifi.h" + +#if defined(ESP32) +#include +#else #include +#endif // NTP CONFIG #define NTP_PACKET_SIZE 48