mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 07:29:14 -08:00
Update display during OTA web update
This commit is contained in:
@@ -112,7 +112,8 @@ MenuFunctions::MenuFunctions()
|
|||||||
// Function to check menu input
|
// Function to check menu input
|
||||||
void MenuFunctions::main()
|
void MenuFunctions::main()
|
||||||
{
|
{
|
||||||
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) {
|
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
|
||||||
|
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
|
||||||
if (wifi_scan_obj.orient_display) {
|
if (wifi_scan_obj.orient_display) {
|
||||||
this->orientDisplay();
|
this->orientDisplay();
|
||||||
wifi_scan_obj.orient_display = false;
|
wifi_scan_obj.orient_display = false;
|
||||||
@@ -139,6 +140,9 @@ void MenuFunctions::main()
|
|||||||
// getTouch causes a 10ms delay which makes beacon spam less effective
|
// getTouch causes a 10ms delay which makes beacon spam less effective
|
||||||
//if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF)
|
//if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF)
|
||||||
pressed = display_obj.tft.getTouch(&t_x, &t_y);
|
pressed = display_obj.tft.getTouch(&t_x, &t_y);
|
||||||
|
|
||||||
|
//if (pressed)
|
||||||
|
// Serial.println("Pressed, son");
|
||||||
//boolean pressed = false;
|
//boolean pressed = false;
|
||||||
|
|
||||||
//Serial.print("getTouch: ");
|
//Serial.print("getTouch: ");
|
||||||
@@ -147,7 +151,7 @@ void MenuFunctions::main()
|
|||||||
|
|
||||||
|
|
||||||
// This is if there are scans/attacks going on
|
// This is if there are scans/attacks going on
|
||||||
if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF) && (pressed))
|
if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF) && (pressed) && (wifi_scan_obj.currentScanMode != OTA_UPDATE))
|
||||||
{
|
{
|
||||||
// Stop the current scan
|
// Stop the current scan
|
||||||
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
|
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
|
||||||
@@ -238,6 +242,7 @@ void MenuFunctions::RunSetup()
|
|||||||
wifiMenu.list = new SimpleList<MenuNode>(); // Get list in second menu ready
|
wifiMenu.list = new SimpleList<MenuNode>(); // Get list in second menu ready
|
||||||
bluetoothMenu.list = new SimpleList<MenuNode>(); // Get list in third menu ready
|
bluetoothMenu.list = new SimpleList<MenuNode>(); // Get list in third menu ready
|
||||||
generalMenu.list = new SimpleList<MenuNode>();
|
generalMenu.list = new SimpleList<MenuNode>();
|
||||||
|
updateMenu.list = new SimpleList<MenuNode>();
|
||||||
|
|
||||||
// WiFi menu stuff
|
// WiFi menu stuff
|
||||||
wifiSnifferMenu.list = new SimpleList<MenuNode>();
|
wifiSnifferMenu.list = new SimpleList<MenuNode>();
|
||||||
@@ -252,6 +257,7 @@ void MenuFunctions::RunSetup()
|
|||||||
mainMenu.name = " ESP32 Marauder ";
|
mainMenu.name = " ESP32 Marauder ";
|
||||||
wifiMenu.name = " WiFi ";
|
wifiMenu.name = " WiFi ";
|
||||||
generalMenu.name = " General Apps ";
|
generalMenu.name = " General Apps ";
|
||||||
|
updateMenu.name = " Update Firmware ";
|
||||||
bluetoothMenu.name = " Bluetooth ";
|
bluetoothMenu.name = " Bluetooth ";
|
||||||
wifiSnifferMenu.name = " WiFi Sniffers ";
|
wifiSnifferMenu.name = " WiFi Sniffers ";
|
||||||
wifiScannerMenu.name = " WiFi Scanners";
|
wifiScannerMenu.name = " WiFi Scanners";
|
||||||
@@ -264,7 +270,7 @@ void MenuFunctions::RunSetup()
|
|||||||
addNodes(&mainMenu, "WiFi", TFT_GREEN, NULL, WIFI, [this](){changeMenu(&wifiMenu);});
|
addNodes(&mainMenu, "WiFi", TFT_GREEN, NULL, WIFI, [this](){changeMenu(&wifiMenu);});
|
||||||
addNodes(&mainMenu, "Bluetooth", TFT_CYAN, NULL, BLUETOOTH, [this](){changeMenu(&bluetoothMenu);});
|
addNodes(&mainMenu, "Bluetooth", TFT_CYAN, NULL, BLUETOOTH, [this](){changeMenu(&bluetoothMenu);});
|
||||||
addNodes(&mainMenu, "General Apps", TFT_MAGENTA, NULL, GENERAL_APPS, [this](){changeMenu(&generalMenu);});
|
addNodes(&mainMenu, "General Apps", TFT_MAGENTA, NULL, GENERAL_APPS, [this](){changeMenu(&generalMenu);});
|
||||||
addNodes(&mainMenu, "Update Firmware", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; web_obj.setupOTAupdate();});
|
addNodes(&mainMenu, "Update Firmware", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
|
||||||
addNodes(&mainMenu, "Reboot", TFT_LIGHTGREY, NULL, REBOOT, [](){ESP.restart();});
|
addNodes(&mainMenu, "Reboot", TFT_LIGHTGREY, NULL, REBOOT, [](){ESP.restart();});
|
||||||
|
|
||||||
// Build WiFi Menu
|
// Build WiFi Menu
|
||||||
@@ -312,6 +318,9 @@ void MenuFunctions::RunSetup()
|
|||||||
addNodes(&generalMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){display_obj.draw_tft = false; changeMenu(generalMenu.parentMenu);});
|
addNodes(&generalMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){display_obj.draw_tft = false; changeMenu(generalMenu.parentMenu);});
|
||||||
addNodes(&generalMenu, "Draw", TFT_WHITE, NULL, DRAW, [this](){display_obj.clearScreen(); display_obj.draw_tft = true;});
|
addNodes(&generalMenu, "Draw", TFT_WHITE, NULL, DRAW, [this](){display_obj.clearScreen(); display_obj.draw_tft = true;});
|
||||||
|
|
||||||
|
updateMenu.parentMenu = &mainMenu;
|
||||||
|
addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true);});
|
||||||
|
|
||||||
|
|
||||||
// Set the current menu to the mainMenu
|
// Set the current menu to the mainMenu
|
||||||
changeMenu(&mainMenu);
|
changeMenu(&mainMenu);
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ class MenuFunctions
|
|||||||
Menu wifiMenu;
|
Menu wifiMenu;
|
||||||
Menu bluetoothMenu;
|
Menu bluetoothMenu;
|
||||||
Menu generalMenu;
|
Menu generalMenu;
|
||||||
|
Menu updateMenu;
|
||||||
|
|
||||||
// WiFi menu stuff
|
// WiFi menu stuff
|
||||||
Menu wifiSnifferMenu;
|
Menu wifiSnifferMenu;
|
||||||
|
|||||||
@@ -32,12 +32,26 @@ void Web::main()
|
|||||||
|
|
||||||
void Web::setupOTAupdate()
|
void Web::setupOTAupdate()
|
||||||
{
|
{
|
||||||
|
display_obj.tft.setTextWrap(false);
|
||||||
|
display_obj.tft.setFreeFont(NULL);
|
||||||
|
display_obj.tft.setCursor(0, 100);
|
||||||
|
display_obj.tft.setTextSize(1);
|
||||||
|
display_obj.tft.setTextColor(TFT_WHITE);
|
||||||
|
|
||||||
|
display_obj.tft.print("Configuring update server...\n\n");
|
||||||
Serial.println("Configuring update server...");
|
Serial.println("Configuring update server...");
|
||||||
|
|
||||||
|
display_obj.tft.setTextColor(TFT_YELLOW);
|
||||||
|
|
||||||
// Start WiFi AP
|
// Start WiFi AP
|
||||||
WiFi.softAP(ssid, password);
|
WiFi.softAP(ssid, password);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
|
display_obj.tft.print("SSID: ");
|
||||||
|
display_obj.tft.println(ssid);
|
||||||
|
display_obj.tft.print("IP address: ");
|
||||||
|
display_obj.tft.print(WiFi.softAPIP());
|
||||||
|
display_obj.tft.print("\n");
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
Serial.println(WiFi.softAPIP());
|
Serial.println(WiFi.softAPIP());
|
||||||
|
|
||||||
@@ -69,6 +83,10 @@ void Web::setupOTAupdate()
|
|||||||
}, [this]() {
|
}, [this]() {
|
||||||
HTTPUpload& upload = server.upload();
|
HTTPUpload& upload = server.upload();
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
if (upload.status == UPLOAD_FILE_START) {
|
||||||
|
display_obj.tft.setTextColor(TFT_YELLOW);
|
||||||
|
display_obj.tft.print("Update: ");
|
||||||
|
display_obj.tft.print(upload.filename.c_str());
|
||||||
|
display_obj.tft.print("\n");
|
||||||
Serial.printf("Update: %s\n", upload.filename.c_str());
|
Serial.printf("Update: %s\n", upload.filename.c_str());
|
||||||
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
|
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
@@ -78,9 +96,32 @@ void Web::setupOTAupdate()
|
|||||||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
}
|
}
|
||||||
|
//display_obj.tft.println(upload.totalSize);
|
||||||
|
/*
|
||||||
|
String display_string = "";
|
||||||
|
display_obj.tft.setCursor(0, 164);
|
||||||
|
for (int i = 0; i < 40; i++) {
|
||||||
|
display_string.concat(" ");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
display_obj.tft.setTextColor(TFT_CYAN);
|
||||||
|
display_obj.tft.fillRect(0, 164, 240, 8, TFT_BLACK);
|
||||||
|
//delay(1);
|
||||||
|
//display_obj.tft.print(display_string);
|
||||||
|
display_obj.tft.setCursor(0, 164);
|
||||||
|
display_obj.tft.print("Bytes complete: ");
|
||||||
|
display_obj.tft.print(upload.totalSize);
|
||||||
|
display_obj.tft.print("\n");
|
||||||
|
|
||||||
|
//Serial.println(upload.totalSize);
|
||||||
} else if (upload.status == UPLOAD_FILE_END) {
|
} else if (upload.status == UPLOAD_FILE_END) {
|
||||||
if (Update.end(true)) { //true to set the size to the current progress
|
if (Update.end(true)) { //true to set the size to the current progress
|
||||||
|
display_obj.tft.setTextColor(TFT_GREEN);
|
||||||
|
display_obj.tft.print("Update Success: ");
|
||||||
|
display_obj.tft.print(upload.totalSize);
|
||||||
|
display_obj.tft.print("\nRebooting...\n");
|
||||||
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
|
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
|
||||||
|
delay(1000);
|
||||||
} else {
|
} else {
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
}
|
}
|
||||||
@@ -88,5 +129,7 @@ void Web::setupOTAupdate()
|
|||||||
});
|
});
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
|
display_obj.tft.setTextColor(TFT_GREEN);
|
||||||
|
display_obj.tft.println("\nCompleted update server setup");
|
||||||
Serial.println("Completed update server setup");
|
Serial.println("Completed update server setup");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ Code taken from espressif ESP32 OTA Update example
|
|||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <Update.h>
|
#include <Update.h>
|
||||||
|
|
||||||
|
#include "Display.h"
|
||||||
|
|
||||||
|
extern Display display_obj;
|
||||||
|
|
||||||
class Web
|
class Web
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -58,14 +58,17 @@ void loop()
|
|||||||
currentTime = millis();
|
currentTime = millis();
|
||||||
|
|
||||||
// Update all of our objects
|
// Update all of our objects
|
||||||
if ((!display_obj.draw_tft) &&
|
//if ((!display_obj.draw_tft) &&
|
||||||
(wifi_scan_obj.currentScanMode != OTA_UPDATE))
|
// (wifi_scan_obj.currentScanMode != OTA_UPDATE))
|
||||||
|
if (!display_obj.draw_tft)
|
||||||
{
|
{
|
||||||
display_obj.main();
|
display_obj.main();
|
||||||
wifi_scan_obj.main(currentTime);
|
wifi_scan_obj.main(currentTime);
|
||||||
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
|
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
|
||||||
if (wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR)
|
if (wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR)
|
||||||
menu_function_obj.main();
|
menu_function_obj.main();
|
||||||
|
if (wifi_scan_obj.currentScanMode == OTA_UPDATE)
|
||||||
|
web_obj.main();
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
else if ((display_obj.draw_tft) &&
|
else if ((display_obj.draw_tft) &&
|
||||||
@@ -73,10 +76,10 @@ void loop()
|
|||||||
{
|
{
|
||||||
display_obj.drawStylus();
|
display_obj.drawStylus();
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
web_obj.main();
|
// web_obj.main();
|
||||||
}
|
//}
|
||||||
|
|
||||||
//Serial.println(wifi_scan_obj.currentScanMode);
|
//Serial.println(wifi_scan_obj.currentScanMode);
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user