RP2040: Add mDNS support

This commit is contained in:
GUVWAF 2024-11-11 18:49:01 +01:00
parent cd837a7716
commit 94dd567186

View File

@ -20,6 +20,8 @@
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include <esp_wifi.h> #include <esp_wifi.h>
static void WiFiEvent(WiFiEvent_t event); static void WiFiEvent(WiFiEvent_t event);
#else // ARCH_RP2040
#include <SimpleMDNS.h>
#endif #endif
#ifndef DISABLE_NTP #ifndef DISABLE_NTP
@ -59,17 +61,19 @@ static void onNetworkConnected()
// Start web server // Start web server
LOG_INFO("Start WiFi network services"); LOG_INFO("Start WiFi network services");
#ifdef ARCH_ESP32
// start mdns // start mdns
#ifdef ARCH_ESP32
if (!MDNS.begin("Meshtastic")) { if (!MDNS.begin("Meshtastic")) {
LOG_ERROR("Error setting up MDNS responder!"); LOG_ERROR("Error setting up MDNS responder!");
} else { } else {
LOG_INFO("mDNS responder started");
LOG_INFO("mDNS Host: Meshtastic.local"); LOG_INFO("mDNS Host: Meshtastic.local");
MDNS.addService("http", "tcp", 80); MDNS.addService("http", "tcp", 80);
MDNS.addService("https", "tcp", 443); MDNS.addService("https", "tcp", 443);
} }
#else // ESP32 handles this in WiFiEvent #else
MDNS.begin("Meshtastic");
// ARCH_RP2040 does not support HTTPS
MDNS.addService("meshtastic", "tcp", 4403);
LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str()); LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str());
#endif #endif