Fix regression of reboot handler / reboot waiting script (#1725)

* Reboot after OTA: Avoid exeception

* Overview - optimize reload behaviour after reboot

* Update

* Update
This commit is contained in:
Slider0007
2022-12-30 21:58:46 +01:00
committed by GitHub
parent 58cbd680e8
commit 33f357d8da
4 changed files with 51 additions and 35 deletions

View File

@@ -93,7 +93,7 @@ void task_do_Update_ZIP(void *pvParameter)
}
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Trigger reboot due to firmware update.");
doReboot();
doRebootOTA();
}
else
{
@@ -596,7 +596,7 @@ void hard_restart()
}
void task_reboot(void *TaskCreated)
void task_reboot(void *KillAutoFlow)
{
// write a reboot, to identify a reboot by purpouse
FILE* pfile = fopen("/sdcard/reboot.txt", "w");
@@ -604,7 +604,9 @@ void task_reboot(void *TaskCreated)
fwrite(_s_zw.c_str(), strlen(_s_zw.c_str()), 1, pfile);
fclose(pfile);
if ((bool)TaskCreated) {
vTaskDelay(3000 / portTICK_PERIOD_MS);
if ((bool)KillAutoFlow) {
KillTFliteTasks(); // Kill autoflow task if executed in extra task, if not don't kill parent task
}
@@ -616,13 +618,14 @@ void task_reboot(void *TaskCreated)
esp_camera_deinit();
WIFIDestroy();
vTaskDelay(4000 / portTICK_PERIOD_MS);
esp_restart(); // Reset type: CPU Reset (Reset both CPUs)
vTaskDelay(3000 / portTICK_PERIOD_MS);
esp_restart(); // Reset type: CPU reset (Reset both CPUs)
vTaskDelay(5000 / portTICK_PERIOD_MS);
hard_restart(); // Reset type: System reset (Triggered by watchdog), if esp_restart stalls (WDT needs to be activated)
vTaskDelete(NULL); //Delete this task if it exits from the loop above
ESP_LOGE(TAG, "Reboot failed!");
vTaskDelete(NULL); //Delete this task if it comes to this point
}
@@ -630,12 +633,28 @@ void doReboot()
{
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Reboot triggered by Software (5s).");
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Reboot in 5sec");
BaseType_t xReturned = xTaskCreate(&task_reboot, "task_reboot", configMINIMAL_STACK_SIZE * 3, (void*) true, 10, NULL);
if( xReturned != pdPASS )
{
ESP_LOGE(TAG, "task_reboot not created -> force reboot without killing flow");
task_reboot((void*) false);
}
vTaskDelay(10000 / portTICK_PERIOD_MS); // Prevent serving web client fetch response until system is shuting down
}
void doRebootOTA()
{
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Reboot in 5sec");
esp_camera_deinit();
vTaskDelay(5000 / portTICK_PERIOD_MS);
esp_restart(); // Reset type: CPU reset (Reset both CPUs)
vTaskDelay(5000 / portTICK_PERIOD_MS);
hard_restart(); // Reset type: System reset (Triggered by watchdog), if esp_restart stalls (WDT needs to be activated)
}
@@ -647,7 +666,7 @@ esp_err_t handler_reboot(httpd_req_t *req)
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_reboot");
ESP_LOGI(TAG, "!!! System will restart within 5 sec!!!");
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s<br>(in case of a firmware update it can take up to 180s).<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch('/index.html',{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 5000);</script>";
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s<br>(in case of a firmware update it can take up to 180s).<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch('/reboot_page.html',{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>";
httpd_resp_send(req, resp_str, strlen(resp_str));
doReboot();

View File

@@ -13,6 +13,7 @@
void register_server_ota_sdcard_uri(httpd_handle_t server);
void CheckOTAUpdate();
void doReboot();
void doRebootOTA();
void hard_restart();
void CheckUpdate();

View File

@@ -180,7 +180,7 @@ esp_err_t reboot_handlerAP(httpd_req_t *req)
LogFile.WriteHeapInfo("handler_ota_update - Start");
#endif
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Trigger reboot due to firmware update.");
doReboot();
doRebootOTA();
return ESP_OK;
};

View File

@@ -81,25 +81,32 @@ function addZero(i) {
}
$(document).ready(function() {
LoadData();
LoadROIImage();
});
function LoadData(){
loadValue("value", "value");
loadValue("raw", "raw");
loadValue("prevalue", "prevalue");
loadValue("error", "error", "font-size:8px");
loadStatus();
loadCPUTemp();
loadRSSI();
loadUptime();
loadRoundCounter();
loadValue("value", "value");
loadValue("raw", "raw");
loadValue("prevalue", "prevalue");
loadValue("error", "error", "font-size:8px");
}
function LoadROIImage(){
var d = new Date();
var timestamp = d.getTime();
var h = addZero(d.getHours());
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
$('#img').html('<img src="/img_tmp/alg_roi.jpg" style="max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
}
@@ -107,16 +114,7 @@ function addZero(i) {
function Refresh() {
setTimeout (function() {
LoadData();
var d = new Date();
var timestamp = d.getTime();
var h = addZero(d.getHours());
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
// reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp to ensure image is getting reloaded
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
LoadROIImage();
Refresh();
}, 300000);
}
@@ -235,8 +233,6 @@ function addZero(i) {
function init(){
basepath = getbasepath();
LoadData();
LoadROIImage();
Refresh();
}