mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2026-07-28 22:51:08 -07:00
Add wdg/wigle api settings, fix upload UI
This commit is contained in:
@@ -2616,12 +2616,10 @@ void MenuFunctions::RunSetup()
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Connecting to " + ssid).c_str(), TFT_HEIGHT / 2);
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
@@ -2630,10 +2628,6 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
@@ -2642,13 +2636,16 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
display_obj.showCenterText("WiGLE OK", TFT_HEIGHT / 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WiGLE failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
display_obj.showCenterText("WiGLE failed", TFT_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
WiFi.disconnect(true);
|
||||
delay(100);
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2668,12 +2665,10 @@ void MenuFunctions::RunSetup()
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Connecting to " + ssid).c_str(), TFT_HEIGHT / 2);
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
@@ -2682,10 +2677,6 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
@@ -2694,13 +2685,16 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
display_obj.showCenterText("WDG OK", TFT_HEIGHT / 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WDG failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
display_obj.showCenterText("WDG failed", TFT_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
WiFi.disconnect(true);
|
||||
delay(100);
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2720,12 +2714,10 @@ void MenuFunctions::RunSetup()
|
||||
display_obj.tft.println("WiFi Credentials Empty.");
|
||||
display_obj.tft.println("Returning...");
|
||||
display_obj.tft.setTextWrap(false);
|
||||
|
||||
delay(2000);
|
||||
|
||||
this->changeMenu(&uploadLogsMenu, true);
|
||||
}
|
||||
else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Connecting to " + ssid).c_str(), TFT_HEIGHT / 2);
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
@@ -2734,10 +2726,6 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
@@ -2746,13 +2734,16 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
display_obj.showCenterText("Upload OK", TFT_HEIGHT / 2);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("Upload failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
display_obj.showCenterText("Upload failed", TFT_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
WiFi.disconnect(true);
|
||||
delay(100);
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2801,20 +2792,19 @@ void MenuFunctions::RunSetup()
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
|
||||
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 {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Connecting to " + ssid).c_str(), TFT_HEIGHT / 2, true);
|
||||
if (!wifi_scan_obj.joinWiFi(ssid, pw, false)) {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.setTextWrap(true);
|
||||
@@ -2823,21 +2813,21 @@ void MenuFunctions::RunSetup()
|
||||
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);
|
||||
display_obj.showCenterText("WiGLE OK", TFT_HEIGHT / 2, true);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WiGLE failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
display_obj.showCenterText("WiGLE failed", TFT_HEIGHT / 2, true);
|
||||
}
|
||||
|
||||
WiFi.disconnect(true);
|
||||
delay(100);
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2849,43 +2839,41 @@ void MenuFunctions::RunSetup()
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
|
||||
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 {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Connecting to " + ssid).c_str(), TFT_HEIGHT / 2, true);
|
||||
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);
|
||||
display_obj.showCenterText("WDG OK", TFT_HEIGHT / 2, true);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("WDG failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
display_obj.showCenterText("WDG failed", TFT_HEIGHT / 2, true);
|
||||
}
|
||||
|
||||
WiFi.disconnect(true);
|
||||
delay(100);
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2897,43 +2885,41 @@ void MenuFunctions::RunSetup()
|
||||
String ssid = settings_obj.loadSetting<String>("ClientSSID");
|
||||
String pw = settings_obj.loadSetting<String>("ClientPW");
|
||||
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
|
||||
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 {
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Connecting to " + ssid).c_str(), TFT_HEIGHT / 2, true);
|
||||
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);
|
||||
display_obj.showCenterText("Upload OK", TFT_HEIGHT / 2, true);
|
||||
} else {
|
||||
display_obj.clearScreen();
|
||||
display_obj.tft.drawCentreString("Upload failed", TFT_WIDTH / 2, TFT_WIDTH / 2, 2);
|
||||
display_obj.showCenterText("Upload failed", TFT_HEIGHT / 2, true);
|
||||
}
|
||||
|
||||
WiFi.disconnect(true);
|
||||
delay(100);
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+185
-28
@@ -1629,6 +1629,77 @@ void WiFiScan::RunSetup() {
|
||||
|
||||
settings_obj.loadSetting<bool>("ChanHop");
|
||||
|
||||
File api_settings_file;
|
||||
|
||||
#ifdef HAS_SD
|
||||
if (sd_obj.supported) {
|
||||
if (SD.exists("/wigle_api_name.txt")) {
|
||||
String contents = "";
|
||||
api_settings_file = sd_obj.getFile("/wigle_api_name.txt");
|
||||
while (api_settings_file.available()) {
|
||||
contents+=(char)api_settings_file.read();
|
||||
}
|
||||
|
||||
while (contents.length() > 0) {
|
||||
char c = contents[contents.length() - 1];
|
||||
if (c == '\n' || c == '\r')
|
||||
contents.remove(contents.length() - 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
settings_obj.saveSetting<bool>("wu", contents);
|
||||
api_settings_file.close();
|
||||
sd_obj.removeFile("/wigle_api_name.txt");
|
||||
Serial.println("Saved WiGLE API Name: " + contents);
|
||||
}
|
||||
|
||||
if (SD.exists("/wigle_api_token.txt")) {
|
||||
String contents = "";
|
||||
api_settings_file = sd_obj.getFile("/wigle_api_token.txt");
|
||||
while (api_settings_file.available()) {
|
||||
contents+=(char)api_settings_file.read();
|
||||
}
|
||||
|
||||
while (contents.length() > 0) {
|
||||
char c = contents[contents.length() - 1];
|
||||
if (c == '\n' || c == '\r')
|
||||
contents.remove(contents.length() - 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
settings_obj.saveSetting<bool>("wt", contents);
|
||||
api_settings_file.close();
|
||||
sd_obj.removeFile("/wigle_api_token.txt");
|
||||
Serial.println("Saved WiGLE API Token: " + contents);
|
||||
}
|
||||
|
||||
if (SD.exists("/wdg_key.txt")) {
|
||||
String contents = "";
|
||||
api_settings_file = sd_obj.getFile("/wdg_key.txt");
|
||||
while (api_settings_file.available()) {
|
||||
contents+=(char)api_settings_file.read();
|
||||
}
|
||||
|
||||
while (contents.length() > 0) {
|
||||
char c = contents[contents.length() - 1];
|
||||
if (c == '\n' || c == '\r')
|
||||
contents.remove(contents.length() - 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
settings_obj.saveSetting<bool>(WDG_KEY_NAME, contents);
|
||||
api_settings_file.close();
|
||||
sd_obj.removeFile("/wdg_key.txt");
|
||||
Serial.println("Saved WDG API Token: " + contents);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PSRAM
|
||||
mac_history = (struct mac_addr*) ps_malloc(mac_history_len * sizeof(struct mac_addr));
|
||||
#endif
|
||||
@@ -1902,8 +1973,9 @@ bool WiFiScan::joinWiFi(String ssid, String password, bool gui) {
|
||||
}
|
||||
}
|
||||
this->connected_network = ssid;
|
||||
this->setNetworkInfo();
|
||||
this->showNetworkInfo();
|
||||
this->setNetworkInfo();
|
||||
if (gui)
|
||||
this->showNetworkInfo();
|
||||
|
||||
this->wifi_initialized = true;
|
||||
#ifndef HAS_TOUCH
|
||||
@@ -10033,8 +10105,10 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
}
|
||||
|
||||
bool WiFiScan::uploadFile(String filePath, bool retry, uint8_t upload_type) {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String("Uploading " + filePath).c_str(), TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText(String("Uploading " + filePath).c_str(), TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
delay(1000);
|
||||
|
||||
Serial.println("[UPLOAD] uploadFile: " + filePath +
|
||||
@@ -10089,28 +10163,41 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
// Upload one log file to WDG Wars.
|
||||
// Mirrors backendUpload() but uses X-API-Key auth and wdgwars.pl endpoint.
|
||||
bool WiFiScan::wdgwarsUpload(String filePath) {
|
||||
bool gotAny = false;
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("WDG Upload...", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("WDG Upload...", TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
delay(100);
|
||||
|
||||
if (!SD.exists(filePath)) {
|
||||
display_obj.showCenterText(String(filePath + " not found").c_str(), TFT_HEIGHT / 2);
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.showCenterText(String(filePath + " not found").c_str(), TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("[WDG] File not found: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
String apiKey = settings_obj.loadSetting<String>(WDG_KEY_NAME);
|
||||
if (apiKey.isEmpty()) {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("No WDG API key", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("No WDG API key", TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("[WDG] No WDG Wars API key configured");
|
||||
return false;
|
||||
}
|
||||
|
||||
File fileToUpload = SD.open(filePath);
|
||||
if (!fileToUpload) {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Could not open file", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("Could not open file", TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("[WDG] Could not open: " + filePath);
|
||||
return false;
|
||||
}
|
||||
@@ -10128,11 +10215,16 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
Serial.println("[WDG] Total length: " + String(totalLength));
|
||||
|
||||
client->setInsecure();
|
||||
client->setTimeout(5000);
|
||||
|
||||
if (!client->connect("wdgwars.pl", 443)) {
|
||||
fileToUpload.close();
|
||||
client->stop();
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("WDG connect fail", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("WDG connect fail", TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("[WDG] Failed to connect to wdgwars.pl");
|
||||
return false;
|
||||
}
|
||||
@@ -10162,28 +10254,47 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
totalSent += n;
|
||||
client->write(buf, n);
|
||||
pct = (totalSent * 100) / fileToUpload.size();
|
||||
#ifdef HAS_SCREEN
|
||||
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);
|
||||
#endif
|
||||
pctStr = String(pct) + "%";
|
||||
display_obj.showCenterText(pctStr.c_str(), TFT_HEIGHT / 2);
|
||||
int bar_width = (TFT_WIDTH * pct) / 100;
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.tft.fillRect(0, (TFT_HEIGHT / 4) * 3, bar_width, 20, TFT_GREEN);
|
||||
//display_obj.showCenterText(pctStr.c_str(), TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
client->print(part2);
|
||||
client->flush();
|
||||
fileToUpload.close();
|
||||
|
||||
Serial.println("[WDG] Bytes sent: " + String(totalSent));
|
||||
|
||||
display_obj.showCenterText("Waiting for response...", (TFT_HEIGHT / 3) * 2, true);
|
||||
|
||||
// Read response
|
||||
String response;
|
||||
unsigned long t = millis();
|
||||
while (millis() - t < 5000) {
|
||||
while (client->available()) {
|
||||
gotAny = true;
|
||||
char c = client->read();
|
||||
Serial.print(c);
|
||||
response += c;
|
||||
}
|
||||
if (!client->connected() && !client->available())
|
||||
//if (!client->connected() && !client->available())
|
||||
// break;
|
||||
if (gotAny && !client->connected()) {
|
||||
break;
|
||||
}
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
|
||||
client->stop();
|
||||
|
||||
// Capture first 200 chars of response for log viewer
|
||||
@@ -10193,9 +10304,14 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
// WDG Wars returns 200 on success
|
||||
bool ok = response.indexOf("202 Accepted") >= 0 ||
|
||||
response.indexOf("\"ok\":true") >= 0;
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(ok ? "WDG OK" : "WDG Failed", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText(ok ? "WDG OK" : "WDG Failed", TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
|
||||
if (!ok)
|
||||
Serial.println(response);
|
||||
|
||||
delay(1000);
|
||||
|
||||
return ok;
|
||||
@@ -10203,22 +10319,32 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
|
||||
// Upload one log file to Wigle
|
||||
bool WiFiScan::wigleUpload(String filePath) {
|
||||
bool gotAny = false;
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Wigle Upload...", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("Wigle Upload...", TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
|
||||
delay(100);
|
||||
|
||||
if (!SD.exists(filePath)) {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(String(filePath + " not found").c_str(), TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText(String(filePath + " not found").c_str(), TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("File does not exist: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
File fileToUpload = SD.open(filePath);
|
||||
if (!fileToUpload) {
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Could not open file", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("Could not open file", TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("Could not open file: " + filePath);
|
||||
return false;
|
||||
}
|
||||
@@ -10228,14 +10354,17 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
String token = settings_obj.loadSetting<String>("wt");
|
||||
if (username.isEmpty() || token.isEmpty()) {
|
||||
fileToUpload.close();
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("No wigle creds", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("No wigle creds", TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("Missing wigle credentials");
|
||||
return false;
|
||||
}
|
||||
|
||||
Serial.println("Username: " + username);
|
||||
Serial.println("Token: " + token);
|
||||
//Serial.println("Username: " + username);
|
||||
//Serial.println("Token: " + token);
|
||||
|
||||
String boundary = "----ESP32BOUNDARY";
|
||||
String contentType = "multipart/form-data; boundary=" + boundary;
|
||||
@@ -10261,17 +10390,18 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
Serial.print("File size: ");
|
||||
Serial.println(fileToUpload.size());
|
||||
|
||||
// Connect manually via WiFiClientSecure
|
||||
//WiFiClientSecure *client = new WiFiClientSecure();
|
||||
//client.stop();
|
||||
client->setInsecure();
|
||||
client->setTimeout(5000);
|
||||
|
||||
if (!client->connect("api.wigle.net", 443)) {
|
||||
fileToUpload.close();
|
||||
//delete client;
|
||||
client->stop();
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText("Could not connect", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText("Could not connect", TFT_HEIGHT / 2, true);
|
||||
delay(2000);
|
||||
#endif
|
||||
Serial.println("Failed to connected to api.wigle.net");
|
||||
return false;
|
||||
}
|
||||
@@ -10315,10 +10445,16 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
Serial.print(totalBytesSent);
|
||||
Serial.println(" bytes...");
|
||||
percent_sent = (totalBytesSent * 100) / fileToUpload.size();
|
||||
int bar_width = (TFT_WIDTH * percent_sent) / 100;
|
||||
#ifdef HAS_SCREEN
|
||||
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_obj.showCenterText(display_percent.c_str(), TFT_HEIGHT / 2);
|
||||
#endif
|
||||
//display_percent = (String)percent_sent + "%";
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.tft.fillRect(0, (TFT_HEIGHT / 4) * 3, bar_width, 20, TFT_GREEN);
|
||||
//display_obj.showCenterText(display_percent.c_str(), TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
client->write(buffer, bytesRead);
|
||||
}
|
||||
|
||||
@@ -10326,23 +10462,40 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
|
||||
client->print(part2);
|
||||
client->print(part3);
|
||||
client->flush();
|
||||
|
||||
Serial.println("Finished sending part2 and part3");
|
||||
|
||||
fileToUpload.close();
|
||||
display_obj.showCenterText("Waiting for response...", (TFT_HEIGHT / 3) * 2, true);
|
||||
|
||||
fileToUpload.close();
|
||||
|
||||
// Read response
|
||||
String response;
|
||||
unsigned long timeout = millis();
|
||||
while (millis() - timeout < 5000) {
|
||||
while (client->available()) {
|
||||
gotAny = true;
|
||||
char c = client->read();
|
||||
Serial.print(c);
|
||||
response += c;
|
||||
}
|
||||
|
||||
if (gotAny && !client->connected()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
if (millis() - timeout > 5000)
|
||||
Serial.println();
|
||||
|
||||
if (!gotAny) {
|
||||
Serial.println("[WIGLE] No response bytes received");
|
||||
}
|
||||
|
||||
if (millis() - timeout >= 5000)
|
||||
Serial.println("Timeout reached");
|
||||
if (!client->connected())
|
||||
Serial.println("Client disconnected");
|
||||
@@ -10353,9 +10506,13 @@ uint16_t WiFiScan::rssiToColor(int8_t rssi) {
|
||||
Serial.println("[WIGLE] Response: " + respTrunc);
|
||||
|
||||
bool ok = response.indexOf("200 OK") >= 0;
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
display_obj.clearScreen();
|
||||
display_obj.showCenterText(ok ? "WIGLE OK" : "WIGLE Failed", TFT_HEIGHT / 2);
|
||||
display_obj.showCenterText(ok ? "WIGLE OK" : "WIGLE Failed", TFT_HEIGHT / 2, true);
|
||||
#endif
|
||||
|
||||
if (!ok)
|
||||
Serial.println(response);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
|
||||
#ifdef HAS_DIRECT_UPLOAD
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <HTTPClient.h>
|
||||
#include "mbedtls/sha256.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@
|
||||
#define HAS_NIMBLE_2
|
||||
#define HAS_IDF_3
|
||||
//#define HAS_SIMPLEX_DISPLAY
|
||||
//#define HAS_DIRECT_UPLOAD
|
||||
#define HAS_DIRECT_UPLOAD
|
||||
#endif
|
||||
|
||||
#if defined(MARAUDER_M5_NANO_C6)
|
||||
|
||||
@@ -32,6 +32,12 @@ void Settings::_buildCache() {
|
||||
_cache.ClientSSID = json["Settings"][i]["value"].as<String>();
|
||||
else if (strcmp(name, "ClientPW") == 0)
|
||||
_cache.ClientPW = json["Settings"][i]["value"].as<String>();
|
||||
else if (strcmp(name, "wu") == 0)
|
||||
_cache.wu = json["Settings"][i]["value"].as<String>();
|
||||
else if (strcmp(name, "wt") == 0)
|
||||
_cache.wt = json["Settings"][i]["value"].as<String>();
|
||||
else if (strcmp(name, WDG_KEY_NAME) == 0)
|
||||
_cache.wdg_key = json["Settings"][i]["value"].as<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +113,14 @@ template <> int Settings::loadSetting<int>(const char* key) {
|
||||
template <> String Settings::loadSetting<String>(const char* key) {
|
||||
if (strcmp(key, "ClientSSID") == 0)
|
||||
return _cache.ClientSSID;
|
||||
|
||||
if (strcmp(key, "ClientPW") == 0)
|
||||
return _cache.ClientPW;
|
||||
if (strcmp(key, "wu") == 0)
|
||||
return _cache.wu;
|
||||
if (strcmp(key, "wt") == 0)
|
||||
return _cache.wt;
|
||||
if (strcmp(key, WDG_KEY_NAME) == 0)
|
||||
return _cache.wdg_key;
|
||||
|
||||
// Unknown String key: fall back to JSON so the setting can be auto-created.
|
||||
DynamicJsonDocument json(JSON_SETTING_SIZE);
|
||||
@@ -302,6 +313,12 @@ template <> bool Settings::saveSetting<bool>(const char* key, String value) {
|
||||
_cache.ClientSSID = value;
|
||||
else if (strcmp(key, "ClientPW") == 0)
|
||||
_cache.ClientPW = value;
|
||||
else if (strcmp(key, "wu") == 0)
|
||||
_cache.wu = value;
|
||||
else if (strcmp(key, "wt") == 0)
|
||||
_cache.wt = value;
|
||||
else if (strcmp(key, WDG_KEY_NAME) == 0)
|
||||
_cache.wdg_key = value;
|
||||
|
||||
this->printJsonSettings(settings_string);
|
||||
|
||||
|
||||
@@ -27,14 +27,17 @@ class Settings {
|
||||
// Flat cache populated once at begin() and kept in sync by saveSetting().
|
||||
// All loadSetting<T>() reads hit this struct — zero heap, zero JSON parse.
|
||||
struct SettingsCache {
|
||||
bool ForcePMKID = false;
|
||||
bool ForceProbe = false;
|
||||
bool SavePCAP = true;
|
||||
bool EnableLED = true;
|
||||
bool EPDeauth = false;
|
||||
bool ChanHop = false;
|
||||
String ClientSSID = "";
|
||||
String ClientPW = "";
|
||||
bool ForcePMKID = false;
|
||||
bool ForceProbe = false;
|
||||
bool SavePCAP = true;
|
||||
bool EnableLED = true;
|
||||
bool EPDeauth = false;
|
||||
bool ChanHop = false;
|
||||
String ClientSSID = "";
|
||||
String ClientPW = "";
|
||||
String wu = "";
|
||||
String wt = "";
|
||||
String wdg_key = "";
|
||||
} _cache;
|
||||
|
||||
void _buildCache(); // parse json_settings_string -> _cache
|
||||
|
||||
Reference in New Issue
Block a user