mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 07:29:14 -08:00
List and select commands now report counts of selected/unselected items
This commit is contained in:
@@ -99,6 +99,15 @@ bool CommandLine::hasSSIDs() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommandLine::showCounts(int selected, int unselected) {
|
||||||
|
Serial.print((String) selected + " selected");
|
||||||
|
|
||||||
|
if (unselected != -1)
|
||||||
|
Serial.print(", " + (String) unselected + " unselected");
|
||||||
|
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
|
|
||||||
void CommandLine::runCommand(String input) {
|
void CommandLine::runCommand(String input) {
|
||||||
if (input != "")
|
if (input != "")
|
||||||
Serial.println("#" + input);
|
Serial.println("#" + input);
|
||||||
@@ -542,6 +551,7 @@ void CommandLine::runCommand(String input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int count_selected = 0;
|
||||||
//// WiFi aux commands
|
//// WiFi aux commands
|
||||||
// List access points
|
// List access points
|
||||||
if (cmd_args.get(0) == LIST_AP_CMD) {
|
if (cmd_args.get(0) == LIST_AP_CMD) {
|
||||||
@@ -552,20 +562,26 @@ void CommandLine::runCommand(String input) {
|
|||||||
// List APs
|
// List APs
|
||||||
if (ap_sw != -1) {
|
if (ap_sw != -1) {
|
||||||
for (int i = 0; i < access_points->size(); i++) {
|
for (int i = 0; i < access_points->size(); i++) {
|
||||||
if (access_points->get(i).selected)
|
if (access_points->get(i).selected) {
|
||||||
Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi + " (selected)");
|
Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi + " (selected)");
|
||||||
|
count_selected += 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi);
|
Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi);
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected);
|
||||||
}
|
}
|
||||||
// List SSIDs
|
// List SSIDs
|
||||||
else if (ss_sw != -1) {
|
else if (ss_sw != -1) {
|
||||||
for (int i = 0; i < ssids->size(); i++) {
|
for (int i = 0; i < ssids->size(); i++) {
|
||||||
if (ssids->get(i).selected)
|
if (ssids->get(i).selected) {
|
||||||
Serial.println("[" + (String)i + "] " + ssids->get(i).essid + " (selected)");
|
Serial.println("[" + (String)i + "] " + ssids->get(i).essid + " (selected)");
|
||||||
|
count_selected += 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Serial.println("[" + (String)i + "] " + ssids->get(i).essid);
|
Serial.println("[" + (String)i + "] " + ssids->get(i).essid);
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected);
|
||||||
}
|
}
|
||||||
// List Stations
|
// List Stations
|
||||||
else if (cl_sw != -1) {
|
else if (cl_sw != -1) {
|
||||||
@@ -578,6 +594,7 @@ void CommandLine::runCommand(String input) {
|
|||||||
Serial.print(" [" + (String)access_points->get(x).stations->get(i) + "] ");
|
Serial.print(" [" + (String)access_points->get(x).stations->get(i) + "] ");
|
||||||
Serial.print(sta_mac);
|
Serial.print(sta_mac);
|
||||||
Serial.println(" (selected)");
|
Serial.println(" (selected)");
|
||||||
|
count_selected += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.print(" [" + (String)access_points->get(x).stations->get(i) + "] ");
|
Serial.print(" [" + (String)access_points->get(x).stations->get(i) + "] ");
|
||||||
@@ -585,6 +602,7 @@ void CommandLine::runCommand(String input) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.println("You did not specify which list to show");
|
Serial.println("You did not specify which list to show");
|
||||||
@@ -598,6 +616,8 @@ void CommandLine::runCommand(String input) {
|
|||||||
int ss_sw = this->argSearch(&cmd_args, "-s");
|
int ss_sw = this->argSearch(&cmd_args, "-s");
|
||||||
int cl_sw = this->argSearch(&cmd_args, "-c");
|
int cl_sw = this->argSearch(&cmd_args, "-c");
|
||||||
|
|
||||||
|
count_selected = 0;
|
||||||
|
int count_unselected = 0;
|
||||||
// select Access points
|
// select Access points
|
||||||
if (ap_sw != -1) {
|
if (ap_sw != -1) {
|
||||||
// Get list of indices
|
// Get list of indices
|
||||||
@@ -611,14 +631,17 @@ void CommandLine::runCommand(String input) {
|
|||||||
AccessPoint new_ap = access_points->get(i);
|
AccessPoint new_ap = access_points->get(i);
|
||||||
new_ap.selected = false;
|
new_ap.selected = false;
|
||||||
access_points->set(i, new_ap);
|
access_points->set(i, new_ap);
|
||||||
|
count_unselected += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Select "unselected" ap
|
// Select "unselected" ap
|
||||||
AccessPoint new_ap = access_points->get(i);
|
AccessPoint new_ap = access_points->get(i);
|
||||||
new_ap.selected = true;
|
new_ap.selected = true;
|
||||||
access_points->set(i, new_ap);
|
access_points->set(i, new_ap);
|
||||||
|
count_selected += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected, count_unselected);
|
||||||
}
|
}
|
||||||
// Select specific APs
|
// Select specific APs
|
||||||
else {
|
else {
|
||||||
@@ -634,14 +657,17 @@ void CommandLine::runCommand(String input) {
|
|||||||
AccessPoint new_ap = access_points->get(index);
|
AccessPoint new_ap = access_points->get(index);
|
||||||
new_ap.selected = false;
|
new_ap.selected = false;
|
||||||
access_points->set(index, new_ap);
|
access_points->set(index, new_ap);
|
||||||
|
count_unselected += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Select "unselected" ap
|
// Select "unselected" ap
|
||||||
AccessPoint new_ap = access_points->get(index);
|
AccessPoint new_ap = access_points->get(index);
|
||||||
new_ap.selected = true;
|
new_ap.selected = true;
|
||||||
access_points->set(index, new_ap);
|
access_points->set(index, new_ap);
|
||||||
|
count_selected += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected, count_unselected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cl_sw != -1) {
|
else if (cl_sw != -1) {
|
||||||
@@ -655,14 +681,17 @@ void CommandLine::runCommand(String input) {
|
|||||||
Station new_sta = stations->get(i);
|
Station new_sta = stations->get(i);
|
||||||
new_sta.selected = false;
|
new_sta.selected = false;
|
||||||
stations->set(i, new_sta);
|
stations->set(i, new_sta);
|
||||||
|
count_unselected += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Select "unselected" ap
|
// Select "unselected" ap
|
||||||
Station new_sta = stations->get(i);
|
Station new_sta = stations->get(i);
|
||||||
new_sta.selected = true;
|
new_sta.selected = true;
|
||||||
stations->set(i, new_sta);
|
stations->set(i, new_sta);
|
||||||
|
count_selected += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected, count_unselected);
|
||||||
}
|
}
|
||||||
// Select specific Stations
|
// Select specific Stations
|
||||||
else {
|
else {
|
||||||
@@ -678,14 +707,17 @@ void CommandLine::runCommand(String input) {
|
|||||||
Station new_sta = stations->get(index);
|
Station new_sta = stations->get(index);
|
||||||
new_sta.selected = false;
|
new_sta.selected = false;
|
||||||
stations->set(index, new_sta);
|
stations->set(index, new_sta);
|
||||||
|
count_unselected += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Select "unselected" ap
|
// Select "unselected" ap
|
||||||
Station new_sta = stations->get(index);
|
Station new_sta = stations->get(index);
|
||||||
new_sta.selected = true;
|
new_sta.selected = true;
|
||||||
stations->set(index, new_sta);
|
stations->set(index, new_sta);
|
||||||
|
count_selected += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected, count_unselected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// select ssids
|
// select ssids
|
||||||
@@ -705,14 +737,17 @@ void CommandLine::runCommand(String input) {
|
|||||||
ssid new_ssid = ssids->get(index);
|
ssid new_ssid = ssids->get(index);
|
||||||
new_ssid.selected = false;
|
new_ssid.selected = false;
|
||||||
ssids->set(index, new_ssid);
|
ssids->set(index, new_ssid);
|
||||||
|
count_unselected += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Select "unselected" ap
|
// Select "unselected" ap
|
||||||
ssid new_ssid = ssids->get(index);
|
ssid new_ssid = ssids->get(index);
|
||||||
new_ssid.selected = true;
|
new_ssid.selected = true;
|
||||||
ssids->set(index, new_ssid);
|
ssids->set(index, new_ssid);
|
||||||
|
count_selected += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->showCounts(count_selected, count_unselected);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.println("You did not specify which list to select from");
|
Serial.println("You did not specify which list to select from");
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class CommandLine {
|
|||||||
bool inRange(int max, int index);
|
bool inRange(int max, int index);
|
||||||
bool apSelected();
|
bool apSelected();
|
||||||
bool hasSSIDs();
|
bool hasSSIDs();
|
||||||
|
void showCounts(int selected, int unselected = -1);
|
||||||
int argSearch(LinkedList<String>* cmd_args, String key);
|
int argSearch(LinkedList<String>* cmd_args, String key);
|
||||||
|
|
||||||
const char* ascii_art =
|
const char* ascii_art =
|
||||||
|
|||||||
Reference in New Issue
Block a user