diff --git a/components/wifi-manager/code.js b/components/wifi-manager/code.js index be532981..12328e61 100644 --- a/components/wifi-manager/code.js +++ b/components/wifi-manager/code.js @@ -11,7 +11,7 @@ if (!String.prototype.format) { }; } -var recovery = 0; +var recovery = false; var enableTimers = true; var commandHeader = 'squeezelite -b 500:2000 -d all=info '; @@ -187,16 +187,6 @@ $(document).ready(function(){ selectOutput(this); }); - if (recovery) { - $("#recoverydiv").hide(); - $("#otadiv").show(); - $("#command_line").hide(); - $("#wifi").hide(); - } else { - $("#recoverydiv").show(); - $("#otadiv").hide(); - } - //first time the page loads: attempt to get the connection status and start the wifi scan refreshAP(); getConfig(); @@ -379,6 +369,19 @@ function getConfig() { $("#autoexec-cb")[0].checked=false; $("#autoexec-command").hide(200); } + } + if (data.hasOwnProperty('recovery')) { + if (data["recovery"] === 1) { + recovery = true; + $("#recoverydiv").hide(); + $("#otadiv").show(); + $("#command_line").hide(); + $("#wifi").hide(); + } else { + recovery = false; + $("#recoverydiv").show(); + $("#otadiv").hide(); + } } if (data.hasOwnProperty('list')) { data.list.forEach(function(line) { diff --git a/components/wifi-manager/http_server.c b/components/wifi-manager/http_server.c index 0d584183..026abca1 100644 --- a/components/wifi-manager/http_server.c +++ b/components/wifi-manager/http_server.c @@ -37,7 +37,7 @@ function to process requests, decode URLs, serve files, etc. etc. /* @brief tag used for ESP serial console messages */ static const char TAG[] = "http_server"; -static const char json_start[] = "{ \"autoexec\": %u, \"list\": ["; +static const char json_start[] = "{ \"recovery\": %u, \"autoexec\": %u, \"list\": ["; static const char json_end[] = "]}"; static const char template[] = "{ \"%s\": \"%s\" }"; static const char array_separator[]=","; @@ -45,6 +45,9 @@ static const char array_separator[]=","; /* @brief task handle for the http server */ static TaskHandle_t task_http_server = NULL; +#ifndef CONFIG_IS_RECOVERY_MODE +#define CONFIG_IS_RECOVERY_MODE 0 +#endif /** * @brief embedded binary data. @@ -222,7 +225,7 @@ void http_server_netconn_serve(struct netconn *conn) { netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); autoexec_flag = wifi_manager_get_flag(); - snprintf(buff,buflen-1, json_start, autoexec_flag); + snprintf(buff,buflen-1, json_start, CONFIG_IS_RECOVERY_MODE, autoexec_flag); netconn_write(conn, buff, strlen(buff), NETCONN_NOCOPY); do { snprintf(autoexec_name,sizeof(autoexec_name)-1,"autoexec%u",i);