diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index ff597b2..e0a55a4 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -111,6 +111,10 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long AC_DBG("DHCP client(%s)\n", wifi_station_dhcpc_status() == DHCP_STOPPED ? "STOPPED" : "STARTED"); #endif + // Set host name + if (_apConfig.hostName.length()) + WiFi.hostname(_apConfig.hostName.c_str()); + // If the portal is requested promptly skip the first WiFi.begin and // immediately start the portal. if (_apConfig.immediateStart) { diff --git a/src/AutoConnect.h b/src/AutoConnect.h index 2e66135..cac2a1a 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -67,6 +67,7 @@ class AutoConnectConfig { autoReset(true), autoReconnect(false), immediateStart(false), + hostName(String("")), homeUri(AUTOCONNECT_HOMEURI), staip(0U), staGateway(0U), @@ -92,6 +93,7 @@ class AutoConnectConfig { autoReset(true), autoReconnect(false), immediateStart(false), + hostName(String("")), homeUri(AUTOCONNECT_HOMEURI), staip(0U), staGateway(0U), @@ -117,6 +119,7 @@ class AutoConnectConfig { autoReset = o.autoReset; autoReconnect = o.autoReconnect; immediateStart = o.immediateStart; + hostName = o.hostName; homeUri = o.homeUri; staip = o.staip; staGateway = o.staGateway; @@ -141,6 +144,7 @@ class AutoConnectConfig { bool autoReset; /**< Reset ESP8266 module automatically when WLAN disconnected. */ bool autoReconnect; /**< Automatic reconnect with past SSID */ bool immediateStart; /**< Skips WiFi.begin(), start portal immediately */ + String hostName; /**< host name */ String homeUri; /**< A URI of user site */ IPAddress staip; /**< Station static IP address */ IPAddress staGateway; /**< Station gateway address */