From db4964636c36ea434a9e1a58b8852dc5d444f8ed Mon Sep 17 00:00:00 2001 From: Holger Weber Date: Thu, 26 Feb 2026 20:29:39 +0100 Subject: [PATCH] Added hostname configuration. --- include/EggDuino.h | 1 + src/Config_Web.cpp | 14 +++++++++++++- src/main.cpp | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/EggDuino.h b/include/EggDuino.h index b3f379f..8eb09a8 100644 --- a/include/EggDuino.h +++ b/include/EggDuino.h @@ -101,6 +101,7 @@ extern int g_iPenEnablePin; extern int g_iServoPin; extern int g_iRotMicrostep; extern int g_iPenMicrostep; +extern String g_sHostname; extern String g_sWifiSsid; extern String g_sWifiPassword; diff --git a/src/Config_Web.cpp b/src/Config_Web.cpp index 3b0bceb..6362a53 100644 --- a/src/Config_Web.cpp +++ b/src/Config_Web.cpp @@ -289,6 +289,7 @@ ConfigParameter configParameters[] = { {"int", "rotMicrostep", &g_iRotMicrostep, "Rotational Stepper Microsteps", kDefaultRotMicrostep, "", false}, {"int", "penMicrostep", &g_iPenMicrostep, "Pen Stepper Microsteps", kDefaultPenMicrostep, "", false}, {"int", "servoPin", &g_iServoPin, "Servo Pin", kDefaultServoPin, "", false}, + {"text", "Name", &g_sHostname, "Name", 0, "EggDuino", false}, {"text", "wifiSsid", &g_sWifiSsid, "WLAN SSID", 0, "", false}, {"password", "wifiPassword", &g_sWifiPassword, "WLAN Passwort", 0, "", true}, }; @@ -500,10 +501,18 @@ void startWebInterface() bool staConnected = false; apModeActive = false; dnsServer.stop(); + String hostName = g_sHostname; + hostName.trim(); + if (hostName.isEmpty()) + { + hostName = "EggDuino"; + } + g_sHostname = hostName; if (!g_sWifiSsid.isEmpty()) { WiFi.mode(WIFI_STA); + WiFi.setHostname(hostName.c_str()); WiFi.begin(g_sWifiSsid.c_str(), g_sWifiPassword.c_str()); const unsigned long connectStart = millis(); @@ -533,11 +542,14 @@ void startWebInterface() if (!staConnected) { WiFi.mode(WIFI_AP); +#ifdef ESP32 + WiFi.softAPsetHostname(hostName.c_str()); +#endif if (WiFi.softAP("EggDuino")) { apModeActive = true; dnsServer.start(kDnsPort, "*", WiFi.softAPIP()); - Serial.println(String("AP aktiv: EggDuino / http://") + WiFi.softAPIP().toString()); + Serial.println(String("AP aktiv: EggDuino / http://") + WiFi.softAPIP().toString() + " (Name: " + hostName + ")"); } else { diff --git a/src/main.cpp b/src/main.cpp index c7334e3..daaf00c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,6 +81,7 @@ int g_iRotMicrostep = kDefaultRotMicrostep; int g_iPenMicrostep = kDefaultPenMicrostep; float fROT_STEP_CORRECTION = 16.0 / kDefaultRotMicrostep; // devide EBB-Coordinates by this factor to get EGGduino-Steps float fPEN_STEP_CORRECTION = 16.0 / kDefaultPenMicrostep; // devide EBB-Coordinates by this factor to get EGGduino-Steps +String g_sHostname = "EggDuino"; String g_sWifiSsid = ""; String g_sWifiPassword = "";