mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-09 21:17:06 +03:00
Update Reboot Algo
This commit is contained in:
@@ -608,6 +608,14 @@ void task_reboot(void *pvParameter)
|
|||||||
esp_camera_deinit();
|
esp_camera_deinit();
|
||||||
WIFIDestroy();
|
WIFIDestroy();
|
||||||
|
|
||||||
|
|
||||||
|
// write a reboot, to identify a reboot by purpouse
|
||||||
|
FILE* pfile = fopen("/sdcard/reboot.txt", "w");
|
||||||
|
std::string _s_zw= "reboot";
|
||||||
|
fwrite(_s_zw.c_str(), strlen(_s_zw.c_str()), 1, pfile);
|
||||||
|
fclose(pfile);
|
||||||
|
|
||||||
|
|
||||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
esp_restart(); // Reset type: CPU Reset (Reset both CPUs)
|
esp_restart(); // Reset type: CPU Reset (Reset both CPUs)
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,30 @@ long auto_intervall = 0;
|
|||||||
bool auto_isrunning = false;
|
bool auto_isrunning = false;
|
||||||
|
|
||||||
int countRounds = 0;
|
int countRounds = 0;
|
||||||
|
bool isPlannedReboot = false;
|
||||||
|
|
||||||
static const char *TAG = "TFLITE SERVER";
|
static const char *TAG = "TFLITE SERVER";
|
||||||
|
|
||||||
|
|
||||||
|
void CheckIsPlannedReboot()
|
||||||
|
{
|
||||||
|
FILE *pfile;
|
||||||
|
if ((pfile = fopen("/sdcard/reboot.txt", "r")) == NULL)
|
||||||
|
{
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Not a planned reboot.");
|
||||||
|
isPlannedReboot = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Planned reboot.");
|
||||||
|
DeleteFile("/sdcard/reboot.txt"); // Prevent Boot Loop!!!
|
||||||
|
isPlannedReboot = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int getCountFlowRounds()
|
int getCountFlowRounds()
|
||||||
{
|
{
|
||||||
return countRounds;
|
return countRounds;
|
||||||
@@ -772,6 +792,8 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
{
|
{
|
||||||
int64_t fr_start, fr_delta_ms;
|
int64_t fr_start, fr_delta_ms;
|
||||||
|
|
||||||
|
if (!isPlannedReboot)
|
||||||
|
{
|
||||||
if (esp_reset_reason() == ESP_RST_PANIC) {
|
if (esp_reset_reason() == ESP_RST_PANIC) {
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Restarted due to an Exception/panic! Postponing first round start by 5 minutes to allow for an OTA or to fetch the log!");
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Restarted due to an Exception/panic! Postponing first round start by 5 minutes to allow for an OTA or to fetch the log!");
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Setting logfile level to DEBUG until the next reboot!");
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Setting logfile level to DEBUG until the next reboot!");
|
||||||
@@ -779,6 +801,8 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
//MQTTPublish(GetMQTTMainTopic() + "/" + "status", "Postponing first round", false);
|
//MQTTPublish(GetMQTTMainTopic() + "/" + "status", "Postponing first round", false);
|
||||||
vTaskDelay(60*5000 / portTICK_RATE_MS); // Wait 5 minutes to give time to do an OTA or fetch the log
|
vTaskDelay(60*5000 / portTICK_RATE_MS); // Wait 5 minutes to give time to do an OTA or fetch the log
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "task_autodoFlow: start");
|
ESP_LOGD(TAG, "task_autodoFlow: start");
|
||||||
doInit();
|
doInit();
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ void TFliteDoAutoStart();
|
|||||||
bool isSetupModusActive();
|
bool isSetupModusActive();
|
||||||
int getCountFlowRounds();
|
int getCountFlowRounds();
|
||||||
|
|
||||||
|
void CheckIsPlannedReboot();
|
||||||
|
|
||||||
esp_err_t GetJPG(std::string _filename, httpd_req_t *req);
|
esp_err_t GetJPG(std::string _filename, httpd_req_t *req);
|
||||||
esp_err_t GetRawJPG(httpd_req_t *req);
|
esp_err_t GetRawJPG(httpd_req_t *req);
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ extern "C" void app_main(void)
|
|||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, versionFormated);
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, versionFormated);
|
||||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Reset reason: " + getResetReason());
|
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Reset reason: " + getResetReason());
|
||||||
|
|
||||||
|
CheckIsPlannedReboot();
|
||||||
CheckOTAUpdate();
|
CheckOTAUpdate();
|
||||||
CheckUpdate();
|
CheckUpdate();
|
||||||
#ifdef ENABLE_SOFTAP
|
#ifdef ENABLE_SOFTAP
|
||||||
|
|||||||
Reference in New Issue
Block a user