mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-12 15:50:36 -08:00
Updated Menu structure
This commit is contained in:
@@ -8,7 +8,6 @@ https://github.com/bodmer
|
||||
|
||||
Display::Display()
|
||||
{
|
||||
//Serial.println("Initializing Display Object...");
|
||||
}
|
||||
|
||||
void Display::main()
|
||||
@@ -45,8 +44,6 @@ void Display::RunSetup()
|
||||
Serial.println("SPIFFS initialisation failed!");
|
||||
while (1) yield(); // Stay here twiddling thumbs waiting
|
||||
}
|
||||
//Serial.println("\r\nInitialisation done.");
|
||||
//listFiles(); // Lists the files so you can see what is in the SPIFFS
|
||||
|
||||
|
||||
// Draw the title screen
|
||||
@@ -78,14 +75,8 @@ void Display::displayBuffer(bool do_clear)
|
||||
while (display_buffer->size() > 0)
|
||||
{
|
||||
xPos = 0;
|
||||
//yDraw = scroll_line(TFT_RED);
|
||||
//tft.setCursor(xPos, yDraw);
|
||||
|
||||
//tft.print(display_buffer->shift());
|
||||
//tft.print(display_buffer->get(0));
|
||||
if ((display_buffer->size() > 0) && (!loading))
|
||||
{
|
||||
//tft.print(display_buffer->pop());
|
||||
printing = true;
|
||||
delay(print_delay_1);
|
||||
yDraw = scroll_line(TFT_RED);
|
||||
@@ -93,28 +84,10 @@ void Display::displayBuffer(bool do_clear)
|
||||
tft.print(display_buffer->shift());
|
||||
printing = false;
|
||||
delay(print_delay_2);
|
||||
//display_buffer->remove(0);
|
||||
}
|
||||
|
||||
blank[(18+(yStart - TOP_FIXED_AREA) / TEXT_HEIGHT)%19] = xPos;
|
||||
}
|
||||
|
||||
/*
|
||||
while (display_buffer->get(0) != "")
|
||||
{
|
||||
Serial.println("Printing");
|
||||
delay(10);
|
||||
xPos = 0;
|
||||
yDraw = scroll_line(TFT_RED);
|
||||
tft.setCursor(xPos, yDraw);
|
||||
if (display_buffer->get(0) != "")
|
||||
{
|
||||
tft.print(display_buffer->get(0));
|
||||
display_buffer->replace(0, "");
|
||||
}
|
||||
blank[(18+(yStart - TOP_FIXED_AREA) / TEXT_HEIGHT)%19] = xPos;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,13 +156,8 @@ void Display::scrollAddress(uint16_t vsp) {
|
||||
// JPEG_functions
|
||||
void Display::drawJpeg(const char *filename, int xpos, int ypos) {
|
||||
|
||||
//Serial.println("===========================");
|
||||
//Serial.print("Drawing file: "); Serial.println(filename);
|
||||
//Serial.println("===========================");
|
||||
|
||||
// Open the named file (the Jpeg decoder library will close it after rendering image)
|
||||
fs::File jpegFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS
|
||||
// File jpegFile = SD.open( filename, FILE_READ); // or, file handle reference for SD library
|
||||
|
||||
//ESP32 always seems to return 1 for jpegFile so this null trap does not work
|
||||
if ( !jpegFile ) {
|
||||
@@ -200,8 +168,6 @@ void Display::drawJpeg(const char *filename, int xpos, int ypos) {
|
||||
// Use one of the three following methods to initialise the decoder,
|
||||
// the filename can be a String or character array type:
|
||||
|
||||
//boolean decoded = JpegDec.decodeFsFile(jpegFile); // Pass a SPIFFS file handle to the decoder,
|
||||
//boolean decoded = JpegDec.decodeSdFile(jpegFile); // or pass the SD file handle to the decoder,
|
||||
boolean decoded = JpegDec.decodeFsFile(filename); // or pass the filename (leading / distinguishes SPIFFS files)
|
||||
|
||||
if (decoded) {
|
||||
@@ -286,11 +252,6 @@ void Display::jpegRender(int xpos, int ypos) {
|
||||
|
||||
// calculate how long it took to draw the image
|
||||
drawTime = millis() - drawTime; // Calculate the time it took
|
||||
|
||||
// print the results to the serial port
|
||||
//Serial.print ("Total render time was : "); Serial.print(drawTime); Serial.println(" ms");
|
||||
//Serial.println("=====================================");
|
||||
|
||||
}
|
||||
|
||||
//====================================================================================
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
MenuFunctions::MenuFunctions()
|
||||
{
|
||||
//Serial.println("Initializing Menu Object...");
|
||||
}
|
||||
|
||||
// Function to check menu input
|
||||
@@ -15,13 +14,9 @@ void MenuFunctions::main()
|
||||
// Get the display buffer out of the way
|
||||
if (wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF)
|
||||
display_obj.displayBuffer();
|
||||
//else
|
||||
// display_obj.displayBuffer(true);
|
||||
|
||||
//Serial.println("Cycle");
|
||||
|
||||
// Pressed will be set true is there is a valid touch on the screen
|
||||
//vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
boolean pressed = display_obj.tft.getTouch(&t_x, &t_y);
|
||||
//boolean pressed = false;
|
||||
|
||||
@@ -74,159 +69,81 @@ void MenuFunctions::main()
|
||||
if (key[b].justReleased())
|
||||
{
|
||||
key[b].drawButton2(current_menu->list->get(b).name); // draw normal
|
||||
//Serial.print("Executing button -> ");
|
||||
//Serial.println(current_menu->list->get(b).name);
|
||||
current_menu->list->get(b).callable();
|
||||
}
|
||||
display_obj.tft.setFreeFont(NULL);
|
||||
}
|
||||
|
||||
// This is if there are any scans or sniffs going on
|
||||
if(digitalRead(FLASH_BUTTON) == 0)
|
||||
{
|
||||
// Stop the current scan
|
||||
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ST) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ALL) ||
|
||||
(wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
|
||||
(wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS))
|
||||
{
|
||||
Serial.println("Stopping scan...");
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
|
||||
|
||||
// If we don't do this, the text and button coordinates will be off
|
||||
display_obj.tft.init();
|
||||
|
||||
// Take us back to the menu
|
||||
changeMenu(current_menu);
|
||||
}
|
||||
}
|
||||
|
||||
//else
|
||||
//{
|
||||
// display_obj.displayBuffer();
|
||||
//}
|
||||
x = -1;
|
||||
y = -1;
|
||||
}
|
||||
|
||||
|
||||
void MenuFunctions::handlePress(boolean pressed, uint16_t t_x, uint16_t t_y)
|
||||
{
|
||||
if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF) && (pressed))
|
||||
{
|
||||
// Stop the current scan
|
||||
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ST) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ALL) ||
|
||||
(wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
|
||||
(wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS))
|
||||
{
|
||||
Serial.println("Stopping scan...");
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
|
||||
|
||||
// If we don't do this, the text and button coordinates will be off
|
||||
display_obj.tft.init();
|
||||
|
||||
// Take us back to the menu
|
||||
changeMenu(current_menu);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// / Check if any key coordinate boxes contain the touch coordinates
|
||||
for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++) {
|
||||
if (pressed && key[b].contains(t_x, t_y)) {
|
||||
key[b].press(true); // tell the button it is pressed
|
||||
} else {
|
||||
key[b].press(false); // tell the button it is NOT pressed
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any key has changed state
|
||||
for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++) {
|
||||
display_obj.tft.setFreeFont(MENU_FONT);
|
||||
if (key[b].justPressed()) {
|
||||
key[b].drawButton2(current_menu->list->get(b).name, true); // draw invert
|
||||
}
|
||||
|
||||
// If button was just release, execute the button's function
|
||||
if (key[b].justReleased())
|
||||
{
|
||||
key[b].drawButton2(current_menu->list->get(b).name); // draw normal
|
||||
//Serial.print("Executing button -> ");
|
||||
//Serial.println(current_menu->list->get(b).name);
|
||||
current_menu->list->get(b).callable();
|
||||
}
|
||||
display_obj.tft.setFreeFont(NULL);
|
||||
}
|
||||
|
||||
// This is if there are any scans or sniffs going on
|
||||
if(digitalRead(FLASH_BUTTON) == 0)
|
||||
{
|
||||
// Stop the current scan
|
||||
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ST) ||
|
||||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ALL) ||
|
||||
(wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
|
||||
(wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS))
|
||||
{
|
||||
Serial.println("Stopping scan...");
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
|
||||
|
||||
// If we don't do this, the text and button coordinates will be off
|
||||
display_obj.tft.init();
|
||||
|
||||
// Take us back to the menu
|
||||
changeMenu(current_menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to build the menus
|
||||
void MenuFunctions::RunSetup()
|
||||
{
|
||||
// Main menu stuff
|
||||
mainMenu.list = new SimpleList<MenuNode>(); // Get list in first menu ready
|
||||
wifiMenu.list = new SimpleList<MenuNode>(); // Get list in second menu ready
|
||||
bluetoothMenu.list = new SimpleList<MenuNode>(); // Get list in third menu ready
|
||||
|
||||
// WiFi menu stuff
|
||||
wifiSnifferMenu.list = new SimpleList<MenuNode>();
|
||||
wifiScannerMenu.list = new SimpleList<MenuNode>();
|
||||
wifiAttackMenu.list = new SimpleList<MenuNode>();
|
||||
|
||||
// Bluetooth menu stuff
|
||||
bluetoothSnifferMenu.list = new SimpleList<MenuNode>();
|
||||
bluetoothScannerMenu.list = new SimpleList<MenuNode>();
|
||||
|
||||
// Work menu names
|
||||
mainMenu.name = " ESP32 Marauder ";
|
||||
wifiMenu.name = " WiFi ";
|
||||
bluetoothMenu.name = " Bluetooth ";
|
||||
wifiSnifferMenu.name = " WiFi Sniffers ";
|
||||
wifiScannerMenu.name = " WiFi Scanners";
|
||||
bluetoothSnifferMenu.name = " Bluetooth Sniffers ";
|
||||
bluetoothScannerMenu.name = " Bluetooth Scanners ";
|
||||
|
||||
// Build Main Menu
|
||||
mainMenu.parentMenu = NULL;
|
||||
addNodes(&mainMenu, "WiFi", TFT_GREEN, NULL, 0, [this](){changeMenu(&wifiMenu);});
|
||||
addNodes(&mainMenu, "Bluetooth", TFT_CYAN, NULL, 1, [this](){changeMenu(&bluetoothMenu);});
|
||||
addNodes(&mainMenu, "Pee", TFT_MAGENTA, NULL, 2, NULL);
|
||||
addNodes(&mainMenu, "Reboot", TFT_LIGHTGREY, NULL, 2, [](){ESP.restart();});
|
||||
|
||||
// Build WiFi Menu
|
||||
wifiMenu.parentMenu = &mainMenu; // Main Menu is second menu parent
|
||||
addNodes(&wifiMenu, "Back", TFT_RED, NULL, 0, [this](){changeMenu(wifiMenu.parentMenu);});
|
||||
addNodes(&wifiMenu, "Probe Request Sniff", TFT_CYAN, NULL, 1, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_PROBE);});
|
||||
addNodes(&wifiMenu, "Beacon Sniff", TFT_MAGENTA, NULL, 2, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_AP);});
|
||||
addNodes(&wifiMenu, "Sniffers", TFT_LIGHTGREY, NULL, 1, [this](){changeMenu(&wifiSnifferMenu);});
|
||||
addNodes(&wifiMenu, "Scanners", TFT_YELLOW, NULL, 1, [this](){Serial.println("Coming soon...");});
|
||||
addNodes(&wifiMenu, "Attacks", TFT_ORANGE, NULL, 1, [this](){Serial.println("Coming soon...");});
|
||||
|
||||
wifiSnifferMenu.parentMenu = &wifiMenu; // Main Menu is second menu parent
|
||||
addNodes(&wifiSnifferMenu, "Back", TFT_RED, NULL, 0, [this](){changeMenu(wifiSnifferMenu.parentMenu);});
|
||||
addNodes(&wifiSnifferMenu, "Probe Request Sniff", TFT_CYAN, NULL, 2, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_PROBE, TFT_CYAN);});
|
||||
addNodes(&wifiSnifferMenu, "Beacon Sniff", TFT_MAGENTA, NULL, 3, [this](){wifi_scan_obj.StartScan(WIFI_SCAN_AP, TFT_MAGENTA);});
|
||||
|
||||
// Build Bluetooth Menu
|
||||
bluetoothMenu.parentMenu = &mainMenu; // Second Menu is third menu parent
|
||||
addNodes(&bluetoothMenu, "Back", TFT_RED, NULL, 0, [this](){changeMenu(bluetoothMenu.parentMenu);});
|
||||
addNodes(&bluetoothMenu, "Bluetooth Sniffer", TFT_GREEN, NULL, 1, [this](){wifi_scan_obj.StartScan(BT_SCAN_ALL);});
|
||||
addNodes(&bluetoothMenu, "Detect Card Skimmers", TFT_MAGENTA, NULL, 2, [this](){wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS);});
|
||||
addNodes(&bluetoothMenu, "Sniffers", TFT_LIGHTGREY, NULL, 1, [this](){changeMenu(&bluetoothSnifferMenu);});
|
||||
addNodes(&bluetoothMenu, "Scanners", TFT_YELLOW, NULL, 1, [this](){changeMenu(&bluetoothScannerMenu);});
|
||||
|
||||
bluetoothSnifferMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent
|
||||
addNodes(&bluetoothSnifferMenu, "Back", TFT_RED, NULL, 0, [this](){changeMenu(bluetoothSnifferMenu.parentMenu);});
|
||||
addNodes(&bluetoothSnifferMenu, "Bluetooth Sniffer", TFT_GREEN, NULL, 1, [this](){wifi_scan_obj.StartScan(BT_SCAN_ALL, TFT_GREEN);});
|
||||
|
||||
bluetoothScannerMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent
|
||||
addNodes(&bluetoothScannerMenu, "Back", TFT_RED, NULL, 0, [this](){changeMenu(bluetoothScannerMenu.parentMenu);});
|
||||
addNodes(&bluetoothScannerMenu, "Detect Card Skimmers", TFT_MAGENTA, NULL, 2, [this](){wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA);});
|
||||
|
||||
|
||||
// Set the current menu to the mainMenu
|
||||
changeMenu(&mainMenu);
|
||||
|
||||
// Show the current menu
|
||||
//Serial.println("\n\nCurrent Menu Tree:");
|
||||
//Serial.println("-------------------------------");
|
||||
//showMenuList(current_menu, 0);
|
||||
//xTaskCreate(&MenuFunctions::getPresses, "getPresses", 2048, NULL, 5, NULL);
|
||||
}
|
||||
|
||||
// Function to change menu
|
||||
void MenuFunctions::changeMenu(Menu* menu)
|
||||
{
|
||||
//display_obj.clearScreen();
|
||||
display_obj.initScrollValues();
|
||||
display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
|
||||
display_obj.tft.init();
|
||||
@@ -267,19 +184,13 @@ void MenuFunctions::addNodes(Menu* menu, String name, uint16_t color, Menu* chil
|
||||
void MenuFunctions::buildButtons(Menu* menu)
|
||||
{
|
||||
Serial.println("Bulding buttons...");
|
||||
//display_obj.clearScreen();
|
||||
if (menu->list != NULL)
|
||||
{
|
||||
for (int i = 0; i < menu->list->size(); i++)
|
||||
{
|
||||
TFT_eSPI_Button new_button;
|
||||
//Serial.print("Building button -> ");
|
||||
//Serial.println(menu->list->get(i).name);
|
||||
char buf[menu->list->get(i).name.length() + 1] = {};
|
||||
menu->list->get(i).name.toCharArray(buf, menu->list->get(i).name.length() + 1);
|
||||
//for (int x = 0; x < sizeof(buf); x++)
|
||||
// Serial.print(buf[x]);
|
||||
//Serial.println();
|
||||
key[i].initButton(&display_obj.tft,
|
||||
KEY_X + 0 * (KEY_W + KEY_SPACING_X),
|
||||
KEY_Y + i * (KEY_H + KEY_SPACING_Y), // x, y, w, h, outline, fill, text
|
||||
@@ -302,6 +213,8 @@ void MenuFunctions::displayCurrentMenu()
|
||||
display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY);
|
||||
display_obj.tft.fillRect(0,0,240,16, TFT_DARKGREY);
|
||||
display_obj.tft.drawCentreString(" ESP32 Marauder ",120,0,2);
|
||||
//String current_name = ¤t_menu->parentMenu->name;
|
||||
//display_obj.tft.drawCentreString(current_name,120,0,2);
|
||||
if (current_menu->list != NULL)
|
||||
{
|
||||
display_obj.tft.setFreeFont(MENU_FONT);
|
||||
|
||||
@@ -34,6 +34,7 @@ struct MenuNode {
|
||||
|
||||
// Full Menus
|
||||
struct Menu {
|
||||
String name;
|
||||
SimpleList<MenuNode>* list;
|
||||
Menu * parentMenu;
|
||||
uint8_t selected;
|
||||
@@ -44,13 +45,22 @@ class MenuFunctions
|
||||
{
|
||||
private:
|
||||
Menu* current_menu;
|
||||
|
||||
|
||||
// Main menu stuff
|
||||
Menu mainMenu;
|
||||
Menu wifiMenu;
|
||||
Menu bluetoothMenu;
|
||||
|
||||
// WiFi menu stuff
|
||||
Menu wifiSnifferMenu;
|
||||
Menu wifiScannerMenu;
|
||||
Menu wifiAttackMenu;
|
||||
|
||||
// Bluetooth menu stuff
|
||||
Menu bluetoothSnifferMenu;
|
||||
Menu bluetoothScannerMenu;
|
||||
|
||||
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
|
||||
//SimpleList<TFT_eSPI_Button>* key;
|
||||
|
||||
void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
|
||||
void showMenuList(Menu* menu, int layer);
|
||||
@@ -64,7 +74,6 @@ class MenuFunctions
|
||||
void buildButtons(Menu* menu);
|
||||
void changeMenu(Menu* menu);
|
||||
void displayCurrentMenu();
|
||||
void handlePress(boolean pressed, uint16_t t_x, uint16_t t_y);
|
||||
void main();
|
||||
void RunSetup();
|
||||
};
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||
String display_string = "";
|
||||
String bad_list[bad_list_length] = {"HC-03", "HC-05", "HC-06"};
|
||||
//Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
|
||||
if (display_obj.display_buffer->size() >= 0)
|
||||
{
|
||||
display_string.concat(" RSSI: ");
|
||||
@@ -21,15 +19,6 @@ class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
{
|
||||
display_string.concat(advertisedDevice.getName().c_str());
|
||||
Serial.print(advertisedDevice.getName().c_str());
|
||||
/*
|
||||
for(int i = 0; i < bad_list_length; i++)
|
||||
{
|
||||
if(strcmp(advertisedDevice.getName().c_str(), bad_list[i].c_str()) == 0)
|
||||
{
|
||||
Serial.println("Found some shit");
|
||||
//digitalWrite(LED, HIGH);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
else
|
||||
@@ -46,14 +35,6 @@ class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
|
||||
Serial.println();
|
||||
|
||||
//while (1)
|
||||
//{
|
||||
// if (display_obj.display_buffer->size() == 0)
|
||||
// {
|
||||
// display_obj.display_buffer->add(display_string);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
while (display_obj.printing)
|
||||
delay(1);
|
||||
display_obj.loading = true;
|
||||
@@ -66,7 +47,6 @@ class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
class bluetoothScanSkimmersCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||
String bad_list[bad_list_length] = {"HC-03", "HC-05", "HC-06"};
|
||||
//Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
|
||||
Serial.print("Device: ");
|
||||
if(advertisedDevice.getName().length() != 0)
|
||||
{
|
||||
@@ -76,7 +56,6 @@ class bluetoothScanSkimmersCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
if(strcmp(advertisedDevice.getName().c_str(), bad_list[i].c_str()) == 0)
|
||||
{
|
||||
Serial.println("Found some shit");
|
||||
//digitalWrite(LED, HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,22 +69,21 @@ class bluetoothScanSkimmersCallback: public BLEAdvertisedDeviceCallbacks {
|
||||
|
||||
WiFiScan::WiFiScan()
|
||||
{
|
||||
//printf("WiFiScan Object initializing...");
|
||||
}
|
||||
|
||||
// Function to prepare to run a specific scan
|
||||
void WiFiScan::StartScan(uint8_t scan_mode)
|
||||
void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
|
||||
{
|
||||
if (scan_mode == WIFI_SCAN_OFF)
|
||||
StopScan(scan_mode);
|
||||
else if (scan_mode == WIFI_SCAN_PROBE)
|
||||
RunProbeScan(scan_mode);
|
||||
RunProbeScan(scan_mode, color);
|
||||
else if (scan_mode == WIFI_SCAN_AP)
|
||||
RunBeaconScan(scan_mode);
|
||||
RunBeaconScan(scan_mode, color);
|
||||
else if (scan_mode == BT_SCAN_ALL)
|
||||
RunBluetoothScan(scan_mode);
|
||||
RunBluetoothScan(scan_mode, color);
|
||||
else if (scan_mode == BT_SCAN_SKIMMERS)
|
||||
RunBluetoothScan(scan_mode);
|
||||
RunBluetoothScan(scan_mode, color);
|
||||
|
||||
WiFiScan::currentScanMode = scan_mode;
|
||||
}
|
||||
@@ -148,36 +126,18 @@ void WiFiScan::main(uint32_t currentTime)
|
||||
channelHop();
|
||||
}
|
||||
}
|
||||
|
||||
// Bluetooth operations
|
||||
/*
|
||||
else if ((currentScanMode == BT_SCAN_ALL) ||
|
||||
(currentScanMode == BT_SCAN_SKIMMERS))
|
||||
{
|
||||
if (currentTime - initTime >= 2000)
|
||||
{
|
||||
BLEScanResults foundDevices = pBLEScan->start(bluetoothScanTime, false);
|
||||
Serial.print("Devices found: ");
|
||||
Serial.print(foundDevices.getCount());
|
||||
Serial.println(" Scan done!\n\n");
|
||||
pBLEScan->clearResults();
|
||||
initTime = millis();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Function to start running a beacon scan
|
||||
void WiFiScan::RunBeaconScan(uint8_t scan_mode)
|
||||
void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
|
||||
{
|
||||
//Serial.println("Preparing beacon scan...");
|
||||
display_obj.print_delay_1 = 15;
|
||||
display_obj.print_delay_2 = 10;
|
||||
display_obj.clearScreen();
|
||||
display_obj.initScrollValues();
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setTextColor(TFT_WHITE, TFT_MAGENTA);
|
||||
display_obj.tft.fillRect(0,0,240,16, TFT_MAGENTA);
|
||||
display_obj.tft.setTextColor(TFT_WHITE, color);
|
||||
display_obj.tft.fillRect(0,0,240,16, color);
|
||||
display_obj.tft.drawCentreString(" Beacon Sniffer ",120,0,2);
|
||||
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
|
||||
@@ -190,21 +150,19 @@ void WiFiScan::RunBeaconScan(uint8_t scan_mode)
|
||||
esp_wifi_set_promiscuous_rx_cb(&beaconSnifferCallback);
|
||||
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
||||
initTime = millis();
|
||||
//Serial.println("Finished scan init");
|
||||
}
|
||||
|
||||
|
||||
// Function for running probe request scan
|
||||
void WiFiScan::RunProbeScan(uint8_t scan_mode)
|
||||
void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
|
||||
{
|
||||
//Serial.println("Preparing probe request scan...");
|
||||
display_obj.print_delay_1 = 15;
|
||||
display_obj.print_delay_2 = 10;
|
||||
display_obj.clearScreen();
|
||||
display_obj.initScrollValues();
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, TFT_CYAN);
|
||||
display_obj.tft.fillRect(0,0,240,16, TFT_CYAN);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, color);
|
||||
display_obj.tft.fillRect(0,0,240,16, color);
|
||||
display_obj.tft.drawCentreString(" Probe Request Sniffer ",120,0,2);
|
||||
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
|
||||
@@ -217,11 +175,10 @@ void WiFiScan::RunProbeScan(uint8_t scan_mode)
|
||||
esp_wifi_set_promiscuous_rx_cb(&probeSnifferCallback);
|
||||
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
||||
initTime = millis();
|
||||
//Serial.println("Finished scan init");
|
||||
}
|
||||
|
||||
// Function to start running any BLE scan
|
||||
void WiFiScan::RunBluetoothScan(uint8_t scan_mode)
|
||||
void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
|
||||
{
|
||||
display_obj.print_delay_1 = 50;
|
||||
display_obj.print_delay_2 = 20;
|
||||
@@ -232,8 +189,8 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode)
|
||||
display_obj.clearScreen();
|
||||
display_obj.initScrollValues();
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, TFT_GREEN);
|
||||
display_obj.tft.fillRect(0,0,240,16, TFT_GREEN);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, color);
|
||||
display_obj.tft.fillRect(0,0,240,16, color);
|
||||
display_obj.tft.drawCentreString(" Bluetooth Sniff ",120,0,2);
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
|
||||
@@ -244,8 +201,8 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode)
|
||||
display_obj.clearScreen();
|
||||
display_obj.initScrollValues();
|
||||
display_obj.tft.setTextWrap(false);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, TFT_MAGENTA);
|
||||
display_obj.tft.fillRect(0,0,240,16, TFT_MAGENTA);
|
||||
display_obj.tft.setTextColor(TFT_BLACK, color);
|
||||
display_obj.tft.fillRect(0,0,240,16, color);
|
||||
display_obj.tft.drawCentreString(" Detect Card Skimmers ",120,0,2);
|
||||
display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK);
|
||||
display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
|
||||
@@ -315,22 +272,12 @@ void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type
|
||||
|
||||
Serial.print(" ");
|
||||
|
||||
//while (display_obj.display_buffer->get(0) != "")
|
||||
// delay(10);
|
||||
//while (display_obj.display_buffer->size() > 0)
|
||||
// delay(10);
|
||||
|
||||
if (display_obj.display_buffer->size() == 0)
|
||||
{
|
||||
//while (display_obj.printing)
|
||||
// delay(1);
|
||||
display_obj.loading = true;
|
||||
display_obj.display_buffer->add(display_string);
|
||||
display_obj.loading = false;
|
||||
}
|
||||
//display_obj.display_buffer->add(0, display_string);
|
||||
|
||||
//Serial.print(display_obj.display_buffer->size());
|
||||
|
||||
|
||||
|
||||
@@ -410,6 +357,5 @@ void WiFiScan::channelHop()
|
||||
set_channel = 1;
|
||||
}
|
||||
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
|
||||
//Serial.println(set_channel);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ class WiFiScan
|
||||
uint8_t payload[0];
|
||||
} wifi_ieee80211_packet_t;
|
||||
|
||||
void RunBeaconScan(uint8_t scan_mode);
|
||||
void RunProbeScan(uint8_t scan_mode);
|
||||
void RunBluetoothScan(uint8_t scan_mode);
|
||||
void RunBeaconScan(uint8_t scan_mode, uint16_t color);
|
||||
void RunProbeScan(uint8_t scan_mode, uint16_t color);
|
||||
void RunBluetoothScan(uint8_t scan_mode, uint16_t color);
|
||||
static void scanCompleteCB(BLEScanResults scanResults);
|
||||
|
||||
public:
|
||||
@@ -61,14 +61,11 @@ class WiFiScan
|
||||
void channelHop();
|
||||
uint8_t currentScanMode = 0;
|
||||
void main(uint32_t currentTime);
|
||||
void StartScan(uint8_t scan_mode);
|
||||
void StartScan(uint8_t scan_mode, uint16_t color = 0);
|
||||
void StopScan(uint8_t scan_mode);
|
||||
|
||||
//static String bad_list[bad_list_length] = {"HC-03", "HC-05", "HC-06"};
|
||||
|
||||
static void getMAC(char *addr, uint8_t* data, uint16_t offset);
|
||||
static void beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
|
||||
static void probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
|
||||
//static void sniffer_callback(void* buf, wifi_promiscuous_pkt_type_t type);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -18,34 +18,6 @@ MenuFunctions menu_function_obj;
|
||||
|
||||
uint32_t currentTime = 0;
|
||||
|
||||
/*
|
||||
void getPresses(void *pvParameter)
|
||||
{
|
||||
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
|
||||
|
||||
while (true)
|
||||
{
|
||||
boolean pressed = display_obj.tft.getTouch(&t_x, &t_y);
|
||||
Serial.print("X: ");
|
||||
Serial.print(t_x);
|
||||
Serial.print(" Y: ");
|
||||
Serial.println(t_y);
|
||||
|
||||
menu_function_obj.pressed = pressed;
|
||||
|
||||
|
||||
//menu_function_obj.handlePress(pressed, t_x, t_y);
|
||||
if (pressed)
|
||||
{
|
||||
menu_function_obj.x = t_x;
|
||||
menu_function_obj.y = t_y;
|
||||
}
|
||||
|
||||
|
||||
delay(1);
|
||||
}
|
||||
}*/
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
@@ -63,16 +35,6 @@ void setup()
|
||||
|
||||
// Build menus
|
||||
menu_function_obj.RunSetup();
|
||||
//menu_function_obj.displayCurrentMenu();
|
||||
|
||||
//xTaskCreate(&getPresses, "getPresses", 2048, NULL, 5, NULL);
|
||||
|
||||
|
||||
// Start a scan mode automatically
|
||||
// In the real version, just setup wifi
|
||||
// and wait for user input for scan modes
|
||||
//wifi_scan_obj.StartScan(WIFI_SCAN_PROBE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +46,7 @@ void loop()
|
||||
// Update all of our objects
|
||||
display_obj.main();
|
||||
wifi_scan_obj.main(currentTime);
|
||||
//if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF)
|
||||
menu_function_obj.main();
|
||||
|
||||
//vTaskDelay(portMAX_DELAY);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user