diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index 7091501..0d3f205 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -222,21 +222,36 @@ void Display::tftDrawChannelScaleButtons(int set_channel) key[5].drawButton(); } -void Display::tftDrawExitScaleButtons() +void Display::tftDrawExitScaleButtons(bool lnd_an) { //tft.drawFastVLine(178, 0, 20, TFT_WHITE); //tft.setCursor(145, 21); tft.setTextColor(TFT_WHITE); tft.setTextSize(1); tft.print("Channel:"); tft.print(set_channel); + if (lnd_an) { - key[6].initButton(&tft, // Exit box - 137, - 10, // x, y, w, h, outline, fill, text - 20, - 20, - TFT_ORANGE, // Outline - TFT_RED, // Fill - TFT_BLACK, // Text - "X", - 2); + key[6].initButton(&tft, // Exit box + 137, + 10, // x, y, w, h, outline, fill, text + 20, + 20, + TFT_ORANGE, // Outline + TFT_RED, // Fill + TFT_BLACK, // Text + "X", + 2); + } + + else { + key[6].initButton(&tft, // Exit box + EXT_BUTTON_WIDTH / 2, + (STATUS_BAR_WIDTH * 2) + CHAR_WIDTH - 1, // x, y, w, h, outline, fill, text + EXT_BUTTON_WIDTH, + EXT_BUTTON_WIDTH, + TFT_ORANGE, // Outline + TFT_RED, // Fill + TFT_BLACK, // Text + "X", + 2); + } key[6].setLabelDatum(1, 5, MC_DATUM); diff --git a/esp32_marauder/Display.h b/esp32_marauder/Display.h index eb6766c..0d09797 100644 --- a/esp32_marauder/Display.h +++ b/esp32_marauder/Display.h @@ -113,7 +113,7 @@ class Display void tftDrawXScaleButtons(byte x_scale); void tftDrawYScaleButtons(byte y_scale); void tftDrawChannelScaleButtons(int set_channel); - void tftDrawExitScaleButtons(); + void tftDrawExitScaleButtons(bool lnd_an = false); void buildBanner(String msg, int xpos); void clearScreen(); void displayBuffer(bool do_clear = false); diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index 33b53c2..750207d 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -321,14 +321,17 @@ MenuFunctions::MenuFunctions() list_btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, text09); lv_obj_set_event_cb(list_btn, ap_list_cb); - if (type == "AP") { + if ((type == "AP") || (type == "AP Info")) { for (int i = 0; i < access_points->size(); i++) { char buf[access_points->get(i).essid.length() + 1] = {}; access_points->get(i).essid.toCharArray(buf, access_points->get(i).essid.length() + 1); list_btn = lv_list_add_btn(list1, LV_SYMBOL_WIFI, buf); lv_btn_set_checkable(list_btn, true); - lv_obj_set_event_cb(list_btn, ap_list_cb); + if (type == "AP") + lv_obj_set_event_cb(list_btn, ap_list_cb); + else if (type == "AP Info") + lv_obj_set_event_cb(list_btn, ap_info_list_cb); if (access_points->get(i).selected) lv_btn_toggle(list_btn); @@ -473,6 +476,43 @@ MenuFunctions::MenuFunctions() } } } + + void ap_info_list_cb(lv_obj_t * btn, lv_event_t event) { + extern LinkedList* access_points; + extern MenuFunctions menu_function_obj; + extern WiFiScan wifi_scan_obj; + + String btn_text = lv_list_get_btn_text(btn); + String display_string = ""; + + // Exit function + if (event == LV_EVENT_CLICKED) { + if (btn_text != text09) { + for (int i = 0; i < access_points->size(); i++) { + if (access_points->get(i).essid == btn_text) { + lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn))); + + printf("LV_EVENT_CANCEL\n"); + menu_function_obj.deinitLVGL(); + wifi_scan_obj.StartScan(WIFI_SCAN_OFF); + //display_obj.exit_draw = true; // set everything back to normal + menu_function_obj.orientDisplay(); + menu_function_obj.changeMenu(&menu_function_obj.apInfoMenu); + wifi_scan_obj.RunAPInfo(i); + } + } + } + else { + Serial.println("Exiting..."); + lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn))); + + printf("LV_EVENT_CANCEL\n"); + menu_function_obj.deinitLVGL(); + wifi_scan_obj.StartScan(WIFI_SCAN_OFF); + display_obj.exit_draw = true; // set everything back to normal + } + } + } void MenuFunctions::addSSIDGFX(){ extern LinkedList* ssids; @@ -1600,6 +1640,12 @@ void MenuFunctions::RunSetup() this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_DEAUTH, TFT_RED); }); + this->addNodes(&wifiSnifferMenu, "Packet Count", TFTORANGE, NULL, PACKET_MONITOR, [this]() { + display_obj.clearScreen(); + this->drawStatusBar(); + wifi_scan_obj.StartScan(WIFI_SCAN_PACKET_RATE, TFT_ORANGE); + wifi_scan_obj.renderPacketRate(); + }); #ifdef HAS_ILI9341 this->addNodes(&wifiSnifferMenu, text_table1[46], TFTVIOLET, NULL, EAPOL, [this]() { wifi_scan_obj.StartScan(WIFI_SCAN_EAPOL, TFT_VIOLET); @@ -1624,12 +1670,12 @@ void MenuFunctions::RunSetup() this->renderGraphUI(WIFI_SCAN_CHAN_ANALYZER); wifi_scan_obj.StartScan(WIFI_SCAN_CHAN_ANALYZER, TFT_CYAN); }); - this->addNodes(&wifiSnifferMenu, "Packet Count", TFTORANGE, NULL, PACKET_MONITOR, [this]() { + /*this->addNodes(&wifiSnifferMenu, "Packet Count", TFTORANGE, NULL, PACKET_MONITOR, [this]() { display_obj.clearScreen(); this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_PACKET_RATE, TFT_ORANGE); wifi_scan_obj.renderPacketRate(); - }); + });*/ this->addNodes(&wifiSnifferMenu, text_table1[58], TFTWHITE, NULL, PACKET_MONITOR, [this]() { display_obj.clearScreen(); this->drawStatusBar(); @@ -1793,6 +1839,10 @@ void MenuFunctions::RunSetup() wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED); selectEPHTMLGFX(); }); + apInfoMenu.parentMenu = &wifiGeneralMenu; + this->addNodes(&apInfoMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { + this->changeMenu(apInfoMenu.parentMenu); + }); #else // Mini EP HTML select this->addNodes(&wifiGeneralMenu, "Select EP HTML File", TFTCYAN, NULL, KEYBOARD_ICO, [this](){ // Add the back button @@ -1946,6 +1996,15 @@ void MenuFunctions::RunSetup() }); #endif + #ifdef HAS_ILI9341 + this->addNodes(&wifiGeneralMenu, "View AP Info", TFTLIGHTGREY, NULL, 0, [this]() { + display_obj.clearScreen(); + wifi_scan_obj.currentScanMode = LV_ADD_SSID; + wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_WHITE); + addAPGFX("AP Info"); + }); + #endif + this->addNodes(&wifiGeneralMenu, "Set MACs", TFTLIGHTGREY, NULL, 0, [this]() { this->changeMenu(&setMacMenu); }); diff --git a/esp32_marauder/MenuFunctions.h b/esp32_marauder/MenuFunctions.h index 3139a00..8405198 100644 --- a/esp32_marauder/MenuFunctions.h +++ b/esp32_marauder/MenuFunctions.h @@ -85,6 +85,7 @@ PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event); PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event); PROGMEM static void html_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event); +PROGMEM static void ap_info_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void at_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void station_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event); @@ -177,7 +178,6 @@ class MenuFunctions Menu htmlMenu; Menu miniKbMenu; Menu saveFileMenu; - Menu apInfoMenu; Menu genAPMacMenu; Menu cloneAPMacMenu; Menu setMacMenu; @@ -238,6 +238,7 @@ class MenuFunctions #endif Menu infoMenu; + Menu apInfoMenu; Ticker tick; diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index 189ba77..314db08 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -2153,39 +2153,62 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color) startPcap("packet_monitor"); #ifdef HAS_ILI9341 - - #ifdef HAS_SCREEN - display_obj.tft.init(); - display_obj.tft.setRotation(1); - display_obj.tft.fillScreen(TFT_BLACK); - #endif - - #ifdef HAS_SCREEN - #ifdef TFT_SHIELD - uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield - Serial.println("Using TFT Shield"); - #else if defined(TFT_DIY) - uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY - Serial.println("Using TFT DIY"); + if (scan_mode != WIFI_SCAN_PACKET_RATE) { + #ifdef HAS_SCREEN + display_obj.tft.init(); + display_obj.tft.setRotation(1); + display_obj.tft.fillScreen(TFT_BLACK); #endif - display_obj.tft.setTouch(calData); - //display_obj.tft.setFreeFont(1); - display_obj.tft.setFreeFont(NULL); - display_obj.tft.setTextSize(1); - display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); // Buttons - display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // color key - - delay(10); - - display_obj.tftDrawGraphObjects(x_scale); //draw graph objects - display_obj.tftDrawColorKey(); - display_obj.tftDrawXScaleButtons(x_scale); - display_obj.tftDrawYScaleButtons(y_scale); + #ifdef HAS_SCREEN + #ifdef TFT_SHIELD + uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield + Serial.println("Using TFT Shield"); + #else if defined(TFT_DIY) + uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY + Serial.println("Using TFT DIY"); + #endif + display_obj.tft.setTouch(calData); + + //display_obj.tft.setFreeFont(1); + display_obj.tft.setFreeFont(NULL); + display_obj.tft.setTextSize(1); + display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); // Buttons + display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // color key + + delay(10); + + display_obj.tftDrawGraphObjects(x_scale); //draw graph objects + display_obj.tftDrawColorKey(); + display_obj.tftDrawXScaleButtons(x_scale); + display_obj.tftDrawYScaleButtons(y_scale); + display_obj.tftDrawChannelScaleButtons(set_channel); + display_obj.tftDrawExitScaleButtons(); + #endif + } + else { + display_obj.TOP_FIXED_AREA_2 = 48; + display_obj.tteBar = true; + display_obj.print_delay_1 = 15; + display_obj.print_delay_2 = 10; + display_obj.initScrollValues(true); + display_obj.tft.setTextWrap(false); + display_obj.tft.setTextColor(TFT_WHITE, color); + #ifdef HAS_FULL_SCREEN + display_obj.tft.fillRect(0,16,240,16, color); + if (scan_mode == WIFI_PACKET_MONITOR) + display_obj.tft.drawCentreString(text_table1[45],120,16,2); + else if (scan_mode == WIFI_SCAN_CHAN_ANALYZER) + display_obj.tft.drawCentreString("Channel Analyzer", 120, 16, 2); + else if (scan_mode == WIFI_SCAN_PACKET_RATE) + display_obj.tft.drawCentreString("Packet Rate", 120, 16, 2); + #endif + display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK); + display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA); display_obj.tftDrawChannelScaleButtons(set_channel); - display_obj.tftDrawExitScaleButtons(); - #endif - #else + display_obj.tftDrawExitScaleButtons(false); + } + #else // Non touch #ifdef HAS_SCREEN display_obj.TOP_FIXED_AREA_2 = 48; display_obj.tteBar = true; @@ -5860,11 +5883,11 @@ void WiFiScan::renderPacketRate() { #ifdef HAS_SCREEN uint8_t line_count = 0; display_obj.tft.fillRect(0, - (STATUS_BAR_WIDTH * 2) + 1, + (STATUS_BAR_WIDTH * 2) + 1 + EXT_BUTTON_WIDTH, TFT_WIDTH, TFT_HEIGHT - STATUS_BAR_WIDTH + 1, TFT_BLACK); - display_obj.tft.setCursor(0, (STATUS_BAR_WIDTH * 2) + CHAR_WIDTH); + display_obj.tft.setCursor(0, (STATUS_BAR_WIDTH * 2) + CHAR_WIDTH + EXT_BUTTON_WIDTH); display_obj.tft.setTextSize(1); display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK); for (int i = 0; i < access_points->size(); i++) { @@ -5879,6 +5902,10 @@ void WiFiScan::renderPacketRate() { Serial.println(macToString(stations->get(i).mac) + ": " + (String)stations->get(i).packets); } } + + #ifdef HAS_ILI9341 + display_obj.key[6].drawButton(); + #endif #endif } @@ -5890,6 +5917,11 @@ void WiFiScan::packetRateLoop(uint32_t tick) { this->renderPacketRate(); else if (this->currentScanMode == WIFI_SCAN_RAW_CAPTURE) this->renderRawStats(); + + #ifdef HAS_ILI9341 + initTime = millis(); + channelHop(); + #endif } #endif } @@ -5927,6 +5959,13 @@ void WiFiScan::main(uint32_t currentTime) else if ((currentScanMode == WIFI_SCAN_CHAN_ANALYZER) || (currentScanMode == BT_SCAN_ANALYZER)) { this->channelAnalyzerLoop(currentTime); + #ifdef HAS_ILI9341 + if (currentTime - initTime >= this->channel_hop_delay * 1000) + { + initTime = millis(); + channelHop(); + } + #endif } else if ((currentScanMode == WIFI_SCAN_PACKET_RATE) || (currentScanMode == WIFI_SCAN_RAW_CAPTURE)) { diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 6600043..4e8de4d 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -413,6 +413,8 @@ #define GRAPH_VERT_LIM TFT_HEIGHT/2 + #define EXT_BUTTON_WIDTH 0 + #define CHAR_WIDTH 6 #define SCREEN_WIDTH TFT_HEIGHT // Originally 240 #define SCREEN_HEIGHT TFT_WIDTH // Originally 320 @@ -483,6 +485,8 @@ #define GRAPH_VERT_LIM TFT_HEIGHT/2 + #define EXT_BUTTON_WIDTH 0 + #define CHAR_WIDTH 6 #define SCREEN_WIDTH TFT_HEIGHT // Originally 240 #define SCREEN_HEIGHT TFT_WIDTH // Originally 320 @@ -543,6 +547,8 @@ #define GRAPH_VERT_LIM TFT_HEIGHT/2 + #define EXT_BUTTON_WIDTH 20 + #define CHAR_WIDTH 12 #define SCREEN_WIDTH TFT_WIDTH #define SCREEN_HEIGHT TFT_HEIGHT @@ -603,6 +609,8 @@ #define TFT_DIY #define GRAPH_VERT_LIM TFT_HEIGHT/2 + + #define EXT_BUTTON_WIDTH 20 #define CHAR_WIDTH 12 #define SCREEN_WIDTH TFT_WIDTH @@ -668,6 +676,8 @@ #define SCREEN_BUFFER #define MAX_SCREEN_BUFFER 22 + + #define EXT_BUTTON_WIDTH 0 #define CHAR_WIDTH 12 #define SCREEN_WIDTH TFT_WIDTH @@ -730,6 +740,8 @@ #define TFT_DIY #define KIT + + #define EXT_BUTTON_WIDTH 20 #define CHAR_WIDTH 12 #define SCREEN_WIDTH TFT_WIDTH @@ -802,6 +814,8 @@ #define GRAPH_VERT_LIM TFT_HEIGHT/2 + #define EXT_BUTTON_WIDTH 0 + #define CHAR_WIDTH 6 #define SCREEN_WIDTH TFT_WIDTH // Originally 240 #define SCREEN_HEIGHT TFT_HEIGHT // Originally 320 @@ -871,6 +885,8 @@ #define GRAPH_VERT_LIM TFT_HEIGHT/2 + #define EXT_BUTTON_WIDTH 0 + #define CHAR_WIDTH 6 #define SCREEN_WIDTH TFT_WIDTH // Originally 240 #define SCREEN_HEIGHT TFT_HEIGHT // Originally 320