Skip to content

Commit

Permalink
network.cpp: make /reboot reply to request before rebooting
Browse files Browse the repository at this point in the history
  • Loading branch information
dingo35 committed Oct 18, 2024
1 parent 5e2bdec commit 1507906
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Sensorbox2_ESP/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,14 +1170,8 @@ static void fn_http_server(struct mg_connection *c, int ev, void *ev_data) {
mg_http_reply(c, 200, "Content-Type: application/json\r\n", "%s\r\n", json.c_str()); // Yes. Respond JSON
*/ } else if (mg_http_match_uri(hm, "/reboot") && !memcmp("POST", hm->method.buf, hm->method.len)) {
DynamicJsonDocument doc(20);

ESP.restart();
doc["reboot"] = true;

String json;
serializeJson(doc, json);
mg_http_reply(c, 200, "Content-Type: application/json\r\n", "%s\r\n", json.c_str()); // Yes. Respond JSON
shouldReboot = true;
mg_http_reply(c, 200, "", "Rebooting....");
} else if (mg_http_match_uri(hm, "/settings") && !memcmp("POST", hm->method.buf, hm->method.len)) {
DynamicJsonDocument doc(64);
#if MQTT
Expand Down

0 comments on commit 1507906

Please sign in to comment.