├── JammerV2.1.1.ino ├── UtilsJammer.cpp └── UtilsJammer.h /JammerV2.1.1.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "BluetoothSerial.h" 5 | #include 6 | #include "UtilsJammer.h" 7 | 8 | BluetoothSerial SerialBT; 9 | RF24 radio(5, 27); // CE, CSN 10 | LiquidCrystal_I2C lcd(0x27, 20, 4); // LCD address 0x27 11 | 12 | const byte address[6] = "00001"; 13 | const int maxChannels = 126; 14 | int activeChannels[maxChannels]; 15 | int activeChannelCount = 0; 16 | int transmissionDuration = 1000; 17 | int ledPin = 4; 18 | int button1 = 12; 19 | int button2 = 2; 20 | int button3 = 15; 21 | int channel = 0; 22 | int scanning = 0; 23 | volatile bool isSelected = false; 24 | char printText[100]; 25 | 26 | volatile bool stateButton1 = false; 27 | volatile bool stateButton2 = false; 28 | volatile bool stateButton3 = false; 29 | 30 | void setup() { 31 | pinMode(ledPin, OUTPUT); 32 | pinMode(button1, INPUT_PULLDOWN); 33 | pinMode(button2, INPUT_PULLDOWN); 34 | pinMode(button3, INPUT_PULLDOWN); 35 | 36 | attachInterrupt(digitalPinToInterrupt(button1), handleButton1Interrupt, RISING); 37 | attachInterrupt(digitalPinToInterrupt(button2), handleButton2Interrupt, RISING); 38 | attachInterrupt(digitalPinToInterrupt(button3), handleButton3Interrupt, RISING); 39 | 40 | Serial.begin(115200); 41 | SerialBT.begin("ESP32BT JAMMER"); 42 | 43 | radio.begin(); 44 | radio.setDataRate(RF24_250KBPS); 45 | radio.openWritingPipe(address); 46 | radio.setPALevel(RF24_PA_MAX, 1); 47 | radio.stopListening(); 48 | 49 | lcd.init(); 50 | lcd.backlight(); 51 | 52 | delay(1000); 53 | if (radio.isChipConnected() && radio.isPVariant()) { 54 | strcpy(printText, "nrf24L01+ module is connected and responding."); 55 | printAll(printText); 56 | delay(1500); 57 | strcpy(printText, "nrf24L01+ OK"); 58 | printAll(printText); 59 | } else { 60 | strcpy(printText, "nrf24L01+ Error"); 61 | printAll(printText); 62 | return; 63 | } 64 | strcpy(printText, "Setup complete"); 65 | printAll(printText); 66 | } 67 | 68 | void loop() { 69 | if (scanning < 6) { 70 | for (int channel = 0; channel <= 125; channel++) { 71 | radio.setChannel(channel); 72 | radio.startListening(); 73 | delay(5); 74 | if (radio.testCarrier() && !isChannelAlreadyDetected(channel)) { 75 | Serial.print("Activity detected on channel: "); 76 | Serial.println(channel); 77 | if (activeChannelCount < maxChannels) { 78 | activeChannels[activeChannelCount++] = channel; 79 | } 80 | } 81 | radio.stopListening(); 82 | } 83 | delay(20); 84 | scanning++; 85 | displayActiveChannels(); 86 | } 87 | 88 | 89 | const char text[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 90 | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 91 | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 92 | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 93 | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 94 | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 95 | 96 | if (isSelected) { 97 | startTransmission(text); 98 | } 99 | } 100 | 101 | void startTransmission(const char* text) { 102 | delay(500); 103 | stateButton1 = stateButton2 = stateButton3 = false; 104 | for (int i = channel; i <= channel + 23; i++) { 105 | radio.setChannel(i); 106 | radio.stopListening(); 107 | strcpy(printText, "channel selected, transmitting"); 108 | SerialBT.println(i); 109 | printAll(printText); 110 | unsigned long startTime = millis(); 111 | while (millis() - startTime < transmissionDuration) { 112 | if (stateButton1 || stateButton2 || stateButton3) { 113 | goto endTransmission; 114 | } 115 | radio.write(text, sizeof(text)); 116 | digitalWrite(ledPin, HIGH); 117 | } 118 | digitalWrite(ledPin, LOW); 119 | if (i == channel + 23) { 120 | i = channel; 121 | } 122 | } 123 | endTransmission: 124 | digitalWrite(ledPin, LOW); 125 | strcpy(printText, "End of transmission"); 126 | printAll(printText); 127 | isSelected = false; 128 | stateButton1 = stateButton2 = stateButton3 = false; 129 | delay(1200); 130 | displayActiveChannels(); 131 | } 132 | 133 | void handleButton1Interrupt() { 134 | handleInterruptCommon(&stateButton1, 12); 135 | } 136 | 137 | void handleButton2Interrupt() { 138 | handleInterruptCommon(&stateButton2, 36); 139 | } 140 | 141 | void handleButton3Interrupt() { 142 | handleInterruptCommon(&stateButton3, 60); 143 | } 144 | 145 | void handleInterruptCommon(volatile bool* stateButton, int newChannel) { 146 | static unsigned long lastInterruptTime = 0; 147 | unsigned long interruptTime = millis(); 148 | if (interruptTime - lastInterruptTime > 200) { 149 | *stateButton = true; 150 | if (isSelected) { 151 | isSelected = false; 152 | } else { 153 | channel = newChannel; 154 | isSelected = true; 155 | } 156 | } 157 | lastInterruptTime = interruptTime; 158 | } 159 | 160 | -------------------------------------------------------------------------------- /UtilsJammer.cpp: -------------------------------------------------------------------------------- 1 | // UtilsJammer.cpp 2 | #include "UtilsJammer.h" 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | extern BluetoothSerial SerialBT; 9 | extern LiquidCrystal_I2C lcd; 10 | extern int activeChannels[]; 11 | extern int activeChannelCount; 12 | 13 | 14 | void printAll(char* printText) { 15 | lcd.clear(); 16 | Serial.println(printText); 17 | SerialBT.println(printText); 18 | 19 | lcd.setCursor(0, 0); 20 | lcd.print(String(printText).substring(0, 20)); 21 | 22 | if (strlen(printText) > 20) { 23 | lcd.setCursor(0, 1); 24 | lcd.print(String(printText).substring(20, 40)); 25 | } 26 | 27 | if (strlen(printText) > 40) { 28 | lcd.setCursor(0, 2); 29 | lcd.print(String(printText).substring(40, 60)); 30 | } 31 | 32 | if (strlen(printText) > 60) { 33 | lcd.setCursor(0, 3); 34 | lcd.print(String(printText).substring(60, 80)); 35 | } 36 | } 37 | void displayActiveChannels() { 38 | lcd.clear(); 39 | lcd.setCursor(0, 0); 40 | lcd.print("Active Channels:"); 41 | 42 | int channelsPerLine = 7; 43 | 44 | for (int i = 0; i < activeChannelCount; i++) { 45 | if (i % channelsPerLine == 0) { 46 | lcd.setCursor(0, i / channelsPerLine + 1); 47 | } 48 | lcd.print(activeChannels[i]); 49 | lcd.print(" "); 50 | } 51 | } 52 | bool isChannelAlreadyDetected(int channel) { 53 | for (int i = 0; i < activeChannelCount; i++) { 54 | if (activeChannels[i] == channel) { 55 | return true; 56 | } 57 | } 58 | return false; 59 | } 60 | -------------------------------------------------------------------------------- /UtilsJammer.h: -------------------------------------------------------------------------------- 1 | // UtilsJammer.h 2 | #ifndef UtilsJammer_h 3 | #define UtilsJammer_h 4 | 5 | void printAll(char *printText); 6 | void displayActiveChannels(); 7 | bool isChannelAlreadyDetected(int channel); 8 | 9 | #endif 10 | --------------------------------------------------------------------------------