Skip to content

Commit

Permalink
Update display during OTA web update
Browse files Browse the repository at this point in the history
  • Loading branch information
justcallmekoko committed Jan 31, 2020
1 parent 9af90a2 commit f3d3a09
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 10 deletions.
15 changes: 12 additions & 3 deletions esp32_marauder/MenuFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ MenuFunctions::MenuFunctions()
// Function to check menu input
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) {
this->orientDisplay();
wifi_scan_obj.orient_display = false;
Expand All @@ -139,6 +140,9 @@ void MenuFunctions::main()
// getTouch causes a 10ms delay which makes beacon spam less effective
//if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF)
pressed = display_obj.tft.getTouch(&t_x, &t_y);

//if (pressed)
// Serial.println("Pressed, son");
//boolean pressed = false;

//Serial.print("getTouch: ");
Expand All @@ -147,7 +151,7 @@ void MenuFunctions::main()


// 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
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
Expand Down Expand Up @@ -238,6 +242,7 @@ void MenuFunctions::RunSetup()
wifiMenu.list = new SimpleList<MenuNode>(); // Get list in second menu ready
bluetoothMenu.list = new SimpleList<MenuNode>(); // Get list in third menu ready
generalMenu.list = new SimpleList<MenuNode>();
updateMenu.list = new SimpleList<MenuNode>();

// WiFi menu stuff
wifiSnifferMenu.list = new SimpleList<MenuNode>();
Expand All @@ -252,6 +257,7 @@ void MenuFunctions::RunSetup()
mainMenu.name = " ESP32 Marauder ";
wifiMenu.name = " WiFi ";
generalMenu.name = " General Apps ";
updateMenu.name = " Update Firmware ";
bluetoothMenu.name = " Bluetooth ";
wifiSnifferMenu.name = " WiFi Sniffers ";
wifiScannerMenu.name = " WiFi Scanners";
Expand All @@ -264,7 +270,7 @@ void MenuFunctions::RunSetup()
addNodes(&mainMenu, "WiFi", TFT_GREEN, NULL, WIFI, [this](){changeMenu(&wifiMenu);});
addNodes(&mainMenu, "Bluetooth", TFT_CYAN, NULL, BLUETOOTH, [this](){changeMenu(&bluetoothMenu);});
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();});

// Build WiFi Menu
Expand Down Expand Up @@ -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, "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
changeMenu(&mainMenu);
Expand Down
1 change: 1 addition & 0 deletions esp32_marauder/MenuFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class MenuFunctions
Menu wifiMenu;
Menu bluetoothMenu;
Menu generalMenu;
Menu updateMenu;

// WiFi menu stuff
Menu wifiSnifferMenu;
Expand Down
45 changes: 44 additions & 1 deletion esp32_marauder/Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@ void Web::main()

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...");

display_obj.tft.setTextColor(TFT_YELLOW);

// Start WiFi AP
WiFi.softAP(ssid, password);
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.println(WiFi.softAPIP());

Expand Down Expand Up @@ -69,6 +83,10 @@ void Web::setupOTAupdate()
}, [this]() {
HTTPUpload& upload = server.upload();
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());
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
Update.printError(Serial);
Expand All @@ -78,15 +96,40 @@ void Web::setupOTAupdate()
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
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) {
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);
delay(1000);
} else {
Update.printError(Serial);
}
}
});
server.begin();

display_obj.tft.setTextColor(TFT_GREEN);
display_obj.tft.println("\nCompleted update server setup");
Serial.println("Completed update server setup");
}
4 changes: 4 additions & 0 deletions esp32_marauder/Web.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Code taken from espressif ESP32 OTA Update example
#include <ESPmDNS.h>
#include <Update.h>

#include "Display.h"

extern Display display_obj;

class Web
{
private:
Expand Down
15 changes: 9 additions & 6 deletions esp32_marauder/esp32_marauder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,28 @@ void loop()
currentTime = millis();

// Update all of our objects
if ((!display_obj.draw_tft) &&
(wifi_scan_obj.currentScanMode != OTA_UPDATE))
//if ((!display_obj.draw_tft) &&
// (wifi_scan_obj.currentScanMode != OTA_UPDATE))
if (!display_obj.draw_tft)
{
display_obj.main();
wifi_scan_obj.main(currentTime);
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
if (wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR)
menu_function_obj.main();
if (wifi_scan_obj.currentScanMode == OTA_UPDATE)
web_obj.main();
delay(1);
}
else if ((display_obj.draw_tft) &&
(wifi_scan_obj.currentScanMode != OTA_UPDATE))
{
display_obj.drawStylus();
}
else
{
web_obj.main();
}
//else
//{
// web_obj.main();
//}

//Serial.println(wifi_scan_obj.currentScanMode);

Expand Down
Binary file modified esp32_marauder/esp32_marauder_v0_4_0_20200130.bin
Binary file not shown.

0 comments on commit f3d3a09

Please sign in to comment.