Fix UI reboot to OTA/Recovery button - release

This commit is contained in:
Sebastien
2019-11-20 14:56:06 -05:00
parent b215f5ddec
commit 29242c63b9
7 changed files with 14 additions and 15 deletions

View File

@@ -6,7 +6,7 @@
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
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 <string.h>
#include <ctype.h>
@@ -128,6 +128,7 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
}
else
{
ESP_LOGD(TAG, "Found partition. Getting info.");
partition = (esp_partition_t *) esp_partition_get(it);
ESP_LOGD(TAG, "Releasing partition iterator");
esp_partition_iterator_release(it);

View File

@@ -27,7 +27,7 @@
#include "sdkconfig.h"
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 {
struct arg_str *url;
struct arg_end *end;
@@ -45,7 +45,7 @@ static int perform_ota_update(int argc, char **argv)
esp_err_t err=ESP_OK;
ESP_LOGI(TAG, "Starting ota: %s", url);
start_ota(url,false);
start_ota(url);
if (err != ESP_OK) {
ESP_LOGE(TAG, "%s", esp_err_to_name(err));

View File

@@ -640,7 +640,7 @@ esp_err_t process_recovery_ota(const char * bin_url){
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);
#if RECOVERY_APPLICATION

View File

@@ -21,7 +21,7 @@
#define OTA_FLASH_ERASE_BLOCK (uint32_t)512000
#define OTA_STACK_SIZE 5120
#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();
uint8_t ota_get_pct_complete();

View File

@@ -533,26 +533,20 @@ void http_server_netconn_serve(struct netconn *conn) {
ESP_LOGI(TAG, "http_server_netconn_serve: done serving DELETE /connect.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_close(conn);
netconn_delete(conn);
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 ")) {
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_close(conn);
netconn_delete(conn);
wifi_manager_reboot(RESTART);
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST reboot.json");
}
else if(strstr(line, "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_close(conn);
netconn_delete(conn);
wifi_manager_reboot(RECOVERY);
ESP_LOGI(TAG, "http_server_netconn_serve: done serving POST recovery.json");
}

View File

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

View File

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