浏览代码

Fix UI reboot to OTA/Recovery button - release

Sebastien 5 年之前
父节点
当前提交
29242c63b9

+ 2 - 1
components/cmd_system/cmd_system.c

@@ -6,7 +6,7 @@
    software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    CONDITIONS OF ANY KIND, either express or implied.
    CONDITIONS OF ANY KIND, either express or implied.
 */
 */
-//#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
+#define LOG_LOCAL_LEVEL ESP_LOG_INFO
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
@@ -128,6 +128,7 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
 	}
 	}
 	else
 	else
 	{
 	{
+		ESP_LOGD(TAG, "Found partition. Getting info.");
 		partition = (esp_partition_t *) esp_partition_get(it);
 		partition = (esp_partition_t *) esp_partition_get(it);
 		ESP_LOGD(TAG, "Releasing partition iterator");
 		ESP_LOGD(TAG, "Releasing partition iterator");
 		esp_partition_iterator_release(it);
 		esp_partition_iterator_release(it);

+ 2 - 2
components/squeezelite-ota/cmd_ota.c

@@ -27,7 +27,7 @@
 #include "sdkconfig.h"
 #include "sdkconfig.h"
 
 
 static const char * TAG = "platform_esp32";
 static const char * TAG = "platform_esp32";
-extern esp_err_t start_ota(const char * bin_url, bool bFromAppMain);
+extern esp_err_t start_ota(const char * bin_url);
 static struct {
 static struct {
     struct arg_str *url;
     struct arg_str *url;
     struct arg_end *end;
     struct arg_end *end;
@@ -45,7 +45,7 @@ static int perform_ota_update(int argc, char **argv)
 
 
     esp_err_t err=ESP_OK;
     esp_err_t err=ESP_OK;
     ESP_LOGI(TAG, "Starting ota: %s", url);
     ESP_LOGI(TAG, "Starting ota: %s", url);
-    start_ota(url,false);
+    start_ota(url);
 
 
     if (err != ESP_OK) {
     if (err != ESP_OK) {
         ESP_LOGE(TAG, "%s", esp_err_to_name(err));
         ESP_LOGE(TAG, "%s", esp_err_to_name(err));

+ 1 - 1
components/squeezelite-ota/squeezelite-ota.c

@@ -640,7 +640,7 @@ esp_err_t process_recovery_ota(const char * bin_url){
     return ESP_OK;
     return ESP_OK;
 }
 }
 
 
-esp_err_t start_ota(const char * bin_url, bool bFromAppMain)
+esp_err_t start_ota(const char * bin_url)
 {
 {
 //	uint8_t * config_alloc_get_default(NVS_TYPE_BLOB, "certs", server_cert_pem_start , server_cert_pem_end-server_cert_pem_start);
 //	uint8_t * config_alloc_get_default(NVS_TYPE_BLOB, "certs", server_cert_pem_start , server_cert_pem_end-server_cert_pem_start);
 #if RECOVERY_APPLICATION
 #if RECOVERY_APPLICATION

+ 1 - 1
components/squeezelite-ota/squeezelite-ota.h

@@ -21,7 +21,7 @@
 #define OTA_FLASH_ERASE_BLOCK (uint32_t)512000
 #define OTA_FLASH_ERASE_BLOCK (uint32_t)512000
 #define OTA_STACK_SIZE 5120
 #define OTA_STACK_SIZE 5120
 #define OTA_TASK_PRIOTITY 6
 #define OTA_TASK_PRIOTITY 6
-esp_err_t start_ota(const char * bin_url, bool bFromAppMain);
+esp_err_t start_ota(const char * bin_url);
 const char * ota_get_status();
 const char * ota_get_status();
 uint8_t ota_get_pct_complete();
 uint8_t ota_get_pct_complete();
 
 

+ 2 - 8
components/wifi-manager/http_server.c

@@ -533,26 +533,20 @@ void http_server_netconn_serve(struct netconn *conn) {
 					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving DELETE /connect.json");
 					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving DELETE /connect.json");
 				}
 				}
 				else if(strstr(line, "POST /reboot_ota.json ")) {
 				else if(strstr(line, "POST /reboot_ota.json ")) {
-					ESP_LOGI(TAG,   "http_server_netconn_serve: POST reboot.json");
+					ESP_LOGI(TAG,   "http_server_netconn_serve: POST reboot_ota.json");
 					netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
 					netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
-					netconn_close(conn);
-					netconn_delete(conn);
 					wifi_manager_reboot(OTA);
 					wifi_manager_reboot(OTA);
-					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving POST reboot.json");
+					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving POST reboot_ota.json");
 				}
 				}
 				else if(strstr(line, "POST /reboot.json ")) {
 				else if(strstr(line, "POST /reboot.json ")) {
 					ESP_LOGI(TAG,   "http_server_netconn_serve: POST reboot.json");
 					ESP_LOGI(TAG,   "http_server_netconn_serve: POST reboot.json");
 					netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
 					netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
-					netconn_close(conn);
-					netconn_delete(conn);
 					wifi_manager_reboot(RESTART);
 					wifi_manager_reboot(RESTART);
 					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving POST reboot.json");
 					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving POST reboot.json");
 				}
 				}
 				else if(strstr(line, "POST /recovery.json ")) {
 				else if(strstr(line, "POST /recovery.json ")) {
 					ESP_LOGI(TAG,   "http_server_netconn_serve: POST recovery.json");
 					ESP_LOGI(TAG,   "http_server_netconn_serve: POST recovery.json");
 					netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
 					netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); /* 200 ok */
-					netconn_close(conn);
-					netconn_delete(conn);
 					wifi_manager_reboot(RECOVERY);
 					wifi_manager_reboot(RECOVERY);
 					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving POST recovery.json");
 					ESP_LOGI(TAG,   "http_server_netconn_serve: done serving POST recovery.json");
 				}
 				}

+ 5 - 1
components/wifi-manager/wifi_manager.c

@@ -1464,17 +1464,21 @@ void wifi_manager( void * pvParameters ){
 
 
 				break;
 				break;
 			case  ORDER_RESTART_OTA:
 			case  ORDER_RESTART_OTA:
+				ESP_LOGD(TAG,   "Calling guided_restart_ota.");
 				guided_restart_ota();
 				guided_restart_ota();
 				break;
 				break;
 			case  ORDER_RESTART_OTA_URL:
 			case  ORDER_RESTART_OTA_URL:
-				start_ota(msg.param,false);
+				ESP_LOGD(TAG,   "Calling start_ota.");
+				start_ota(msg.param);
 				free(msg.param);
 				free(msg.param);
 				break;
 				break;
 
 
 			case  ORDER_RESTART_RECOVERY:
 			case  ORDER_RESTART_RECOVERY:
+				ESP_LOGD(TAG,   "Calling guided_factory.");
 				guided_factory();
 				guided_factory();
 				break;
 				break;
 			case	ORDER_RESTART:
 			case	ORDER_RESTART:
+				ESP_LOGD(TAG,   "Calling simple_restart.");
 				simple_restart();
 				simple_restart();
 				break;
 				break;
 			default:
 			default:

+ 1 - 1
main/esp_app_main.c

@@ -316,7 +316,7 @@ void app_main()
 			taskYIELD();
 			taskYIELD();
 		}
 		}
 		ESP_LOGI(TAG,"Updating firmware from link: %s",fwurl);
 		ESP_LOGI(TAG,"Updating firmware from link: %s",fwurl);
-		start_ota(fwurl, true);
+		start_ota(fwurl);
 #else
 #else
 		ESP_LOGE(TAG,"Restarted to application partition. We're not going to perform OTA!");
 		ESP_LOGE(TAG,"Restarted to application partition. We're not going to perform OTA!");
 #endif
 #endif