From 71cd6032047584e6170693f1cb094fb2f4b38898 Mon Sep 17 00:00:00 2001 From: John Stockdale Date: Fri, 6 Dec 2024 22:57:41 -0800 Subject: [PATCH] this should make serial console echo and handle backspace --- esp32_marauder/CommandLine.cpp | 958 +++++++++++++++++---------------- 1 file changed, 494 insertions(+), 464 deletions(-) diff --git a/esp32_marauder/CommandLine.cpp b/esp32_marauder/CommandLine.cpp index 08974d49f..d657e7160 100644 --- a/esp32_marauder/CommandLine.cpp +++ b/esp32_marauder/CommandLine.cpp @@ -20,24 +20,52 @@ String CommandLine::getSerialInput() { int bytes_available = 0; String command_line = ""; char command_buffer[255]; - + memset(command_buffer, '\0', 255); if (Serial.available() > 0 && serial_buffer_idx < 255) { bytes_available = Serial.available(); + //Serial.println("Should have bytes available: " + bytes_available); int bytes_to_read = bytes_available < (254 - serial_buffer_idx) ? bytes_available : (254 - serial_buffer_idx); bytes_received = Serial.readBytes(&serial_buffer[serial_buffer_idx], bytes_to_read); + + // echo what we just got to the terminal + for (int i = serial_buffer_idx; i < serial_buffer_idx + bytes_received; i++) { + // support backspace + if (serial_buffer[i] == '\x7f') { + for (int j = i; j < 255; j++) { + if (j == 0) { + break; + } else if (j == 254 || j > serial_buffer_idx) { + serial_buffer[j] = '\0'; + } else { + serial_buffer[j-1] = serial_buffer[j]; + } + serial_buffer_idx--; + } + } + Serial.print(serial_buffer[i]); + } + serial_buffer_idx += bytes_received; if (serial_buffer_idx < 254) { serial_buffer[serial_buffer_idx+1] = '\0'; } else if (serial_buffer_idx >= 254) { Serial.println("Serial buffer overrun?"); } +// Serial.println("Received bytes over serial: " + String(bytes_received)); +// Serial.println("Buffer: " + String(serial_buffer)); +// Serial.println("Buffer idx: " + String(serial_buffer_idx)); } int index_of_newline = -1; for (int i = 0; i < serial_buffer_idx; i++) { +// Serial.println("Checking character at: " + String(i) + " it appears to be: " + String(serial_buffer[i])); +// Serial.print("Hex value of character: "); +// Serial.print(serial_buffer[i], HEX); +// Serial.println(); + // this is mind boggling but hey. why not. :D if (serial_buffer[i] == '\n' || serial_buffer[i] == '\r') { //Serial.println("Found \"newline\" at index: " + String(i)); @@ -47,7 +75,7 @@ String CommandLine::getSerialInput() { command_buffer[i] = serial_buffer[i]; } } - + command_line = command_buffer; if (index_of_newline > -1) { @@ -137,7 +165,7 @@ int CommandLine::argSearch(LinkedList* cmd_args_list, String key) { bool CommandLine::checkValueExists(LinkedList* cmd_args_list, int index) { if (index < cmd_args_list->size() - 1) return true; - + return false; } @@ -166,10 +194,10 @@ bool CommandLine::hasSSIDs() { void CommandLine::showCounts(int selected, int unselected) { Serial.print((String) selected + " selected"); - - if (unselected != -1) + + if (unselected != -1) Serial.print(", " + (String) unselected + " unselected"); - + Serial.println(""); } @@ -246,14 +274,14 @@ void CommandLine::filterAccessPoints(String filter) { void CommandLine::runCommand(String input) { if (input == "") return; - if(wifi_scan_obj.scanning() && wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_NMEA){ - if(input != STOPSCAN_CMD) return; + if (wifi_scan_obj.scanning() && wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_NMEA) { + if (input != STOPSCAN_CMD) return; } else Serial.println("#" + input); LinkedList cmd_args = this->parseCommand(input, " "); - + //// Admin commands // Help if (cmd_args.get(0) == HELP_CMD) { @@ -268,7 +296,7 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_GPS_DATA_CMD); Serial.println(HELP_GPS_CMD); Serial.println(HELP_NMEA_CMD); - + // WiFi sniff/scan Serial.println(HELP_EVIL_PORTAL_CMD); Serial.println(HELP_SIGSTREN_CMD); @@ -282,13 +310,13 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_SNIFF_DEAUTH_CMD); Serial.println(HELP_SNIFF_PMKID_CMD); Serial.println(HELP_STOPSCAN_CMD); - #ifdef HAS_GPS - Serial.println(HELP_WARDRIVE_CMD); - #endif - +#ifdef HAS_GPS + Serial.println(HELP_WARDRIVE_CMD); +#endif + // WiFi attack Serial.println(HELP_ATTACK_CMD); - + // WiFi Aux Serial.println(HELP_LIST_AP_CMD_A); Serial.println(HELP_LIST_AP_CMD_B); @@ -299,20 +327,20 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_SSID_CMD_B); Serial.println(HELP_SAVE_CMD); Serial.println(HELP_LOAD_CMD); - + // Bluetooth sniff/scan - #ifdef HAS_BT - Serial.println(HELP_BT_SNIFF_CMD); - Serial.println(HELP_BT_SPAM_CMD); - Serial.println(HELP_BT_SPOOFAT_CMD); - //Serial.println(HELP_BT_SWIFTPAIR_SPAM_CMD); - //Serial.println(HELP_BT_SAMSUNG_SPAM_CMD); - //Serial.println(HELP_BT_SPAM_ALL_CMD); - #ifdef HAS_GPS - Serial.println(HELP_BT_WARDRIVE_CMD); - #endif - Serial.println(HELP_BT_SKIM_CMD); - #endif +#ifdef HAS_BT + Serial.println(HELP_BT_SNIFF_CMD); + Serial.println(HELP_BT_SPAM_CMD); + Serial.println(HELP_BT_SPOOFAT_CMD); + //Serial.println(HELP_BT_SWIFTPAIR_SPAM_CMD); + //Serial.println(HELP_BT_SAMSUNG_SPAM_CMD); + //Serial.println(HELP_BT_SPAM_ALL_CMD); +#ifdef HAS_GPS + Serial.println(HELP_BT_WARDRIVE_CMD); +#endif + Serial.println(HELP_BT_SKIM_CMD); +#endif Serial.println(HELP_FOOT); return; } @@ -321,168 +349,168 @@ void CommandLine::runCommand(String input) { if (cmd_args.get(0) == STOPSCAN_CMD) { //if (wifi_scan_obj.currentScanMode == OTA_UPDATE) { // wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; - //#ifdef HAS_SCREEN - // menu_function_obj.changeMenu(menu_function_obj.updateMenu.parentMenu); - //#endif + //#ifdef HAS_SCREEN + // menu_function_obj.changeMenu(menu_function_obj.updateMenu.parentMenu); + //#endif // WiFi.softAPdisconnect(true); // web_obj.shutdownServer(); // return; //} - - uint8_t old_scan_mode=wifi_scan_obj.currentScanMode; + + uint8_t old_scan_mode = wifi_scan_obj.currentScanMode; wifi_scan_obj.StartScan(WIFI_SCAN_OFF); - if(old_scan_mode == WIFI_SCAN_GPS_NMEA) + if (old_scan_mode == WIFI_SCAN_GPS_NMEA) Serial.println("END OF NMEA STREAM"); - else if(old_scan_mode == WIFI_SCAN_GPS_DATA) + else if (old_scan_mode == WIFI_SCAN_GPS_DATA) Serial.println("Stopping GPS data updates"); else Serial.println("Stopping WiFi tran/recv"); // If we don't do this, the text and button coordinates will be off - #ifdef HAS_SCREEN - display_obj.tft.init(); - menu_function_obj.changeMenu(menu_function_obj.current_menu); - #endif +#ifdef HAS_SCREEN + display_obj.tft.init(); + menu_function_obj.changeMenu(menu_function_obj.current_menu); +#endif } else if (cmd_args.get(0) == GPS_DATA_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - Serial.println("Getting GPS Data. Stop with " + (String)STOPSCAN_CMD); - wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_DATA; - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); - #endif - wifi_scan_obj.StartScan(WIFI_SCAN_GPS_DATA, TFT_CYAN); - } - #endif +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + Serial.println("Getting GPS Data. Stop with " + (String)STOPSCAN_CMD); + wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_DATA; +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); +#endif + wifi_scan_obj.StartScan(WIFI_SCAN_GPS_DATA, TFT_CYAN); + } +#endif } else if (cmd_args.get(0) == GPS_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - int get_arg = this->argSearch(&cmd_args, "-g"); - int nmea_arg = this->argSearch(&cmd_args, "-n"); - - if (get_arg != -1) { - String gps_info = cmd_args.get(get_arg + 1); - - if (gps_info == "fix") - Serial.println("Fix: " + gps_obj.getFixStatusAsString()); - else if (gps_info == "sat") - Serial.println("Sats: " + gps_obj.getNumSatsString()); - else if (gps_info == "lat") - Serial.println("Lat: " + gps_obj.getLat()); - else if (gps_info == "lon") - Serial.println("Lon: " + gps_obj.getLon()); - else if (gps_info == "alt") - Serial.println("Alt: " + (String)gps_obj.getAlt()); - else if (gps_info == "accuracy") - Serial.println("Accuracy: " + (String)gps_obj.getAccuracy()); - else if (gps_info == "date") - Serial.println("Date/Time: " + gps_obj.getDatetime()); - else if (gps_info == "text"){ - Serial.println(gps_obj.getText()); - } - else if (gps_info == "nmea"){ - int notparsed_arg = this->argSearch(&cmd_args, "-p"); - int notimp_arg = this->argSearch(&cmd_args, "-i"); - int recd_arg = this->argSearch(&cmd_args, "-r"); - if(notparsed_arg == -1 && notimp_arg == -1 && recd_arg == -1){ - gps_obj.sendSentence(Serial, gps_obj.generateGXgga().c_str()); - gps_obj.sendSentence(Serial, gps_obj.generateGXrmc().c_str()); - } - else if(notparsed_arg == -1 && notimp_arg == -1) - Serial.println(gps_obj.getNmea()); - else if(notparsed_arg == -1) - Serial.println(gps_obj.getNmeaNotimp()); - else - Serial.println(gps_obj.getNmeaNotparsed()); +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + int get_arg = this->argSearch(&cmd_args, "-g"); + int nmea_arg = this->argSearch(&cmd_args, "-n"); + + if (get_arg != -1) { + String gps_info = cmd_args.get(get_arg + 1); + + if (gps_info == "fix") + Serial.println("Fix: " + gps_obj.getFixStatusAsString()); + else if (gps_info == "sat") + Serial.println("Sats: " + gps_obj.getNumSatsString()); + else if (gps_info == "lat") + Serial.println("Lat: " + gps_obj.getLat()); + else if (gps_info == "lon") + Serial.println("Lon: " + gps_obj.getLon()); + else if (gps_info == "alt") + Serial.println("Alt: " + (String)gps_obj.getAlt()); + else if (gps_info == "accuracy") + Serial.println("Accuracy: " + (String)gps_obj.getAccuracy()); + else if (gps_info == "date") + Serial.println("Date/Time: " + gps_obj.getDatetime()); + else if (gps_info == "text") { + Serial.println(gps_obj.getText()); + } + else if (gps_info == "nmea") { + int notparsed_arg = this->argSearch(&cmd_args, "-p"); + int notimp_arg = this->argSearch(&cmd_args, "-i"); + int recd_arg = this->argSearch(&cmd_args, "-r"); + if (notparsed_arg == -1 && notimp_arg == -1 && recd_arg == -1) { + gps_obj.sendSentence(Serial, gps_obj.generateGXgga().c_str()); + gps_obj.sendSentence(Serial, gps_obj.generateGXrmc().c_str()); } + else if (notparsed_arg == -1 && notimp_arg == -1) + Serial.println(gps_obj.getNmea()); + else if (notparsed_arg == -1) + Serial.println(gps_obj.getNmeaNotimp()); else - Serial.println("You did not provide a valid argument"); + Serial.println(gps_obj.getNmeaNotparsed()); } - else if(nmea_arg != -1){ - String nmea_type = cmd_args.get(nmea_arg + 1); - - if (nmea_type == "native" || nmea_type == "all" || nmea_type == "gps" || nmea_type == "glonass" - || nmea_type == "galileo" || nmea_type == "navic" || nmea_type == "qzss" || nmea_type == "beidou"){ - if(nmea_type == "beidou"){ - int beidou_bd_arg = this->argSearch(&cmd_args, "-b"); - if(beidou_bd_arg != -1) - nmea_type="beidou_bd"; - } - gps_obj.setType(nmea_type); - Serial.println("GPS Output Type Set To: " + nmea_type); + else + Serial.println("You did not provide a valid argument"); + } + else if (nmea_arg != -1) { + String nmea_type = cmd_args.get(nmea_arg + 1); + + if (nmea_type == "native" || nmea_type == "all" || nmea_type == "gps" || nmea_type == "glonass" + || nmea_type == "galileo" || nmea_type == "navic" || nmea_type == "qzss" || nmea_type == "beidou") { + if (nmea_type == "beidou") { + int beidou_bd_arg = this->argSearch(&cmd_args, "-b"); + if (beidou_bd_arg != -1) + nmea_type = "beidou_bd"; } - else - Serial.println("You did not provide a valid argument"); + gps_obj.setType(nmea_type); + Serial.println("GPS Output Type Set To: " + nmea_type); } - else if(cmd_args.size()>1) - Serial.println("You did not provide a valid flag"); else - Serial.println("You did not provide an argument"); + Serial.println("You did not provide a valid argument"); } - #endif + else if (cmd_args.size() > 1) + Serial.println("You did not provide a valid flag"); + else + Serial.println("You did not provide an argument"); + } +#endif } else if (cmd_args.get(0) == NMEA_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); - #endif - Serial.println("NMEA STREAM FOLLOWS"); - wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_NMEA; - wifi_scan_obj.StartScan(WIFI_SCAN_GPS_NMEA, TFT_CYAN); - } - #endif +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); +#endif + Serial.println("NMEA STREAM FOLLOWS"); + wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_NMEA; + wifi_scan_obj.StartScan(WIFI_SCAN_GPS_NMEA, TFT_CYAN); + } +#endif } // LED command else if (cmd_args.get(0) == LED_CMD) { int hex_arg = this->argSearch(&cmd_args, "-s"); int pat_arg = this->argSearch(&cmd_args, "-p"); - #ifdef PIN - if (hex_arg != -1) { - String hexstring = cmd_args.get(hex_arg + 1); - int number = (int)strtol(&hexstring[1], NULL, 16); - int r = number >> 16; - int g = number >> 8 & 0xFF; - int b = number & 0xFF; - //Serial.println(r); - //Serial.println(g); - //Serial.println(b); - led_obj.setColor(r, g, b); - led_obj.setMode(MODE_CUSTOM); - } - else if (pat_arg != -1) { - String pat_name = cmd_args.get(pat_arg + 1); - pat_name.toLowerCase(); - if (pat_name == "rainbow") { - led_obj.setMode(MODE_RAINBOW); - } +#ifdef PIN + if (hex_arg != -1) { + String hexstring = cmd_args.get(hex_arg + 1); + int number = (int)strtol(&hexstring[1], NULL, 16); + int r = number >> 16; + int g = number >> 8 & 0xFF; + int b = number & 0xFF; + //Serial.println(r); + //Serial.println(g); + //Serial.println(b); + led_obj.setColor(r, g, b); + led_obj.setMode(MODE_CUSTOM); + } + else if (pat_arg != -1) { + String pat_name = cmd_args.get(pat_arg + 1); + pat_name.toLowerCase(); + if (pat_name == "rainbow") { + led_obj.setMode(MODE_RAINBOW); } - #else - Serial.println("This hardware does not support neopixel"); - #endif + } +#else + Serial.println("This hardware does not support neopixel"); +#endif } // ls command else if (cmd_args.get(0) == LS_CMD) { - #ifdef HAS_SD - if (cmd_args.size() > 1) - sd_obj.listDir(cmd_args.get(1)); - else - Serial.println("You did not provide a dir to list"); - #else - Serial.println("SD support disabled, cannot use command"); - return; - #endif +#ifdef HAS_SD + if (cmd_args.size() > 1) + sd_obj.listDir(cmd_args.get(1)); + else + Serial.println("You did not provide a dir to list"); +#else + Serial.println("SD support disabled, cannot use command"); + return; +#endif } // Channel command else if (cmd_args.get(0) == CH_CMD) { // Search for channel set arg int ch_set = this->argSearch(&cmd_args, "-s"); - + if (cmd_args.size() == 1) { Serial.println("Current channel: " + (String)wifi_scan_obj.set_channel); } @@ -499,23 +527,23 @@ void CommandLine::runCommand(String input) { int cl_sw = this->argSearch(&cmd_args, "-c"); // Stations if (ap_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); +#endif wifi_scan_obj.RunClearAPs(); } if (ss_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.clearSSIDsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.clearSSIDsMenu); +#endif wifi_scan_obj.RunClearSSIDs(); } if (cl_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); +#endif wifi_scan_obj.RunClearStations(); } } @@ -566,39 +594,40 @@ void CommandLine::runCommand(String input) { // Signal strength scan if (cmd_args.get(0) == SIGSTREN_CMD) { Serial.println("Starting Signal Strength Scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_MAGENTA); } // Wardrive else if (cmd_args.get(0) == WARDRIVE_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - int sta_sw = this->argSearch(&cmd_args, "-s"); - - if (sta_sw == -1) { - Serial.println("Starting Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(WIFI_SCAN_WAR_DRIVE, TFT_GREEN); - } - else {Serial.println("Starting Station Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(WIFI_SCAN_STATION_WAR_DRIVE, TFT_GREEN); - } +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + int sta_sw = this->argSearch(&cmd_args, "-s"); + + if (sta_sw == -1) { + Serial.println("Starting Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(WIFI_SCAN_WAR_DRIVE, TFT_GREEN); } - else - Serial.println("GPS Module not detected"); - #else - Serial.println("GPS not supported"); - #endif + else { + Serial.println("Starting Station Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(WIFI_SCAN_STATION_WAR_DRIVE, TFT_GREEN); + } + } + else + Serial.println("GPS Module not detected"); +#else + Serial.println("GPS not supported"); +#endif } // AP Scan else if (cmd_args.get(0) == EVIL_PORTAL_CMD) { @@ -609,10 +638,10 @@ void CommandLine::runCommand(String input) { String et_command = cmd_args.get(cmd_sw + 1); if (et_command == "start") { Serial.println("Starting Evil Portal. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif if (html_sw != -1) { String target_html_name = cmd_args.get(html_sw + 1); evil_portal_obj.target_html_name = target_html_name; @@ -625,10 +654,10 @@ void CommandLine::runCommand(String input) { wifi_scan_obj.StartScan(WIFI_SCAN_EVIL_PORTAL, TFT_MAGENTA); } else if (et_command == "reset") { - + } else if (et_command == "ack") { - + } else if (et_command == "sethtml") { String target_html_name = cmd_args.get(cmd_sw + 2); @@ -646,10 +675,10 @@ void CommandLine::runCommand(String input) { } else if (cmd_args.get(0) == SCANAP_CMD) { int full_sw = -1; - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif if (full_sw == -1) { Serial.println("Starting AP scan. Stop with " + (String)STOPSCAN_CMD); @@ -663,67 +692,67 @@ void CommandLine::runCommand(String input) { // Raw sniff else if (cmd_args.get(0) == SNIFF_RAW_CMD) { Serial.println("Starting Raw sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_RAW_CAPTURE, TFT_WHITE); } // Scan stations - else if (cmd_args.get(0) == SCANSTA_CMD) { - if(access_points->size() < 1) - Serial.println("The AP list is empty. Scan APs first with " + (String)SCANAP_CMD); - - Serial.println("Starting Station scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif + else if (cmd_args.get(0) == SCANSTA_CMD) { + if (access_points->size() < 1) + Serial.println("The AP list is empty. Scan APs first with " + (String)SCANAP_CMD); + + Serial.println("Starting Station scan. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_STATION, TFT_ORANGE); } // Beacon sniff else if (cmd_args.get(0) == SNIFF_BEACON_CMD) { Serial.println("Starting Beacon sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_AP, TFT_MAGENTA); } // Probe sniff else if (cmd_args.get(0) == SNIFF_PROBE_CMD) { Serial.println("Starting Probe sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_PROBE, TFT_MAGENTA); } // Deauth sniff else if (cmd_args.get(0) == SNIFF_DEAUTH_CMD) { Serial.println("Starting Deauth sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_DEAUTH, TFT_RED); } // Pwn sniff else if (cmd_args.get(0) == SNIFF_PWN_CMD) { Serial.println("Starting Pwnagotchi sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_PWN, TFT_MAGENTA); } // Espressif sniff else if (cmd_args.get(0) == SNIFF_ESP_CMD) { Serial.println("Starting Espressif device sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_ESPRESSIF, TFT_MAGENTA); } // PMKID sniff @@ -738,12 +767,12 @@ void CommandLine::runCommand(String input) { return; } } - + if (ch_sw != -1) { wifi_scan_obj.set_channel = cmd_args.get(ch_sw + 1).toInt(); wifi_scan_obj.changeChannel(); Serial.println("Set channel: " + (String)wifi_scan_obj.set_channel); - + } if (d_sw == -1) { @@ -758,7 +787,7 @@ void CommandLine::runCommand(String input) { Serial.println("Starting PMKID sniff with deauthentication on channel " + (String)wifi_scan_obj.set_channel + ". Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_SCAN_ACTIVE_EAPOL, TFT_VIOLET); } - } + } //// WiFi attack commands // attack @@ -770,14 +799,14 @@ void CommandLine::runCommand(String input) { int src_addr_sw = this->argSearch(&cmd_args, "-s"); int dst_addr_sw = this->argSearch(&cmd_args, "-d"); int targ_sw = this->argSearch(&cmd_args, "-c"); - + if (attack_type_switch == -1) { Serial.println("You must specify an attack type"); return; } else { String attack_type = cmd_args.get(attack_type_switch + 1); - + // Branch on attack type // Deauth if (attack_type == ATTACK_TYPE_DEAUTH) { @@ -801,10 +830,10 @@ void CommandLine::runCommand(String input) { Serial.println("You don't have any targets selected. Use " + (String)SEL_CMD); return; } - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Deauthentication attack. Stop with " + (String)STOPSCAN_CMD); // Station list not specified if (targ_sw == -1) @@ -816,15 +845,15 @@ void CommandLine::runCommand(String input) { // Source addr specified else { String src_mac_str = cmd_args.get(src_addr_sw + 1); - sscanf(src_mac_str.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", - &wifi_scan_obj.src_mac[0], &wifi_scan_obj.src_mac[1], &wifi_scan_obj.src_mac[2], &wifi_scan_obj.src_mac[3], &wifi_scan_obj.src_mac[4], &wifi_scan_obj.src_mac[5]); + sscanf(src_mac_str.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", + &wifi_scan_obj.src_mac[0], &wifi_scan_obj.src_mac[1], &wifi_scan_obj.src_mac[2], &wifi_scan_obj.src_mac[3], &wifi_scan_obj.src_mac[4], &wifi_scan_obj.src_mac[5]); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Manual Deauthentication attack. Stop with " + (String)STOPSCAN_CMD); - wifi_scan_obj.StartScan(WIFI_ATTACK_DEAUTH_MANUAL, TFT_RED); + wifi_scan_obj.StartScan(WIFI_ATTACK_DEAUTH_MANUAL, TFT_RED); } } // Beacon @@ -835,19 +864,19 @@ void CommandLine::runCommand(String input) { Serial.println("You don't have any SSIDs in your list. Use " + (String)SSID_CMD); return; } - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Beacon list spam. Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_ATTACK_BEACON_LIST, TFT_RED); } // spam with random else if (rand_beacon_sw != -1) { - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting random Beacon spam. Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_ATTACK_BEACON_SPAM, TFT_ORANGE); } @@ -857,10 +886,10 @@ void CommandLine::runCommand(String input) { Serial.println("You don't have any targets selected. Use " + (String)SEL_CMD); return; } - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Targeted AP Beacon spam. Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_ATTACK_AP_SPAM, TFT_MAGENTA); } @@ -874,18 +903,18 @@ void CommandLine::runCommand(String input) { return; } Serial.println("Starting Probe spam. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_ATTACK_AUTH, TFT_RED); } else if (attack_type == ATTACK_TYPE_RR) { Serial.println("Starting Rick Roll Beacon spam. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_ATTACK_RICK_ROLL, TFT_YELLOW); } else { @@ -898,72 +927,72 @@ void CommandLine::runCommand(String input) { //// Bluetooth scan/attack commands // Bluetooth scan if (cmd_args.get(0) == BT_SNIFF_CMD) { - #ifdef HAS_BT - int bt_type_sw = this->argSearch(&cmd_args, "-t"); - - // Specifying type of bluetooth sniff - if (bt_type_sw != -1) { - String bt_type = cmd_args.get(bt_type_sw + 1); - - bt_type.toLowerCase(); - - // Airtag sniff - if (bt_type == "airtag") { - Serial.println("Starting Airtag sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_AIRTAG, TFT_WHITE); - } - else if (bt_type == "flipper") { - Serial.println("Starting Flipper sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_FLIPPER, TFT_ORANGE); - } +#ifdef HAS_BT + int bt_type_sw = this->argSearch(&cmd_args, "-t"); + + // Specifying type of bluetooth sniff + if (bt_type_sw != -1) { + String bt_type = cmd_args.get(bt_type_sw + 1); + + bt_type.toLowerCase(); + + // Airtag sniff + if (bt_type == "airtag") { + Serial.println("Starting Airtag sniff. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_AIRTAG, TFT_WHITE); } - // General bluetooth sniff - else { - Serial.println("Starting Bluetooth scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_ALL, TFT_GREEN); + else if (bt_type == "flipper") { + Serial.println("Starting Flipper sniff. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_FLIPPER, TFT_ORANGE); } - #else - Serial.println("Bluetooth not supported"); - #endif + } + // General bluetooth sniff + else { + Serial.println("Starting Bluetooth scan. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_ALL, TFT_GREEN); + } +#else + Serial.println("Bluetooth not supported"); +#endif } else if (cmd_args.get(0) == BT_SPOOFAT_CMD) { int at_sw = this->argSearch(&cmd_args, "-t"); if (at_sw != -1) { - #ifdef HAS_BT - int target_mac = cmd_args.get(at_sw + 1).toInt(); - if (target_mac < airtags->size()) { - for (int i = 0; i < airtags->size(); i++) { - AirTag at = airtags->get(i); - if (i == target_mac) - at.selected = true; - else - at.selected = false; - airtags->set(i, at); - } - Serial.println("Spoofing Airtag: " + airtags->get(target_mac).mac); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SPOOF_AIRTAG, TFT_WHITE); - } - else { - Serial.println("Provided index is out of range: " + (String)target_mac); - return; +#ifdef HAS_BT + int target_mac = cmd_args.get(at_sw + 1).toInt(); + if (target_mac < airtags->size()) { + for (int i = 0; i < airtags->size(); i++) { + AirTag at = airtags->get(i); + if (i == target_mac) + at.selected = true; + else + at.selected = false; + airtags->set(i, at); } - #endif + Serial.println("Spoofing Airtag: " + airtags->get(target_mac).mac); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SPOOF_AIRTAG, TFT_WHITE); + } + else { + Serial.println("Provided index is out of range: " + (String)target_mac); + return; + } +#endif } } else if (cmd_args.get(0) == BT_SPAM_CMD) { @@ -972,76 +1001,76 @@ void CommandLine::runCommand(String input) { String bt_type = cmd_args.get(bt_type_sw + 1); if (bt_type == "apple") { - #ifdef HAS_BT - Serial.println("Starting Sour Apple attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SOUR_APPLE, TFT_GREEN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Sour Apple attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SOUR_APPLE, TFT_GREEN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "windows") { - #ifdef HAS_BT - Serial.println("Starting Swiftpair Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SWIFTPAIR_SPAM, TFT_CYAN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Swiftpair Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SWIFTPAIR_SPAM, TFT_CYAN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "samsung") { - #ifdef HAS_BT - Serial.println("Starting Samsung Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SAMSUNG_SPAM, TFT_CYAN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Samsung Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SAMSUNG_SPAM, TFT_CYAN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "google") { - #ifdef HAS_BT - Serial.println("Starting Google Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_GOOGLE_SPAM, TFT_CYAN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Google Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_GOOGLE_SPAM, TFT_CYAN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "flipper") { - #ifdef HAS_BT - Serial.println("Starting Flipper Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_FLIPPER_SPAM, TFT_ORANGE); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Flipper Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_FLIPPER_SPAM, TFT_ORANGE); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "all") { - #ifdef HAS_BT - Serial.println("Starting BT Spam All attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SPAM_ALL, TFT_MAGENTA); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting BT Spam All attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SPAM_ALL, TFT_MAGENTA); +#else + Serial.println("Bluetooth not supported"); +#endif } else { Serial.println("You did not specify a correct spam type"); @@ -1059,8 +1088,8 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - } - else if (cmd_args.get(0) == BT_SWIFTPAIR_SPAM_CMD) { + } + else if (cmd_args.get(0) == BT_SWIFTPAIR_SPAM_CMD) { #ifdef HAS_BT Serial.println("Starting Swiftpair Spam attack. Stop with " + (String)STOPSCAN_CMD); #ifdef HAS_SCREEN @@ -1071,8 +1100,8 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - } - else if (cmd_args.get(0) == BT_SAMSUNG_SPAM_CMD) { + } + else if (cmd_args.get(0) == BT_SAMSUNG_SPAM_CMD) { #ifdef HAS_BT Serial.println("Starting Samsung Spam attack. Stop with " + (String)STOPSCAN_CMD); #ifdef HAS_SCREEN @@ -1083,8 +1112,8 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - } - else if (cmd_args.get(0) == BT_SPAM_ALL_CMD) { + } + else if (cmd_args.get(0) == BT_SPAM_ALL_CMD) { #ifdef HAS_BT Serial.println("Starting BT Spam All attack. Stop with " + (String)STOPSCAN_CMD); #ifdef HAS_SCREEN @@ -1095,52 +1124,53 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - }*/ + }*/ // Wardrive else if (cmd_args.get(0) == BT_WARDRIVE_CMD) { - #ifdef HAS_BT - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - int cont_sw = this->argSearch(&cmd_args, "-c"); - - if (cont_sw == -1) { - Serial.println("Starting BT Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE, TFT_GREEN); - } - else {Serial.println("Starting Continuous BT Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE_CONT, TFT_GREEN); - } - } - else - Serial.println("GPS Module not detected"); - #else - Serial.println("GPS not supported"); - #endif - #else - Serial.println("Bluetooth not supported"); - #endif - +#ifdef HAS_BT +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + int cont_sw = this->argSearch(&cmd_args, "-c"); + + if (cont_sw == -1) { + Serial.println("Starting BT Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE, TFT_GREEN); + } + else { + Serial.println("Starting Continuous BT Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE_CONT, TFT_GREEN); + } + } + else + Serial.println("GPS Module not detected"); +#else + Serial.println("GPS not supported"); +#endif +#else + Serial.println("Bluetooth not supported"); +#endif + } // Bluetooth CC Skimmer scan else if (cmd_args.get(0) == BT_SKIM_CMD) { - #ifdef HAS_BT - Serial.println("Starting Bluetooth CC Skimmer scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Bluetooth CC Skimmer scan. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA); +#else + Serial.println("Bluetooth not supported"); +#endif } // Update command @@ -1152,24 +1182,24 @@ void CommandLine::runCommand(String input) { //if (w_sw != -1) { // Serial.println("Starting Marauder OTA Update. Stop with " + (String)STOPSCAN_CMD); // wifi_scan_obj.currentScanMode = OTA_UPDATE; - //#ifdef HAS_SCREEN - // menu_function_obj.changeMenu(menu_function_obj.updateMenu); - //#endif + //#ifdef HAS_SCREEN + // menu_function_obj.changeMenu(menu_function_obj.updateMenu); + //#endif // web_obj.setupOTAupdate(); //} // Update via SD if (sd_sw != -1) { - #ifdef HAS_SD - if (!sd_obj.supported) { - Serial.println("SD card is not connected. Cannot perform SD Update"); - return; - } - wifi_scan_obj.currentScanMode = OTA_UPDATE; - sd_obj.runUpdate(); - #else - Serial.println("SD card support disabled. Cannot perform SD Update"); +#ifdef HAS_SD + if (!sd_obj.supported) { + Serial.println("SD card is not connected. Cannot perform SD Update"); return; - #endif + } + wifi_scan_obj.currentScanMode = OTA_UPDATE; + sd_obj.runUpdate(); +#else + Serial.println("SD card support disabled. Cannot perform SD Update"); + return; +#endif } } } @@ -1190,7 +1220,7 @@ void CommandLine::runCommand(String input) { if (access_points->get(i).selected) { Serial.println("[" + (String)i + "][CH:" + (String)access_points->get(i).channel + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi + " (selected)"); count_selected += 1; - } + } else Serial.println("[" + (String)i + "][CH:" + (String)access_points->get(i).channel + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi); } @@ -1202,7 +1232,7 @@ void CommandLine::runCommand(String input) { if (ssids->get(i).selected) { Serial.println("[" + (String)i + "] " + ssids->get(i).essid + " (selected)"); count_selected += 1; - } + } else Serial.println("[" + (String)i + "] " + ssids->get(i).essid); } @@ -1311,7 +1341,7 @@ void CommandLine::runCommand(String input) { } else if (cl_sw != -1) { LinkedList sta_index = this->parseCommand(cmd_args.get(cl_sw + 1), ","); - + // Select all Stations if (cmd_args.get(cl_sw + 1) == "all") { for (int i = 0; i < stations->size(); i++) { @@ -1398,15 +1428,15 @@ void CommandLine::runCommand(String input) { int st_sw = this->argSearch(&cmd_args, "-s"); if (ap_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.saveAPsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.saveAPsMenu); +#endif wifi_scan_obj.RunSaveAPList(true); } else if (st_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.saveSSIDsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.saveSSIDsMenu); +#endif wifi_scan_obj.RunSaveSSIDList(true); } } @@ -1415,15 +1445,15 @@ void CommandLine::runCommand(String input) { int st_sw = this->argSearch(&cmd_args, "-s"); if (ap_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.loadAPsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.loadAPsMenu); +#endif wifi_scan_obj.RunLoadAPList(); } else if (st_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.loadSSIDsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.loadSSIDsMenu); +#endif wifi_scan_obj.RunLoadSSIDList(); } } @@ -1470,11 +1500,11 @@ void CommandLine::runCommand(String input) { int n_sw = this->argSearch(&cmd_args, "-n"); // name int a_sw = this->argSearch(&cmd_args, "-a"); // access point int s_sw = this->argSearch(&cmd_args, "-s"); // ssid - int p_sw = this->argSearch(&cmd_args, "-p"); - + int p_sw = this->argSearch(&cmd_args, "-p"); + String essid = ""; String pwx = ""; - + if (s_sw != -1) { int index = cmd_args.get(s_sw + 1).toInt(); if (!this->inRange(ssids->size(), index)) { @@ -1495,11 +1525,11 @@ void CommandLine::runCommand(String input) { Serial.println("You must specify an access point or ssid"); return; } - + if (p_sw != -1) { pwx = cmd_args.get(p_sw + 1); } Serial.println("Attempting to join WiFi with ssid " + (String)essid); wifi_scan_obj.joinWiFi(essid, pwx); - }*/ + }*/ }