mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 23:26:45 -08:00
Exit if SD update fails
This commit is contained in:
@@ -184,6 +184,7 @@ void MenuFunctions::RunSetup()
|
|||||||
deviceMenu.list = new LinkedList<MenuNode>();
|
deviceMenu.list = new LinkedList<MenuNode>();
|
||||||
|
|
||||||
// Device menu stuff
|
// Device menu stuff
|
||||||
|
failedUpdateMenu.list = new LinkedList<MenuNode>();
|
||||||
whichUpdateMenu.list = new LinkedList<MenuNode>();
|
whichUpdateMenu.list = new LinkedList<MenuNode>();
|
||||||
confirmMenu.list = new LinkedList<MenuNode>();
|
confirmMenu.list = new LinkedList<MenuNode>();
|
||||||
updateMenu.list = new LinkedList<MenuNode>();
|
updateMenu.list = new LinkedList<MenuNode>();
|
||||||
@@ -203,6 +204,7 @@ void MenuFunctions::RunSetup()
|
|||||||
wifiMenu.name = " WiFi ";
|
wifiMenu.name = " WiFi ";
|
||||||
deviceMenu.name = " Device ";
|
deviceMenu.name = " Device ";
|
||||||
generalMenu.name = " General Apps ";
|
generalMenu.name = " General Apps ";
|
||||||
|
failedUpdateMenu.name = " Updating... ";
|
||||||
whichUpdateMenu.name = "Select Method ";
|
whichUpdateMenu.name = "Select Method ";
|
||||||
confirmMenu.name = " Confirm Update ";
|
confirmMenu.name = " Confirm Update ";
|
||||||
updateMenu.name = " Update Firmware ";
|
updateMenu.name = " Update Firmware ";
|
||||||
@@ -279,19 +281,23 @@ void MenuFunctions::RunSetup()
|
|||||||
whichUpdateMenu.parentMenu = &deviceMenu;
|
whichUpdateMenu.parentMenu = &deviceMenu;
|
||||||
addNodes(&whichUpdateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(whichUpdateMenu.parentMenu);});
|
addNodes(&whichUpdateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(whichUpdateMenu.parentMenu);});
|
||||||
addNodes(&whichUpdateMenu, "Web Update", TFT_GREEN, NULL, WEB_UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
|
addNodes(&whichUpdateMenu, "Web Update", TFT_GREEN, NULL, WEB_UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
|
||||||
addNodes(&whichUpdateMenu, "SD Update", TFT_MAGENTA, NULL, SD_UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&confirmMenu);});
|
if (sd_obj.supported) addNodes(&whichUpdateMenu, "SD Update", TFT_MAGENTA, NULL, SD_UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&confirmMenu);});
|
||||||
|
|
||||||
// Confirm SD update menu
|
// Confirm SD update menu
|
||||||
confirmMenu.parentMenu = &whichUpdateMenu;
|
confirmMenu.parentMenu = &whichUpdateMenu;
|
||||||
addNodes(&confirmMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(confirmMenu.parentMenu);});
|
addNodes(&confirmMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(confirmMenu.parentMenu);});
|
||||||
//addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); sd_obj.runUpdate();});
|
//addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); sd_obj.runUpdate();});
|
||||||
addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; sd_obj.runUpdate();});
|
addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&failedUpdateMenu); sd_obj.runUpdate();});
|
||||||
|
|
||||||
// Web Update
|
// Web Update
|
||||||
updateMenu.parentMenu = &deviceMenu;
|
updateMenu.parentMenu = &deviceMenu;
|
||||||
addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true); web_obj.shutdownServer();});
|
addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true); web_obj.shutdownServer();});
|
||||||
//addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu);});
|
//addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu);});
|
||||||
|
|
||||||
|
// Failed update menu
|
||||||
|
failedUpdateMenu.parentMenu = &whichUpdateMenu;
|
||||||
|
addNodes(&failedUpdateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(failedUpdateMenu.parentMenu);});
|
||||||
|
|
||||||
// Device info menu
|
// Device info menu
|
||||||
infoMenu.parentMenu = &deviceMenu;
|
infoMenu.parentMenu = &deviceMenu;
|
||||||
addNodes(&infoMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(infoMenu.parentMenu);});
|
addNodes(&infoMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(infoMenu.parentMenu);});
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ struct Menu {
|
|||||||
class MenuFunctions
|
class MenuFunctions
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
String u_result = "";
|
||||||
|
|
||||||
Menu* current_menu;
|
Menu* current_menu;
|
||||||
|
|
||||||
// Main menu stuff
|
// Main menu stuff
|
||||||
@@ -83,6 +86,7 @@ class MenuFunctions
|
|||||||
|
|
||||||
// Device menu stuff
|
// Device menu stuff
|
||||||
Menu whichUpdateMenu;
|
Menu whichUpdateMenu;
|
||||||
|
Menu failedUpdateMenu;
|
||||||
Menu confirmMenu;
|
Menu confirmMenu;
|
||||||
Menu updateMenu;
|
Menu updateMenu;
|
||||||
Menu infoMenu;
|
Menu infoMenu;
|
||||||
|
|||||||
@@ -69,19 +69,21 @@ void SDInterface::openCapture() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SDInterface::runUpdate() {
|
void SDInterface::runUpdate() {
|
||||||
display_obj.clearScreen();
|
//display_obj.clearScreen();
|
||||||
display_obj.tft.setTextWrap(false);
|
display_obj.tft.setTextWrap(false);
|
||||||
display_obj.tft.setFreeFont(NULL);
|
display_obj.tft.setFreeFont(NULL);
|
||||||
display_obj.tft.setCursor(0, 0);
|
display_obj.tft.setCursor(0, 100);
|
||||||
display_obj.tft.setTextSize(1);
|
display_obj.tft.setTextSize(1);
|
||||||
display_obj.tft.setTextColor(TFT_MAGENTA);
|
display_obj.tft.setTextColor(TFT_WHITE);
|
||||||
|
|
||||||
display_obj.tft.println("Opening /update.bin...");
|
display_obj.tft.println("Opening /update.bin...");
|
||||||
File updateBin = SD.open("/update.bin");
|
File updateBin = SD.open("/update.bin");
|
||||||
if (updateBin) {
|
if (updateBin) {
|
||||||
if(updateBin.isDirectory()){
|
if(updateBin.isDirectory()){
|
||||||
|
display_obj.tft.setTextColor(TFT_RED);
|
||||||
display_obj.tft.println("Error, could not find update.bin");
|
display_obj.tft.println("Error, could not find update.bin");
|
||||||
Serial.println("Error, update.bin is not a file");
|
Serial.println("Error, update.bin is not a file");
|
||||||
|
display_obj.tft.setTextColor(TFT_WHITE);
|
||||||
updateBin.close();
|
updateBin.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -94,16 +96,21 @@ void SDInterface::runUpdate() {
|
|||||||
this->performUpdate(updateBin, updateSize);
|
this->performUpdate(updateBin, updateSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
display_obj.tft.setTextColor(TFT_RED);
|
||||||
display_obj.tft.println("Error, update.bin is empty");
|
display_obj.tft.println("Error, update.bin is empty");
|
||||||
Serial.println("Error, file is empty");
|
Serial.println("Error, file is empty");
|
||||||
|
display_obj.tft.setTextColor(TFT_WHITE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBin.close();
|
updateBin.close();
|
||||||
|
|
||||||
// whe finished remove the binary from sd card to indicate end of the process
|
// whe finished remove the binary from sd card to indicate end of the process
|
||||||
display_obj.tft.println("Exiting update process...");
|
display_obj.tft.println("rebooting...");
|
||||||
Serial.println("Exiting update process...");
|
Serial.println("rebooting...");
|
||||||
//SD.remove("/update.bin");
|
//SD.remove("/update.bin");
|
||||||
|
delay(1000);
|
||||||
|
ESP.restart();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
display_obj.tft.println("Could not load update.bin from /");
|
display_obj.tft.println("Could not load update.bin from /");
|
||||||
@@ -131,8 +138,10 @@ void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) {
|
|||||||
Serial.println("Update successfully completed. Rebooting.");
|
Serial.println("Update successfully completed. Rebooting.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
display_obj.tft.setTextColor(TFT_RED);
|
||||||
display_obj.tft.println("Update could not complete");
|
display_obj.tft.println("Update could not complete");
|
||||||
Serial.println("Update not finished? Something went wrong!");
|
Serial.println("Update not finished? Something went wrong!");
|
||||||
|
display_obj.tft.setTextColor(TFT_WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user