From aa81f397126e0f83653fa08f2227814d9c8e3ee2 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Thu, 3 Oct 2019 22:45:46 -0400 Subject: [PATCH] Bug fix: rebooting to squeezelite now works --- components/cmd_system/cmd_system.c | 6 ++++++ components/cmd_system/cmd_system.h | 1 + components/wifi-manager/http_server.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/cmd_system/cmd_system.c b/components/cmd_system/cmd_system.c index 803fda67..c6e15e7e 100644 --- a/components/cmd_system/cmd_system.c +++ b/components/cmd_system/cmd_system.c @@ -142,6 +142,12 @@ static int restart(int argc, char **argv) guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY); return 0; // return fail. This should never return... we're rebooting! } +esp_err_t guided_restart_ota(){ + guided_boot(ESP_PARTITION_SUBTYPE_APP_OTA_0); + // If we're still alive, then there may not be an ota partition to boot from + guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY); + return ESP_FAIL; // return fail. This should never return... we're rebooting! +} esp_err_t guided_factory(){ guided_boot(ESP_PARTITION_SUBTYPE_APP_FACTORY); return ESP_FAIL; // return fail. This should never return... we're rebooting! diff --git a/components/cmd_system/cmd_system.h b/components/cmd_system/cmd_system.h index ccfb06de..add6d051 100644 --- a/components/cmd_system/cmd_system.h +++ b/components/cmd_system/cmd_system.h @@ -15,6 +15,7 @@ extern "C" { // Register system functions void register_system(); esp_err_t guided_factory(); +esp_err_t guided_restart_ota(); #ifdef __cplusplus } diff --git a/components/wifi-manager/http_server.c b/components/wifi-manager/http_server.c index d829fd95..0e264ade 100644 --- a/components/wifi-manager/http_server.c +++ b/components/wifi-manager/http_server.c @@ -480,7 +480,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); /* 200 ok */ } else if(strstr(line, "POST /reboot.json ")){ - esp_restart(); + guided_restart_ota(); } else if(strstr(line, "POST /recovery.json ")){ guided_factory();