diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index b4885e2..1b9e582 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -184,6 +184,7 @@ void MenuFunctions::RunSetup() deviceMenu.list = new LinkedList(); // Device menu stuff + failedUpdateMenu.list = new LinkedList(); whichUpdateMenu.list = new LinkedList(); confirmMenu.list = new LinkedList(); updateMenu.list = new LinkedList(); @@ -203,6 +204,7 @@ void MenuFunctions::RunSetup() wifiMenu.name = " WiFi "; deviceMenu.name = " Device "; generalMenu.name = " General Apps "; + failedUpdateMenu.name = " Updating... "; whichUpdateMenu.name = "Select Method "; confirmMenu.name = " Confirm Update "; updateMenu.name = " Update Firmware "; @@ -279,19 +281,23 @@ void MenuFunctions::RunSetup() whichUpdateMenu.parentMenu = &deviceMenu; 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, "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 confirmMenu.parentMenu = &whichUpdateMenu; 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; sd_obj.runUpdate();}); + addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&failedUpdateMenu); sd_obj.runUpdate();}); // Web Update 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);}); + // 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 infoMenu.parentMenu = &deviceMenu; addNodes(&infoMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(infoMenu.parentMenu);}); diff --git a/esp32_marauder/MenuFunctions.h b/esp32_marauder/MenuFunctions.h index 0227473..9bd417e 100644 --- a/esp32_marauder/MenuFunctions.h +++ b/esp32_marauder/MenuFunctions.h @@ -71,6 +71,9 @@ struct Menu { class MenuFunctions { private: + + String u_result = ""; + Menu* current_menu; // Main menu stuff @@ -83,6 +86,7 @@ class MenuFunctions // Device menu stuff Menu whichUpdateMenu; + Menu failedUpdateMenu; Menu confirmMenu; Menu updateMenu; Menu infoMenu; diff --git a/esp32_marauder/SDInterface.cpp b/esp32_marauder/SDInterface.cpp index bbcafdb..454030f 100644 --- a/esp32_marauder/SDInterface.cpp +++ b/esp32_marauder/SDInterface.cpp @@ -69,19 +69,21 @@ void SDInterface::openCapture() { } void SDInterface::runUpdate() { - display_obj.clearScreen(); + //display_obj.clearScreen(); display_obj.tft.setTextWrap(false); 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.setTextColor(TFT_MAGENTA); + display_obj.tft.setTextColor(TFT_WHITE); display_obj.tft.println("Opening /update.bin..."); File updateBin = SD.open("/update.bin"); if (updateBin) { if(updateBin.isDirectory()){ + display_obj.tft.setTextColor(TFT_RED); display_obj.tft.println("Error, could not find update.bin"); Serial.println("Error, update.bin is not a file"); + display_obj.tft.setTextColor(TFT_WHITE); updateBin.close(); return; } @@ -94,16 +96,21 @@ void SDInterface::runUpdate() { this->performUpdate(updateBin, updateSize); } else { + display_obj.tft.setTextColor(TFT_RED); display_obj.tft.println("Error, update.bin is empty"); Serial.println("Error, file is empty"); + display_obj.tft.setTextColor(TFT_WHITE); + return; } updateBin.close(); // whe finished remove the binary from sd card to indicate end of the process - display_obj.tft.println("Exiting update process..."); - Serial.println("Exiting update process..."); + display_obj.tft.println("rebooting..."); + Serial.println("rebooting..."); //SD.remove("/update.bin"); + delay(1000); + ESP.restart(); } else { 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."); } else { + display_obj.tft.setTextColor(TFT_RED); display_obj.tft.println("Update could not complete"); Serial.println("Update not finished? Something went wrong!"); + display_obj.tft.setTextColor(TFT_WHITE); } } else {