diff --git a/src/mesh/api/ServerAPI.h b/src/mesh/api/ServerAPI.h index 5b84fddd7e..fe6a733a76 100644 --- a/src/mesh/api/ServerAPI.h +++ b/src/mesh/api/ServerAPI.h @@ -2,6 +2,8 @@ #include "StreamAPI.h" +#define SERVER_API_DEFAULT_PORT 4403 + /** * Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs * (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs). diff --git a/src/mesh/api/WiFiServerAPI.h b/src/mesh/api/WiFiServerAPI.h index 7a3d2967f5..6e60bb6786 100644 --- a/src/mesh/api/WiFiServerAPI.h +++ b/src/mesh/api/WiFiServerAPI.h @@ -22,5 +22,5 @@ class WiFiServerPort : public APIServerPort explicit WiFiServerPort(int port); }; -void initApiServer(int port = 4403); +void initApiServer(int port = SERVER_API_DEFAULT_PORT); void deInitApiServer(); \ No newline at end of file diff --git a/src/mesh/api/ethServerAPI.h b/src/mesh/api/ethServerAPI.h index 6f214c75a9..9d25a2fc17 100644 --- a/src/mesh/api/ethServerAPI.h +++ b/src/mesh/api/ethServerAPI.h @@ -22,4 +22,4 @@ class ethServerPort : public APIServerPort explicit ethServerPort(int port); }; -void initApiServer(int port = 4403); +void initApiServer(int port = SERVER_API_DEFAULT_PORT); diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 911a47093e..f9e5d1cc9a 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -66,13 +66,13 @@ static void onNetworkConnected() LOG_ERROR("Error setting up MDNS responder!"); } else { LOG_INFO("mDNS Host: Meshtastic.local"); + MDNS.addService("meshtastic", "tcp", SERVER_API_DEFAULT_PORT); #ifdef ARCH_ESP32 MDNS.addService("http", "tcp", 80); MDNS.addService("https", "tcp", 443); + // ESP32 prints obtained IP address in WiFiEvent #elif defined(ARCH_RP2040) - // ARCH_RP2040 does not support HTTPS, create a "meshtastic" service - MDNS.addService("meshtastic", "tcp", 4403); - // ESP32 handles this in WiFiEvent + // ARCH_RP2040 does not support HTTPS LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str()); #endif } diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index a4485e91ff..2aa6c90542 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -9,6 +9,7 @@ #include #include "PortduinoGlue.h" +#include "api/ServerAPI.h" #include "linux/gpio/LinuxGPIOPin.h" #include "yaml-cpp/yaml.h" #include @@ -34,7 +35,7 @@ void cpuDeepSleep(uint32_t msecs) void updateBatteryLevel(uint8_t level) NOT_IMPLEMENTED("updateBatteryLevel"); -int TCPPort = 4403; +int TCPPort = SERVER_API_DEFAULT_PORT; static error_t parse_opt(int key, char *arg, struct argp_state *state) {