mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2026-07-28 14:47:16 -07:00
Start direct upload UI
This commit is contained in:
@@ -1494,6 +1494,49 @@ bool MenuFunctions::isKeyPressed(char c)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
void MenuFunctions::buildUploadFileMenu() {
|
||||
if (sd_obj.supported) {
|
||||
this->setupSDFileList();
|
||||
|
||||
uploadLogsMenu.list->clear();
|
||||
delete uploadLogsMenu.list;
|
||||
uploadLogsMenu.list = new LinkedList<MenuNode>();
|
||||
uploadLogsMenu.name = "Logs";
|
||||
|
||||
uploadLogsMenu.parentMenu = &wifiGeneralMenu;
|
||||
|
||||
this->addNodes(&uploadLogsMenu, "Back", TFTLIGHTGREY, 0, [this]() {
|
||||
this->changeMenu(uploadLogsMenu.parentMenu, true);
|
||||
});
|
||||
|
||||
this->addNodes(&uploadLogsMenu, "Delete Wardrive Logs", TFTORANGE, 0, [this]() {
|
||||
this->changeMenu(&deleteAllMenu, true);
|
||||
});
|
||||
|
||||
this->addNodes(&uploadLogsMenu, "Upload All", TFTGREEN, 0, [this]() {
|
||||
this->changeMenu(&uploadAllMenu, true);
|
||||
|
||||
});
|
||||
|
||||
for (int i = 0; i < sd_obj.sd_files->size(); i++) {
|
||||
File current_file = sd_obj.getFile("/" + sd_obj.sd_files->get(i));
|
||||
if (sd_obj.sd_files->get(i).startsWith("wardrive_") || sd_obj.sd_files->get(i).startsWith("wigle-")) {
|
||||
this->addNodes(&uploadLogsMenu, sd_obj.sd_files->get(i).c_str(), TFTCYAN, 0, [this, i]() {
|
||||
sd_obj.selected_file_name = sd_obj.sd_files->get(i);
|
||||
Serial.println(sd_obj.sd_files->get(i) + " selected");
|
||||
this->changeMenu(&actionMenu, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("Built SD file menu with " + (String)sd_obj.sd_files->size() + " files");
|
||||
} else {
|
||||
Serial.println("SD Card not detected. Skipping menu creation...");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Function to build the menus
|
||||
void MenuFunctions::RunSetup()
|
||||
{
|
||||
@@ -1567,6 +1610,13 @@ void MenuFunctions::RunSetup()
|
||||
clearAPsMenu.list = new LinkedList<MenuNode>();
|
||||
saveFileMenu.list = new LinkedList<MenuNode>();
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
uploadLogsMenu.list = new LinkedList<MenuNode>();
|
||||
uploadAllMenu.list = new LinkedList<MenuNode>();
|
||||
deleteAllMenu.list = new LinkedList<MenuNode>();
|
||||
actionMenu.list = new LinkedList<MenuNode>();
|
||||
#endif
|
||||
|
||||
saveSSIDsMenu.list = new LinkedList<MenuNode>();
|
||||
loadSSIDsMenu.list = new LinkedList<MenuNode>();
|
||||
saveAPsMenu.list = new LinkedList<MenuNode>();
|
||||
@@ -1616,6 +1666,14 @@ void MenuFunctions::RunSetup()
|
||||
setMacMenu.name = "Set MACs";
|
||||
genAPMacMenu.name = "Generate AP MAC";
|
||||
wifiStationMenu.name = "Select Stations";
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
uploadLogsMenu.name = "Upload Logs";
|
||||
uploadAllMenu.name = "Upload All?";
|
||||
deleteAllMenu.name = "Delete All?";
|
||||
actionMenu.name = "Destination";
|
||||
#endif
|
||||
|
||||
#ifdef HAS_GPS
|
||||
gpsMenu.name = "GPS";
|
||||
gpsInfoMenu.name = "GPS Data";
|
||||
@@ -2528,6 +2586,362 @@ void MenuFunctions::RunSetup()
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
this->changeMenu(current_menu, true);
|
||||
});
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
this->addNodes(&wifiGeneralMenu, "Upload Wardrive Logs", TFTGREEN, 0, [this]() {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Loading...");
|
||||
|
||||
this->buildUploadFileMenu();
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
});
|
||||
|
||||
uploadAllMenu.parentMenu = &uploadLogsMenu;
|
||||
this->addNodes(&uploadAllMenu, text09, TFTLIGHTGREY, 0, [this]() {
|
||||
this->changeMenu(uploadAllMenu.parentMenu, true);
|
||||
});
|
||||
this->addNodes(&uploadAllMenu, "WiGLE", TFTLIGHTGREY, 0, [this]() {
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
if ((ssid == "") && (pw == "")) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Could not connect to WiFi.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
delay(1000);
|
||||
for (int i = 0; i < sd_obj.sd_files->size(); i++) {
|
||||
if (sd_obj.sd_files->get(i).startsWith("wardrive_") || sd_obj.sd_files->get(i).startsWith("wigle-")) {
|
||||
Serial.println("Uploading " + sd_obj.sd_files->get(i) + "...");
|
||||
if (wifi_scan_obj.uploadFile("/" + sd_obj.sd_files->get(i), true, WIGLE_UPLOAD)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WiGLE OK", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WiGLE failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(uploadAllMenu.parentMenu, true);
|
||||
});
|
||||
this->addNodes(&uploadAllMenu, "WDGWars", TFTLIGHTGREY, 0, [this]() {
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
if ((ssid == "") && (pw == "")) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Could not connect to WiFi.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
delay(1000);
|
||||
for (int i = 0; i < sd_obj.sd_files->size(); i++) {
|
||||
if (sd_obj.sd_files->get(i).startsWith("wardrive_") || sd_obj.sd_files->get(i).startsWith("wigle-")) {
|
||||
Serial.println("Uploading " + sd_obj.sd_files->get(i) + "...");
|
||||
if (wifi_scan_obj.uploadFile("/" + sd_obj.sd_files->get(i), true, WDG_UPLOAD)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WDG OK", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WDG failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(uploadAllMenu.parentMenu, true);
|
||||
});
|
||||
this->addNodes(&uploadAllMenu, "Both", TFTLIGHTGREY, 0, [this]() {
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
if ((ssid == "") && (pw == "")) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Could not connect to WiFi.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
delay(1000);
|
||||
for (int i = 0; i < sd_obj.sd_files->size(); i++) {
|
||||
if (sd_obj.sd_files->get(i).startsWith("wardrive_") || sd_obj.sd_files->get(i).startsWith("wigle-")) {
|
||||
Serial.println("Uploading " + sd_obj.sd_files->get(i) + "...");
|
||||
if (wifi_scan_obj.uploadFile("/" + sd_obj.sd_files->get(i), true, BOTH_UPLOAD)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("Upload OK", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("Upload failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(uploadAllMenu.parentMenu, true);
|
||||
});
|
||||
|
||||
deleteAllMenu.parentMenu = &uploadLogsMenu;
|
||||
this->addNodes(&deleteAllMenu, "No", TFTLIGHTGREY, 0, [this]() {
|
||||
this->changeMenu(deleteAllMenu.parentMenu, true);
|
||||
});
|
||||
this->addNodes(&deleteAllMenu, "Yes", TFTRED, 0, [this]() {
|
||||
display_obj.clearScreen();
|
||||
|
||||
display_obj.tft.drawCentreString("Deleting Logs...",TFT_WIDTH / 2, TFT_HEIGHT / 2, 2);
|
||||
|
||||
for (int i = 0; i < sd_obj.sd_files->size(); i++) {
|
||||
if (sd_obj.sd_files->get(i).startsWith("wardrive_") || sd_obj.sd_files->get(i).startsWith("wigle-")) {
|
||||
if (sd_obj.removeFile("/" + sd_obj.sd_files->get(i))) {
|
||||
Serial.println("Removed file: " + sd_obj.sd_files->get(i));
|
||||
sd_obj.removeFile("/" + sd_obj.sd_files->get(i) + ".wdg");
|
||||
sd_obj.removeFile("/" + sd_obj.sd_files->get(i) + ".wigle");
|
||||
}
|
||||
else {
|
||||
Serial.println("Could not remove file: " + sd_obj.sd_files->get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
display_obj.clearScreen();
|
||||
|
||||
display_obj.tft.drawCentreString("Logs removed",TFT_WIDTH / 2, TFT_HEIGHT / 2, 2);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->buildUploadFileMenu();
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
});
|
||||
|
||||
actionMenu.parentMenu = &uploadLogsMenu;
|
||||
this->addNodes(&actionMenu, text09, TFTLIGHTGREY, 0, [this]() {
|
||||
this->changeMenu(actionMenu.parentMenu, true);
|
||||
});
|
||||
this->addNodes(&actionMenu, "WiGLE", TFTLIGHTGREY, 0, [this]() {
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
if ((ssid == "") && (pw == "")) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Could not connect to WiFi.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
delay(1000);
|
||||
Serial.println("Uploading " + sd_obj.selected_file_name + "...");
|
||||
if (wifi_scan_obj.uploadFile("/" + sd_obj.selected_file_name, true, WIGLE_UPLOAD)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WiGLE OK", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WiGLE failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&actionMenu, true);
|
||||
});
|
||||
this->addNodes(&actionMenu, "WDGWars", TFTLIGHTGREY, 0, [this]() {
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
if ((ssid == "") && (pw == "")) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Could not connect to WiFi.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
delay(1000);
|
||||
Serial.println("Uploading " + sd_obj.selected_file_name + "...");
|
||||
if (wifi_scan_obj.uploadFile("/" + sd_obj.selected_file_name, true, WDG_UPLOAD)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WDG OK", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WDG failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&actionMenu, true);
|
||||
});
|
||||
this->addNodes(&actionMenu, "Both", TFTLIGHTGREY, 0, [this]() {
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
if ((ssid == "") && (pw == "")) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.tft.println("Could not connect to WiFi.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
delay(1000);
|
||||
Serial.println("Uploading " + sd_obj.selected_file_name + "...");
|
||||
if (wifi_scan_obj.uploadFile("/" + sd_obj.selected_file_name, true, BOTH_UPLOAD)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("Upload OK", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("Upload failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&actionMenu, true);
|
||||
});
|
||||
#endif
|
||||
|
||||
|
||||
// Menu for generating and setting MAC addrs for AP and STA
|
||||
|
||||
@@ -198,10 +198,16 @@ class MenuFunctions
|
||||
|
||||
Menu foxHuntMenu;
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
Menu deleteAllMenu;
|
||||
Menu uploadAllMenu;
|
||||
#endif
|
||||
|
||||
//static void lv_tick_handler();
|
||||
|
||||
// Menu icons
|
||||
|
||||
void buildUploadFileMenu();
|
||||
void setupSDFileList(bool update = false);
|
||||
void buildSDFileMenu(bool update = false);
|
||||
void displayMenuButtons();
|
||||
@@ -264,6 +270,11 @@ class MenuFunctions
|
||||
Menu infoMenu;
|
||||
Menu apInfoMenu;
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
Menu uploadLogsMenu;
|
||||
Menu actionMenu;
|
||||
#endif
|
||||
|
||||
//Ticker tick;
|
||||
|
||||
uint16_t x = -1, y = -1;
|
||||
|
||||
@@ -56,6 +56,7 @@ class SDInterface {
|
||||
bool supported = false;
|
||||
|
||||
String card_sz;
|
||||
String selected_file_name = "";
|
||||
|
||||
bool initSD();
|
||||
|
||||
|
||||
+99
-31
@@ -10016,31 +10016,101 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
}
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
bool WiFiScan::sidecarExists(String filePath, String service) {
|
||||
return SD.exists(filePath + "." + service);
|
||||
}
|
||||
|
||||
void WiFiScan::writeSidecar(String filePath, String service) {
|
||||
String sidecarPath = filePath + "." + service;
|
||||
File f = SD.open(sidecarPath, FILE_WRITE);
|
||||
if (f) {
|
||||
f.println("uploaded=" + gps_obj.getDatetime());
|
||||
f.close();
|
||||
Serial.println("[UPLOAD] Sidecar written: " + sidecarPath);
|
||||
} else {
|
||||
Serial.println("[UPLOAD] Could not write sidecar: " + sidecarPath);
|
||||
}
|
||||
}
|
||||
|
||||
bool WiFiScan::uploadFile(String filePath, bool retry, uint8_t upload_type) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Uploading " + filePath).c_str(), TFT_HEIGHT / 2);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("[UPLOAD] uploadFile: " + filePath +
|
||||
(retry ? " (retry)" : ""));
|
||||
|
||||
bool wigle_already = !retry && this->sidecarExists(filePath, "wigle");
|
||||
bool wdg_already = !retry && this->sidecarExists(filePath, "wdg");
|
||||
|
||||
bool wigle_ok = wigle_already;
|
||||
bool wdg_ok = wdg_already;
|
||||
|
||||
if ((upload_type == WIGLE_UPLOAD) || (upload_type == BOTH_UPLOAD)) {
|
||||
if (!wigle_already) {
|
||||
Serial.println("[UPLOAD] Uploading to WiGLE: " + filePath);
|
||||
wigle_ok = this->wigleUpload(filePath);
|
||||
if (wigle_ok) {
|
||||
this->writeSidecar(filePath, "wigle");
|
||||
Serial.println("[UPLOAD] WiGLE upload succeeded");
|
||||
} else {
|
||||
Serial.println("[UPLOAD] WiGLE upload failed");
|
||||
}
|
||||
} else {
|
||||
Serial.println("[UPLOAD] WiGLE already uploaded, skipping");
|
||||
}
|
||||
}
|
||||
|
||||
if ((upload_type == WDG_UPLOAD) || (upload_type == BOTH_UPLOAD)) {
|
||||
if (!wdg_already) {
|
||||
Serial.println("[UPLOAD] Uploading to WDG Wars: " + filePath);
|
||||
wdg_ok = this->wdgwarsUpload(filePath);
|
||||
if (wdg_ok) {
|
||||
this->writeSidecar(filePath, "wdg");
|
||||
Serial.println("[UPLOAD] WDG Wars upload succeeded");
|
||||
} else {
|
||||
Serial.println("[UPLOAD] WDG Wars upload failed");
|
||||
}
|
||||
} else {
|
||||
Serial.println("[UPLOAD] WDG Wars already uploaded, skipping");
|
||||
}
|
||||
}
|
||||
|
||||
if (upload_type == WIGLE_UPLOAD)
|
||||
return wigle_ok;
|
||||
else if (upload_type == WDG_UPLOAD)
|
||||
return wdg_ok;
|
||||
else if (upload_type == BOTH_UPLOAD)
|
||||
return wigle_ok && wdg_ok;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Upload one log file to WDG Wars.
|
||||
// Mirrors backendUpload() but uses X-API-Key auth and wdgwars.pl endpoint.
|
||||
bool WiFiScan::wdgwarsUpload(String filePath) {
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("WDG Upload...", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("WDG Upload...", TFT_HEIGHT / 2);
|
||||
delay(100);
|
||||
|
||||
if (!SD.exists(filePath)) {
|
||||
//display.drawCenteredText(filePath + " not found", true);
|
||||
display_obj.showCenterText(String(filePath + " not found").c_str(), TFT_HEIGHT / 2);
|
||||
Serial.println("[WDG] File not found: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
String apiKey = settings_obj.loadSetting<String>(WDG_KEY_NAME);
|
||||
if (apiKey.isEmpty()) {
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("No WDG API key", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("No WDG API key", TFT_HEIGHT / 2);
|
||||
Serial.println("[WDG] No WDG Wars API key configured");
|
||||
return false;
|
||||
}
|
||||
|
||||
File fileToUpload = SD.open(filePath);
|
||||
if (!fileToUpload) {
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("Could not open file", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Could not open file", TFT_HEIGHT / 2);
|
||||
Serial.println("[WDG] Could not open: " + filePath);
|
||||
return false;
|
||||
}
|
||||
@@ -10061,8 +10131,8 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
if (!client->connect("wdgwars.pl", 443)) {
|
||||
fileToUpload.close();
|
||||
client->stop();
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("WDG connect fail", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("WDG connect fail", TFT_HEIGHT / 2);
|
||||
Serial.println("[WDG] Failed to connect to wdgwars.pl");
|
||||
return false;
|
||||
}
|
||||
@@ -10092,10 +10162,10 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
totalSent += n;
|
||||
client->write(buf, n);
|
||||
pct = (totalSent * 100) / fileToUpload.size();
|
||||
//display.tft->drawRect(0, (TFT_HEIGHT / 3) * 2, TFT_WIDTH, TFT_HEIGHT - (TFT_HEIGHT / 3) * 2, ST77XX_BLACK);
|
||||
//display.tft->setCursor(0, (TFT_HEIGHT / 3) * 2);
|
||||
display_obj.tft.drawRect(0, (TFT_HEIGHT / 3) * 2, TFT_WIDTH, TFT_HEIGHT - (TFT_HEIGHT / 3) * 2, TFT_BLACK);
|
||||
display_obj.tft.setCursor(0, (TFT_HEIGHT / 3) * 2);
|
||||
pctStr = String(pct) + "%";
|
||||
//display.drawCenteredText(pctStr, false);
|
||||
display_obj.showCenterText(pctStr.c_str(), TFT_HEIGHT / 2);
|
||||
}
|
||||
|
||||
client->print(part2);
|
||||
@@ -10124,8 +10194,8 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
bool ok = response.indexOf("202 Accepted") >= 0 ||
|
||||
response.indexOf("\"ok\":true") >= 0;
|
||||
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText(ok ? "WDG OK" : "WDG Failed", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(ok ? "WDG OK" : "WDG Failed", TFT_HEIGHT / 2);
|
||||
delay(1000);
|
||||
|
||||
return ok;
|
||||
@@ -10133,24 +10203,22 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
|
||||
// Upload one log file to Wigle
|
||||
bool WiFiScan::wigleUpload(String filePath) {
|
||||
//server.begin();
|
||||
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("Wigle Upload...", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Wigle Upload...", TFT_HEIGHT / 2);
|
||||
|
||||
delay(100);
|
||||
|
||||
if (!SD.exists(filePath)) {
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText(filePath + " not found", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String(filePath + " not found").c_str(), TFT_HEIGHT / 2);
|
||||
Serial.println("File does not exist: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
File fileToUpload = SD.open(filePath);
|
||||
if (!fileToUpload) {
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("Could not open file", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Could not open file", TFT_HEIGHT / 2);
|
||||
Serial.println("Could not open file: " + filePath);
|
||||
return false;
|
||||
}
|
||||
@@ -10160,8 +10228,8 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
String token = settings_obj.loadSetting<String>("wt");
|
||||
if (username.isEmpty() || token.isEmpty()) {
|
||||
fileToUpload.close();
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("No wigle creds", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("No wigle creds", TFT_HEIGHT / 2);
|
||||
Serial.println("Missing wigle credentials");
|
||||
return false;
|
||||
}
|
||||
@@ -10202,8 +10270,8 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
fileToUpload.close();
|
||||
//delete client;
|
||||
client->stop();
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText("Could not connect", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Could not connect", TFT_HEIGHT / 2);
|
||||
Serial.println("Failed to connected to api.wigle.net");
|
||||
return false;
|
||||
}
|
||||
@@ -10247,10 +10315,10 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
Serial.print(totalBytesSent);
|
||||
Serial.println(" bytes...");
|
||||
percent_sent = (totalBytesSent * 100) / fileToUpload.size();
|
||||
//display.tft->drawRect(0, (TFT_HEIGHT / 3) * 2, TFT_WIDTH, TFT_HEIGHT, ST77XX_BLACK);
|
||||
//display.tft->setCursor(0, (TFT_HEIGHT / 3) * 2);
|
||||
display_obj.tft.drawRect(0, (TFT_HEIGHT / 3) * 2, TFT_WIDTH, TFT_HEIGHT, TFT_BLACK);
|
||||
display_obj.tft.setCursor(0, (TFT_HEIGHT / 3) * 2);
|
||||
display_percent = (String)percent_sent + "%";
|
||||
//display.drawCenteredText(display_percent, false);
|
||||
display_obj.showCenterText(display_percent.c_str(), TFT_HEIGHT / 2);
|
||||
client->write(buffer, bytesRead);
|
||||
}
|
||||
|
||||
@@ -10286,8 +10354,8 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
|
||||
bool ok = response.indexOf("200 OK") >= 0;
|
||||
|
||||
//display.clearScreen();
|
||||
//display.drawCenteredText(ok ? "WIGLE OK" : "WIGLE Failed", true);
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(ok ? "WIGLE OK" : "WIGLE Failed", TFT_HEIGHT / 2);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -216,6 +216,10 @@
|
||||
#define CLEAR_SSID 7
|
||||
#define CLEAR_BLE 8
|
||||
|
||||
#define WIGLE_UPLOAD 0
|
||||
#define WDG_UPLOAD 1
|
||||
#define BOTH_UPLOAD 2
|
||||
|
||||
extern EvilPortal evil_portal_obj;
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
@@ -605,6 +609,8 @@ class WiFiScan
|
||||
|
||||
bool wigleUpload(String filePath);
|
||||
bool wdgwarsUpload(String filePath);
|
||||
void writeSidecar(String filePath, String service);
|
||||
bool sidecarExists(String filePath, String service);
|
||||
|
||||
void runFoxHunt(uint32_t currentTime);
|
||||
void throwThatShitInACircle();
|
||||
@@ -879,6 +885,7 @@ class WiFiScan
|
||||
|
||||
wifi_config_t ap_config;
|
||||
|
||||
bool uploadFile(String filePath, bool retry = false, uint8_t upload_type = WIGLE_UPLOAD);
|
||||
String checkEmptyProbe(String essid);
|
||||
bool checkFlockOUI(const uint8_t mac[6]);
|
||||
bool startWiFi(String ssid, String password, bool gui = true);
|
||||
|
||||
@@ -494,6 +494,7 @@
|
||||
//#define HAS_TEMP_SENSOR
|
||||
#define HAS_NIMBLE_2
|
||||
#define HAS_IDF_3
|
||||
//#define HAS_DIRECT_UPLOAD
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_V8
|
||||
@@ -517,6 +518,7 @@
|
||||
#define HAS_NIMBLE_2
|
||||
#define HAS_IDF_3
|
||||
#define HAS_ACT_LED
|
||||
#define HAS_DIRECT_UPLOAD
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_PANCAKE
|
||||
|
||||
Reference in New Issue
Block a user