From 22ed8c76f988cb9f0584e6aca8b1fddf00d729ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Farkas=20Szil=C3=A1rd?= Date: Thu, 7 Jul 2022 11:23:59 +0200 Subject: [PATCH] Restore Default Configuration button for wifi ap page --- main/http.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main/http.cpp b/main/http.cpp index 66b7f1f..51c10e9 100644 --- a/main/http.cpp +++ b/main/http.cpp @@ -420,7 +420,14 @@ static void ParmForm_AP(httpd_req_t *Req) // Wi-Fi access point parameters { cha httpd_resp_sendstr_chunk(Req, "\n"); } #endif - +static void ParmForm_Defaults(httpd_req_t *Req) +{ + httpd_resp_sendstr_chunk(Req, "\ +
\n\ +\n\ +\n\ +
\n"); +} static void ParmForm_Restart(httpd_req_t *Req) { @@ -794,6 +801,7 @@ static void Html_End(httpd_req_t *Req) static esp_err_t parm_post_handler(httpd_req_t *Req) { bool Restart=0; + bool Defaults=0; /* Destination buffer for content of HTTP POST request. * httpd_req_recv() accepts char* only, but content could * as well be any binary data (needs type casting). @@ -829,6 +837,7 @@ static esp_err_t parm_post_handler(httpd_req_t *Req) #endif char *Line=URL; Restart = strstr(Line,"Restart=1"); + Defaults = strstr(Line,"Defaults=1"); for( ; ; ) { Parameters.ReadLine(Line); Line = strchr(Line, '&'); if(Line==0) break; @@ -836,6 +845,9 @@ static esp_err_t parm_post_handler(httpd_req_t *Req) free(URL); Parameters.WriteToNVS(); + if(Defaults) + { Parameters.setDefault(); } + if(Restart) { #ifdef WITH_SPIFFS @@ -869,6 +881,8 @@ static esp_err_t parm_get_handler(httpd_req_t *Req) ParmForm_Other(Req); + ParmForm_Defaults(Req); + ParmForm_Restart(Req); Html_End(Req);