File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -151,10 +151,15 @@ void EmbUI::wifi_init(){
151
151
} else {
152
152
LOG (println, F (" STA mode" ));
153
153
WiFi.mode (WIFI_STA); // we start in STA mode, esp32 can't set client's hotname in ap/sta
154
-
154
+ LOG (println, F ( " UI WiFi: STA reconecting... " ));
155
155
#ifdef ESP8266
156
156
WiFi.hostname (hn);
157
- WiFi.begin (); // use internaly stored last known credentials for connection
157
+ if (WiFi.begin ()!=WL_CONNECTED){ // use internaly stored last known credentials for connection
158
+ LOG (println, F (" UI WiFi: Can't connect in STA, starting AP..." ));
159
+ WiFi.disconnect (); // something wrong... starting in AP mode
160
+ WiFi.mode (WIFI_AP);
161
+ WiFi.begin ();
162
+ }
158
163
#elif defined ESP32
159
164
/* this is a weird hack to mitigate DHCP hostname issue
160
165
* order of initialization does matter, pls keep it like this till fixed in upstream
@@ -165,7 +170,6 @@ void EmbUI::wifi_init(){
165
170
if (!WiFi.setHostname (hn.c_str ()))
166
171
LOG (println, F (" UI WiFi: Failed to set hostname :(" ));
167
172
#endif
168
- LOG (println, F (" UI WiFi: STA reconecting..." ));
169
173
}
170
174
}
171
175
You can’t perform that action at this time.
0 commit comments