diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index eaa818c..02f042e 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -1683,7 +1683,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < ipList->size(); i++) { // This is the menu node - this->addNodes(&wifiIPMenu, ipList->get(i).toString(), TFTBLUE, NULL, 255, [this, i](){ + this->addNodes(&wifiIPMenu, ipList->get(i).toString().c_str(), TFTBLUE, NULL, 255, [this, i](){ Serial.println("Selected: " + ipList->get(i).toString()); wifi_scan_obj.current_scan_ip = ipList->get(i); display_obj.clearScreen(); @@ -1905,7 +1905,7 @@ void MenuFunctions::RunSetup() // Get AP list ready for (int i = 0; i < access_points->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ if (evil_portal_obj.setAP(access_points->get(i).essid)) { AccessPoint new_ap = access_points->get(i); new_ap.selected = true; @@ -1925,7 +1925,7 @@ void MenuFunctions::RunSetup() for (int i = 0; i < ssids->size(); i++) { // This is the menu node - this->addNodes(&ssidsMenu, ssids->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&ssidsMenu, ssids->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ if (evil_portal_obj.setAP(ssids->get(i).essid)) { display_obj.clearScreen(); this->drawStatusBar(); @@ -1964,7 +1964,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < probe_req_ssids->size(); i++) { // This is the menu node - this->addNodes(&selectProbeSSIDsMenu, probe_req_ssids->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&selectProbeSSIDsMenu, probe_req_ssids->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ if (evil_portal_obj.setAP(probe_req_ssids->get(i).essid)) { display_obj.clearScreen(); this->drawStatusBar(); @@ -2073,9 +2073,10 @@ void MenuFunctions::RunSetup() for (int i = 0; i < probe_req_ssids->size(); i++) { ProbeReqSsid cur_ssid = probe_req_ssids->get(i); // This is the menu node + String button_name = "[" + String(cur_ssid.requests) + "]" + cur_ssid.essid; this->addNodes( &selectProbeSSIDsMenu, - "[" + String(cur_ssid.requests) + "]" + cur_ssid.essid, + button_name.c_str(), TFTCYAN, NULL, 255, @@ -2147,7 +2148,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < evil_portal_obj.html_files->size(); i++) { // This is the menu node - this->addNodes(&htmlMenu, evil_portal_obj.html_files->get(i), TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&htmlMenu, evil_portal_obj.html_files->get(i).c_str(), TFTCYAN, NULL, 255, [this, i](){ evil_portal_obj.selected_html_index = i; evil_portal_obj.target_html_name = evil_portal_obj.html_files->get(evil_portal_obj.selected_html_index); Serial.println("Set Evil Portal HTML as " + evil_portal_obj.target_html_name); @@ -2201,7 +2202,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < access_points->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ AccessPoint new_ap = access_points->get(i); new_ap.selected = !access_points->get(i).selected; @@ -2228,7 +2229,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < access_points->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ this->changeMenu(&apInfoMenu, true); wifi_scan_obj.RunAPInfo(i); }); @@ -2266,7 +2267,7 @@ void MenuFunctions::RunSetup() for (int i = 0; i < menu_limit; i++) { wifiStationMenu.list->clear(); - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ wifiStationMenu.list->clear(); @@ -2300,7 +2301,7 @@ void MenuFunctions::RunSetup() for (int x = 0; x < access_points->get(i).stations->size(); x++) { int cur_ap_sta = access_points->get(i).stations->get(x); - this->addNodes(&wifiStationMenu, macToString(stations->get(cur_ap_sta)), TFTCYAN, NULL, 255, [this, i, cur_ap_sta, x](){ + this->addNodes(&wifiStationMenu, macToString(stations->get(cur_ap_sta)).c_str(), TFTCYAN, NULL, 255, [this, i, cur_ap_sta, x](){ Station new_sta = stations->get(cur_ap_sta); new_sta.selected = !stations->get(cur_ap_sta).selected; @@ -2334,7 +2335,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < access_points->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ // Join WiFi using mini keyboard #ifdef HAS_MINI_KB this->changeMenu(&miniKbMenu, true); @@ -2382,7 +2383,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < access_points->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ // Join WiFi using mini keyboard #ifdef HAS_MINI_KB this->changeMenu(&miniKbMenu, true); @@ -2423,7 +2424,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < ssids->size(); i++) { // This is the menu node - this->addNodes(&ssidsMenu, ssids->get(i).essid, TFTCYAN, NULL, 255, [this, i](){ + this->addNodes(&ssidsMenu, ssids->get(i).essid.c_str(), TFTCYAN, NULL, 255, [this, i](){ // Join WiFi using mini keyboard #ifdef HAS_MINI_KB this->changeMenu(&miniKbMenu, true); @@ -2507,7 +2508,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < access_points->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTLIME, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, access_points->get(i).essid.c_str(), TFTLIME, NULL, 255, [this, i](){ this->changeMenu(&genAPMacMenu, true); wifi_scan_obj.RunSetMac(access_points->get(i).bssid, true); }); @@ -2527,7 +2528,7 @@ void MenuFunctions::RunSetup() // Populate the menu with buttons for (int i = 0; i < stations->size(); i++) { // This is the menu node - this->addNodes(&wifiAPMenu, macToString(stations->get(i).mac), TFTMAGENTA, NULL, 255, [this, i](){ + this->addNodes(&wifiAPMenu, macToString(stations->get(i).mac).c_str(), TFTMAGENTA, NULL, 255, [this, i](){ this->changeMenu(&genAPMacMenu, true); wifi_scan_obj.RunSetMac(stations->get(i).mac, false); }); @@ -2680,7 +2681,7 @@ void MenuFunctions::RunSetup() // Create the menu nodes for all of the list items for (int i = 0; i < menu_limit; i++) { - this->addNodes(&wifiAPMenu, airtags->get(i).mac, TFTWHITE, NULL, BLUETOOTH, [this, i](){ + this->addNodes(&wifiAPMenu, airtags->get(i).mac.c_str(), TFTWHITE, NULL, BLUETOOTH, [this, i](){ AirTag new_at = airtags->get(i); new_at.selected = true; @@ -2912,7 +2913,7 @@ void MenuFunctions::RunSetup() String settingName = settings_obj.setting_index_to_name(i); const char* type = this->callSetting(settingName.c_str()); if (type && strcmp(type, "bool") == 0) { - this->addNodes(&settingsMenu, settingName, TFTLIGHTGREY, NULL, SETTINGS, [this, i, settingName]() { + this->addNodes(&settingsMenu, settingName.c_str(), TFTLIGHTGREY, NULL, SETTINGS, [this, i, settingName]() { settings_obj.toggleSetting(settingName.c_str()); this->callSetting(settingName.c_str()); this->changeMenu(&specSettingMenu, true); @@ -3416,7 +3417,7 @@ void MenuFunctions::buildSDFileMenu(bool update) { if (!update) { for (int x = 0; x < sd_obj.sd_files->size(); x++) { - this->addNodes(&sdDeleteMenu, sd_obj.sd_files->get(x), TFTCYAN, NULL, SD_UPDATE, [this, x]() { + this->addNodes(&sdDeleteMenu, sd_obj.sd_files->get(x).c_str(), TFTCYAN, NULL, SD_UPDATE, [this, x]() { // Change selection status of menu node MenuNode new_node = current_menu->list->get(x + 2); new_node.selected = !current_menu->list->get(x + 2).selected; @@ -3426,7 +3427,7 @@ void MenuFunctions::buildSDFileMenu(bool update) { } else { for (int x = 0; x < sd_obj.sd_files->size(); x++) { - this->addNodes(&sdDeleteMenu, sd_obj.sd_files->get(x), TFTCYAN, NULL, SD_UPDATE, [this, x]() { + this->addNodes(&sdDeleteMenu, sd_obj.sd_files->get(x).c_str(), TFTCYAN, NULL, SD_UPDATE, [this, x]() { wifi_scan_obj.currentScanMode = OTA_UPDATE; this->changeMenu(&failedUpdateMenu, true); sd_obj.runUpdate("/" + sd_obj.sd_files->get(x)); @@ -3437,10 +3438,10 @@ void MenuFunctions::buildSDFileMenu(bool update) { // Function to add MenuNodes to a menu -void MenuFunctions::addNodes(Menu * menu, String name, uint8_t color, Menu * child, int place, std::function callable, bool selected) +void MenuFunctions::addNodes(Menu * menu, const char* name, uint8_t color, Menu * child, int place, std::function callable, bool selected) { //Serial.println("Building node: " + name); - menu->list->add(MenuNode{name, false, color, place, selected, callable}); + menu->list->add(MenuNode{String(name), false, color, place, selected, callable}); } void MenuFunctions::setGraphScale(float scale) { diff --git a/esp32_marauder/MenuFunctions.h b/esp32_marauder/MenuFunctions.h index b421d03..a0fd55e 100644 --- a/esp32_marauder/MenuFunctions.h +++ b/esp32_marauder/MenuFunctions.h @@ -216,7 +216,7 @@ class MenuFunctions void drawGraph(int16_t *values); void drawGraphSmall(uint8_t *values); void renderGraphUI(uint8_t scan_mode = 0); - void addNodes(Menu* menu, String name, uint8_t color, Menu* child, int place, std::function callable, bool selected = false); + void addNodes(Menu* menu, const char* name, uint8_t color, Menu* child, int place, std::function callable, bool selected = false); void battery(bool initial = false); void battery2(bool initial = false); const char* callSetting(const char* key);