Just Call Me Koko 4 лет назад
Родитель
Сommit
6e829f5bf4

+ 1 - 1
esp32_marauder/Display.h

@@ -108,7 +108,7 @@ class Display
     TFT_eSPI tft = TFT_eSPI();
     TFT_eSprite img = TFT_eSprite(&tft);
     TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
-    const String PROGMEM version_number = "v0.9.0";
+    const String PROGMEM version_number = "v0.9.1";
 
     bool printing = false;
     bool loading = false;

+ 98 - 0
esp32_marauder/MenuFunctions.cpp

@@ -155,6 +155,98 @@ void MenuFunctions::writeBadUSB(){
   lv_keyboard_set_cursor_manage(kb, true);
 }
 
+void MenuFunctions::addAPGFX(){
+  extern LinkedList<AccessPoint>* access_points;
+
+  lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
+  lv_obj_set_size(list1, 160, 200);
+  lv_obj_set_width(list1, LV_HOR_RES);
+  lv_obj_align(list1, NULL, LV_ALIGN_CENTER, 0, 0);
+
+  lv_obj_t * list_btn;
+
+  lv_obj_t * label;
+
+  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 (access_points->get(i).selected)
+      lv_btn_toggle(list_btn);
+
+    //lv_obj_t * btn1 = lv_btn_create(list_btn, NULL);
+    //lv_obj_set_event_cb(btn1, ap_list_cb);
+    //lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);
+    //lv_btn_set_checkable(btn1, true);
+
+    //label = lv_label_create(btn1, NULL);
+    //lv_label_set_text(label, buf);
+  }
+
+  list_btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Exit");
+  lv_obj_set_event_cb(list_btn, ap_list_cb);
+}
+
+void ap_list_cb(lv_obj_t * btn, lv_event_t event) {
+  extern LinkedList<AccessPoint>* access_points;
+  extern MenuFunctions menu_function_obj;
+
+  String btn_text = lv_list_get_btn_text(btn);
+  String display_string = "";
+  
+  if (event == LV_EVENT_CLICKED) {
+    if (btn_text != "Exit") {
+      //lv_list_focus_btn(lv_obj_get_parent(lv_obj_get_parent(btn)), btn);
+    }
+    else {
+      Serial.println("Exiting...");
+      lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn)));
+
+      for (int i = 0; i < access_points->size(); i++) {
+        if (access_points->get(i).selected) {
+          Serial.println("Selected: " + (String)access_points->get(i).essid);
+        }
+      }
+
+      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
+    }
+  }
+  
+  if (event == LV_EVENT_VALUE_CHANGED) {      
+    if (lv_btn_get_state(btn) == LV_BTN_STATE_CHECKED_RELEASED) {
+      //Serial.print("Toggle on: ");
+      //Serial.println(btn_text);
+      for (int i = 0; i < access_points->size(); i++) {
+        if (access_points->get(i).essid == btn_text) {
+          Serial.println("Adding AP: " + (String)access_points->get(i).essid);
+          AccessPoint ap = access_points->get(i);
+          ap.selected = true;
+          access_points->set(i, ap);
+        }
+      }
+    }
+    else {
+      //Serial.print("Toggle off: ");
+      //Serial.println(btn_text);
+      for (int i = 0; i < access_points->size(); i++) {
+        if (access_points->get(i).essid == btn_text) {
+          Serial.println("Removing AP: " + (String)access_points->get(i).essid);
+          AccessPoint ap = access_points->get(i);
+          ap.selected = false;
+          access_points->set(i, ap);
+        }
+      }
+    }
+  }
+}
+
 void MenuFunctions::addSSIDGFX(){
   extern LinkedList<ssid>* ssids;
   
@@ -1146,6 +1238,12 @@ void MenuFunctions::RunSetup()
     changeMenu(&clearAPsMenu);
     wifi_scan_obj.RunClearAPs();
   });
+  addNodes(&wifiGeneralMenu, "Select APs", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
+    display_obj.clearScreen(); 
+    wifi_scan_obj.currentScanMode = LV_ADD_SSID; 
+    wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED);  
+    addAPGFX();
+  });
 
   // Build shutdown wifi menu
   shutdownWiFiMenu.parentMenu = &wifiGeneralMenu;

+ 6 - 2
esp32_marauder/MenuFunctions.h

@@ -90,6 +90,7 @@ PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t e
 PROGMEM static void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
 PROGMEM static void load_btn_cb(lv_obj_t * load_btn, lv_event_t event);
 PROGMEM static void test_btn_cb(lv_obj_t * load_btn, lv_event_t event);
+PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
 PROGMEM static void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
 
 // lvgl stuff
@@ -125,7 +126,7 @@ class MenuFunctions
 
     uint32_t initTime = 0;
 
-    Menu* current_menu;
+    //Menu* current_menu;
 
     // Main menu stuff
     Menu mainMenu;
@@ -173,11 +174,12 @@ class MenuFunctions
     void battery(bool initial = false);
     void battery2(bool initial = false);
     void showMenuList(Menu* menu, int layer);
-    void orientDisplay();
 
   public:
     MenuFunctions();
 
+    Menu* current_menu;
+
     Ticker tick;
 
     uint16_t x = -1, y = -1;
@@ -189,6 +191,7 @@ class MenuFunctions
     void deinitLVGL();
     void joinWiFiGFX();
     void addSSIDGFX();
+    void addAPGFX();
     void writeBadUSB();
 
     void buildButtons(Menu* menu);
@@ -196,6 +199,7 @@ class MenuFunctions
     void displayCurrentMenu();
     void main(uint32_t currentTime);
     void RunSetup();
+    void orientDisplay();
 };
 
 

+ 6 - 1
esp32_marauder/WiFiScan.cpp

@@ -1242,6 +1242,7 @@ void WiFiScan::apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
 
   String display_string = "";
   String essid = "";
+  String bssid = "";
 
   if (type == WIFI_PKT_MGMT)
   {
@@ -1297,7 +1298,11 @@ void WiFiScan::apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
           Serial.print((char)snifferPacket->payload[i + 38]);
           display_string.concat((char)snifferPacket->payload[i + 38]);
           essid.concat((char)snifferPacket->payload[i + 38]);
+
+          
         }
+
+        bssid.concat(addr);
   
         int temp_len = display_string.length();
         for (int i = 0; i < 40 - temp_len; i++)
@@ -1314,7 +1319,7 @@ void WiFiScan::apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
           display_obj.loading = false;
         }
         if (essid == "") {
-          essid = "N/A";
+          essid = bssid;
           Serial.print(essid + " ");
         }
 

+ 1 - 0
esp32_marauder/WiFiScan.h

@@ -46,6 +46,7 @@
 #define LV_ADD_SSID 14
 #define WIFI_ATTACK_BEACON_LIST 15
 #define WIFI_SCAN_TARGET_AP 16
+#define LV_SELECT_AP 17
 
 #define GRAPH_REFRESH 100