implemented entering recovery mode
recovery mode itself does not work yet
This commit is contained in:
parent
e31d33273a
commit
ee924b8b30
|
@ -73,7 +73,9 @@ bool ESPMegaPRO::begin()
|
|||
esp_restart();
|
||||
}
|
||||
}
|
||||
|
||||
// Recovery Mode
|
||||
recovery.bindFRAM(&fram, 600);
|
||||
recovery.begin();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,6 +91,7 @@ void ESPMegaPRO::loop()
|
|||
{
|
||||
inputs.loop();
|
||||
outputs.loop();
|
||||
recovery.loop();
|
||||
for (int i = 0; i < 255; i++)
|
||||
{
|
||||
if (cardInstalled[i])
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <ESPMegaDisplay.hpp>
|
||||
#include <InternalDisplay.hpp>
|
||||
#include <ESPMegaWebServer.hpp>
|
||||
#include <ESPMegaRecovery.hpp>
|
||||
|
||||
// ESPMega Pro R3 Board Address
|
||||
#define FRAM_ADDRESS 0x56
|
||||
|
@ -82,6 +83,11 @@ class ESPMegaPRO {
|
|||
* @note You must call enableWebServer() before using this component.
|
||||
*/
|
||||
ESPMegaWebServer *webServer;
|
||||
/**
|
||||
* @brief This component is used to enter recovery mode when the ESPMegaPRO board is in a bootloop.
|
||||
* @typedef ESPMegaRecovery
|
||||
*/
|
||||
ESPMegaRecovery recovery;
|
||||
private:
|
||||
bool iotEnabled = false;
|
||||
bool internalDisplayEnabled = false;
|
||||
|
|
|
@ -15,17 +15,29 @@ void ESPMegaRecovery::begin() {
|
|||
}
|
||||
// Inclement the bootloop counter
|
||||
this->inclementBootloopCounter();
|
||||
ESP_LOGV("ESPMegaRecovery", "Bootloop counter: %d", this->getBootloopCounter());
|
||||
// If the bootloop counter is greater than 5, enter recovery mode
|
||||
if(this->getBootloopCounter() > 5) {
|
||||
ESP_LOGW("ESPMegaRecovery", "Entering recovery mode");
|
||||
this->enterRecoveryMode();
|
||||
// Reset the bootloop counter to prevent re-entering recovery mode
|
||||
// The device might unintentionally restart multiple times
|
||||
// By resetting the counter, the user can press reset once in recovery mode to exit
|
||||
ESP_LOGD("ESPMegaRecovery", "Resetting bootloop counter");
|
||||
this->resetBootloopCounter();
|
||||
}
|
||||
}
|
||||
void ESPMegaRecovery::loop() {
|
||||
// If the device is in recovery mode, block all other tasks
|
||||
if(this->isRecoveryMode()) {
|
||||
int i = 0;
|
||||
while(true) {
|
||||
if (i%10 == 0)
|
||||
ESP_LOGV("ESPMegaRecovery", "System is in recovery mode, no tasks will be executed");
|
||||
ESP_LOGV("ESPMegaRecovery", "Please upload a new firmware to exit recovery mode");
|
||||
// This code will become the new loop
|
||||
delay(1000);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Watchdog timer
|
||||
|
@ -33,6 +45,7 @@ void ESPMegaRecovery::loop() {
|
|||
static uint32_t boot_time = millis();
|
||||
if(!booted) {
|
||||
if(millis() - boot_time > RECOVERY_WATCHDOG_TIMEOUT * 1000) {
|
||||
ESP_LOGI("ESPMegaRecovery", "System booted successfully, resetting bootloop counter");
|
||||
this->resetBootloopCounter();
|
||||
booted = true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <FRAM.h>
|
||||
#include <ESPMegaWebServer.hpp>
|
||||
#include <esp_log.h>
|
||||
/**
|
||||
* @brief Recovery mode for ESPMega
|
||||
* Recovery mode is a mode that is entered when the device is in a bootloop
|
||||
|
|
Loading…
Reference in New Issue