Skip to content

Commit 73ff185

Browse files
committed
Added restart of device if looking as though wifi is not connecting
1 parent aef6a93 commit 73ff185

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

ESPGeiger/ESPGeiger.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,19 @@ void sTickerCB()
145145
#ifdef GEIGER_SDCARD
146146
sdcard.s_tick(stick_now);
147147
#endif
148+
status.wifi_status = WiFi.status();
149+
if (status.warmup) {
150+
return;
151+
}
148152
if (status.wifi_disabled) {
149153
return;
150154
}
155+
if (status.wifi_status != WL_CONNECTED) {
156+
return;
157+
}
151158
#ifdef MQTTOUT
152159
mqtt.loop(stick_now);
153160
#endif
154-
status.wifi_status = WiFi.status();
155-
if (status.warmup) {
156-
return;
157-
}
158161
#ifdef GMCOUT
159162
gmc.s_tick(stick_now);
160163
#endif
@@ -205,6 +208,7 @@ void setup()
205208
delay(250);
206209
pushbutton.read();
207210
}
211+
delay(750);
208212
status.enable_oled_timeout = false;
209213
status.wifi_disabled = true;
210214
}
@@ -216,7 +220,19 @@ void setup()
216220
}
217221
#endif
218222
if (!status.wifi_disabled) {
219-
cManager.autoConnect();
223+
bool res = cManager.autoConnect();
224+
if (!res) {
225+
#if (defined(ESPGEIGER_HW) || defined(ESPGEIGER_LT))
226+
if (!cManager.getWiFiIsSaved()) {
227+
status.wifi_disabled = true;
228+
}
229+
#else
230+
Log::console(PSTR("WiFi not connecting ... Restarting ... "));
231+
delay(1000);
232+
ESP.restart();
233+
#endif
234+
}
235+
220236
delay(100);
221237
status.wifi_status = WiFi.status();
222238
cManager.startWebPortal();
@@ -247,6 +263,9 @@ void setup()
247263
status.led.Off().Update();
248264
serialcmd.setup();
249265
hmsTicker.attach_ms(100, hmsTickerCB);
266+
#ifdef SSD1306_DISPLAY
267+
status.oled_timeout = millis();
268+
#endif
250269
}
251270

252271
void loop()

0 commit comments

Comments
 (0)