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
This commit is contained in:
tablatronix
2022-08-17 19:24:45 -05:00
parent e0c5fb7daf
commit b90af1ac4d
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -272,13 +272,20 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
DEBUG_WM(F("AutoConnect"));
#endif
// sethostname before wifi ready
// https://github.com/tzapu/WiFiManager/issues/1403
#ifdef ESP32
if(_hostname != ""){
setupHostname(false);
}
#endif
#ifdef ESP32
if(WiFi.getMode() != WIFI_STA){
WiFi.mode(WIFI_STA);
}
#endif
if(getWiFiIsSaved()){
_startconn = millis();
_begin();
@@ -287,7 +294,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
// https://github.com/tzapu/WiFiManager/issues/1403
#ifdef ESP32
if(_hostname != ""){
setupHostname(true);
setupHostname(false);
}
#endif
@@ -223,7 +223,7 @@ void setup() {
// set Hostname
// wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str());
wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str());
// wm.setHostname("WM_RANDO_1234");
// set custom channel