Just Call Me Koko 5 vuotta sitten
vanhempi
commit
06a172e28c

+ 2 - 1
esp32_marauder/Display.cpp

@@ -927,7 +927,8 @@ void ta_event_cb(lv_obj_t * ta, lv_event_t event)
 
 void Display::main(uint8_t scan_mode)
 {  
-  if (scan_mode == LV_JOIN_WIFI)
+  if ((scan_mode == LV_JOIN_WIFI) ||
+      (scan_mode == LV_ADD_SSID))
     lv_task_handler();
   return;
 }

+ 2 - 0
esp32_marauder/Display.h

@@ -33,6 +33,8 @@
 #define BT_SCAN_SKIMMERS 11
 #define WIFI_SCAN_ESPRESSIF 12
 #define LV_JOIN_WIFI 13
+#define LV_ADD_SSID 14
+#define WIFI_ATTACK_BEACON_LIST 15
 
 //#define TFT_SHIELD
 #define TFT_DIY

+ 90 - 6
esp32_marauder/MenuFunctions.cpp

@@ -69,11 +69,11 @@ bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
     data->point.x = touchX;
     data->point.y = touchY;
 
-    Serial.print("Data x");
-    Serial.println(touchX);
+    //Serial.print("Data x");
+    //Serial.println(touchX);
     
-    Serial.print("Data y");
-    Serial.println(touchY);
+    //Serial.print("Data y");
+    //Serial.println(touchY);
 
   }
 
@@ -108,7 +108,46 @@ void MenuFunctions::deinitLVGL() {
   //lv_deinit();
 }
 
+void MenuFunctions::addSSIDGFX(){
+  extern LinkedList<ssid>* ssids;
+  
+  String display_string = "";
+  // Create a keyboard and apply the styles
+  kb = lv_keyboard_create(lv_scr_act(), NULL);
+  lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2);
+  lv_obj_set_event_cb(kb, add_ssid_keyboard_event_cb);
 
+  // Create one text area
+  // Store all SSIDs
+  ta1 = lv_textarea_create(lv_scr_act(), NULL);
+  lv_textarea_set_one_line(ta1, false);
+  lv_obj_set_width(ta1, LV_HOR_RES);
+  lv_obj_set_height(ta1, (LV_VER_RES / 2) - 35);
+  lv_obj_set_pos(ta1, 5, 20);
+  lv_textarea_set_cursor_hidden(ta1, true);
+  lv_obj_align(ta1, NULL, LV_ALIGN_IN_TOP_MID, NULL, NULL);
+  lv_textarea_set_placeholder_text(ta1, "SSID List");
+
+  // Create second text area
+  // Add SSIDs
+  ta2 = lv_textarea_create(lv_scr_act(), ta1);
+  lv_textarea_set_cursor_hidden(ta2, false);
+  lv_textarea_set_one_line(ta2, true);
+  lv_obj_align(ta2, NULL, LV_ALIGN_IN_TOP_MID, NULL, (LV_VER_RES / 2) - 35);
+  lv_textarea_set_text(ta2, "");
+  lv_textarea_set_placeholder_text(ta2, "Add SSIDs");
+
+  // After generating text areas, add text to first text box
+  for (int i = 0; i < ssids->size(); i++)
+    display_string.concat((String)ssids->get(i).essid + "\n");
+    
+  lv_textarea_set_text(ta1, display_string.c_str());
+
+  // Focus it on one of the text areas to start
+  lv_keyboard_set_textarea(kb, ta2);
+  lv_keyboard_set_cursor_manage(kb, true);
+  
+}
 
 void MenuFunctions::joinWiFiGFX(){
 
@@ -149,6 +188,43 @@ void MenuFunctions::joinWiFiGFX(){
   
 }
 
+// Keyboard callback dedicated to joining wifi
+void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
+  extern Display display_obj;
+  extern MenuFunctions menu_function_obj;
+  extern WiFiScan wifi_scan_obj;
+  extern LinkedList<ssid>* ssids;
+  
+  lv_keyboard_def_event_cb(kb, event);
+
+  // User has applied text box
+  if(event == LV_EVENT_APPLY){
+    String display_string = "";
+    printf("LV_EVENT_APPLY\n");
+
+    // Get text from SSID text box
+    String ta2_text = lv_textarea_get_text(ta2);
+    //Serial.println(ta1_text);
+    Serial.println(ta2_text);
+
+    // Add text box text to list of SSIDs
+    wifi_scan_obj.addSSID(ta2_text);
+
+    // Update large text box with ssid
+    for (int i = 0; i < ssids->size(); i++)
+      display_string.concat((String)ssids->get(i).essid + "\n");
+    lv_textarea_set_text(ta1, display_string.c_str());
+
+    lv_textarea_set_text(ta2, "");
+  }else if(event == LV_EVENT_CANCEL){
+    printf("LV_EVENT_CANCEL\n");
+    //lv_textarea_set_text(lv_keyboard_get_textarea(kb), "");
+    menu_function_obj.deinitLVGL();
+    //wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
+    display_obj.exit_draw = true; // set everything back to normal
+  }
+}
+
 // Keyboard callback dedicated to joining wifi
 void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
   extern Display display_obj;
@@ -209,14 +285,16 @@ void MenuFunctions::main(uint32_t currentTime)
     //{
     //  this->drawStatusBar();
     //}
-    if (wifi_scan_obj.currentScanMode != LV_JOIN_WIFI)
+    if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) &&
+        (wifi_scan_obj.currentScanMode != LV_ADD_SSID))
       display_obj.updateBanner(current_menu->name);
   }
 
   if (currentTime != 0) {
     if (currentTime - initTime >= 100) {
       this->initTime = millis();
-      if (wifi_scan_obj.currentScanMode != LV_JOIN_WIFI)
+      if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) &&
+          (wifi_scan_obj.currentScanMode != LV_ADD_SSID))
         this->updateStatusBar();
     }
   }
@@ -776,6 +854,12 @@ void MenuFunctions::RunSetup()
     changeMenu(&generateSSIDsMenu);
     wifi_scan_obj.RunGenerateSSIDs();
   });
+  addNodes(&wifiGeneralMenu, "Add SSID", TFT_NAVY, NULL, GENERATE, [this](){
+    display_obj.clearScreen(); 
+    //wifi_scan_obj.currentScanMode = LV_ADD_SSID; 
+    wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_YELLOW); 
+    addSSIDGFX();
+  });
   addNodes(&wifiGeneralMenu, "Clear SSIDs", TFT_SILVER, NULL, CLEAR_ICO, [this]() {
     changeMenu(&clearSSIDsMenu);
     wifi_scan_obj.RunClearSSIDs();

+ 2 - 0
esp32_marauder/MenuFunctions.h

@@ -77,6 +77,7 @@ PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
 
 PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
 PROGMEM static void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
+PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
 
 // lvgl stuff
 PROGMEM static lv_obj_t *kb;
@@ -170,6 +171,7 @@ class MenuFunctions
     void initLVGL();
     void deinitLVGL();
     void joinWiFiGFX();
+    void addSSIDGFX();
 
     void buildButtons(Menu* menu);
     void changeMenu(Menu* menu);

+ 10 - 1
esp32_marauder/WiFiScan.cpp

@@ -146,6 +146,14 @@ int WiFiScan::clearSSIDs() {
   return num_cleared;
 }
 
+bool WiFiScan::addSSID(String essid) {
+  ssid s = {essid, {random(256), random(256), random(256), random(256), random(256), random(256)}};
+  ssids->add(s);
+  Serial.println(ssids->get(ssids->size() - 1).essid);
+
+  return true;
+}
+
 int WiFiScan::generateSSIDs() {
   uint8_t num_gen = 20;
   for (uint8_t x = 0; x < num_gen; x++) {
@@ -255,6 +263,8 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
     RunEspressifScan(scan_mode, color);
   else if (scan_mode == LV_JOIN_WIFI)
     RunLvJoinWiFi(scan_mode, color);
+  else if (scan_mode == LV_ADD_SSID)
+    RunLvJoinWiFi(scan_mode, color);
 
   WiFiScan::currentScanMode = scan_mode;
 }
@@ -412,7 +422,6 @@ String WiFiScan::freeRAM()
   return String(s);
 }
 
-
 void WiFiScan::RunLvJoinWiFi(uint8_t scan_mode, uint16_t color) {
 
   display_obj.tft.init();

+ 3 - 1
esp32_marauder/WiFiScan.h

@@ -42,7 +42,8 @@
 #define BT_SCAN_SKIMMERS 11
 #define WIFI_SCAN_ESPRESSIF 12
 #define LV_JOIN_WIFI 13
-#define WIFI_ATTACK_BEACON_LIST 14
+#define LV_ADD_SSID 14
+#define WIFI_ATTACK_BEACON_LIST 15
 
 #define GRAPH_REFRESH 100
 
@@ -182,6 +183,7 @@ class WiFiScan
 
     void RunSetup();
     int clearSSIDs();
+    bool addSSID(String essid);
     int generateSSIDs();
     bool shutdownWiFi();
     bool shutdownBLE();