Added hostname configuration.

This commit is contained in:
Holger Weber
2026-02-22 23:10:28 +01:00
parent f862672a81
commit a85bf19885
3 changed files with 15 additions and 1 deletions

View File

@@ -97,6 +97,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;

View File

@@ -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();
@@ -525,11 +534,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
{

View File

@@ -71,6 +71,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 = "";