Skip to content

Commit 8f714c6

Browse files
committed
network_common.cpp: fix http_reply, after saving wifi credentials.
1 parent bbac058 commit 8f714c6

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

SmartEVSE-3/src/network_common.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -986,18 +986,11 @@ static void fn_http_server(struct mg_connection *c, int ev, void *ev_data) {
986986
bool has_pass = mg_http_get_var(&hm->body, "password", password, sizeof(password)) > 0;
987987
if (has_ssid && has_pass) {
988988
mg_http_reply(c, 200, "Content-Type: text/html\r\n", "<html><body><h2>Saved! Rebooting...</h2></body></html>");
989-
#ifndef SENSORBOX_VERSION
990-
vTaskDelay(2000 / portTICK_PERIOD_MS); // for some strange reason this triggers the watchdog function in Sensorbox
991-
#endif
992989
_LOG_A("Connecting to wifi network.\n");
993-
WiFi.mode(WIFI_STA); // Set Station Mode
994-
WiFi.begin(ssid, password); // Configure Wifi with credentials
995-
WIFImode = 1; // we are already connected so don't call handleWIFImode
990+
WiFi.begin(ssid, password); // Configure Wifi with credentials
991+
WIFImode = 1; // we are already connected so don't call handleWIFImode
996992
write_settings();
997-
#ifndef SENSORBOX_VERSION
998-
vTaskDelay(2000 / portTICK_PERIOD_MS); // for some strange reason this triggers the watchdog function in Sensorbox
999-
#endif
1000-
ESP.restart();
993+
shouldReboot = true; // Allow the webserver to send the reply back before rebooting
1001994
} else {
1002995
mg_http_reply(c, 400, "", "Missing SSID or password");
1003996
}

0 commit comments

Comments
 (0)