kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Restore Default Configuration button for wifi ap page
rodzic
7d4b309534
commit
22ed8c76f9
|
@ -420,7 +420,14 @@ static void ParmForm_AP(httpd_req_t *Req) // Wi-Fi access point parameters { cha
|
|||
httpd_resp_sendstr_chunk(Req, "</form>\n"); }
|
||||
#endif
|
||||
|
||||
|
||||
static void ParmForm_Defaults(httpd_req_t *Req)
|
||||
{
|
||||
httpd_resp_sendstr_chunk(Req, "\
|
||||
<form action=\"/parm.html\" method=\"POST\" onsubmit=\"return confirm('Are you sure to restore default configuration?')\">\n\
|
||||
<input type=\"submit\" value=\"Restore Default Configuration\">\n\
|
||||
<input type=\"hidden\" name=\"Defaults\" value=\"1\">\n\
|
||||
</form>\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);
|
||||
|
|
Ładowanie…
Reference in New Issue