Sitelet https://github.com/tzapu/WiFiManager/commit/b90af1ac4d1c86e71836041c21b7c6539d60bb72
Skip to content

Commit b90af1a

Browse files
committed
fixes #1068 esp32 S2
Esp32 has seeveral variations on when you can sethostname, might vary with versions so will try to add a best practice for all
1 parent e0c5fb7 commit b90af1a

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎WiFiManager.cpp‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,20 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
272272
DEBUG_WM(F("AutoConnect"));
273273
#endif
274274

275+
// sethostname before wifi ready
276+
// https://github.com/tzapu/WiFiManager/issues/1403
277+
#ifdef ESP32
278+
if(_hostname != ""){
279+
setupHostname(false);
280+
}
281+
#endif
282+
275283
#ifdef ESP32
276284
if(WiFi.getMode() != WIFI_STA){
277285
WiFi.mode(WIFI_STA);
278286
}
279287
#endif
280288

281-
282289
if(getWiFiIsSaved()){
283290
_startconn = millis();
284291
_begin();
@@ -287,7 +294,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
287294
// https://github.com/tzapu/WiFiManager/issues/1403
288295
#ifdef ESP32
289296
if(_hostname != ""){
290-
setupHostname(true);
297+
setupHostname(false);
291298
}
292299
#endif
293300

‎examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void setup() {
223223

224224
// set Hostname
225225

226-
// wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str());
226+
wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str());
227227
// wm.setHostname("WM_RANDO_1234");
228228

229229
// set custom channel

0 commit comments

Comments
 (0)