mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 07:10:47 -08:00
Add AP select for attacks
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user