1111#define BT3 26 // data rate
1212#define BT4 25 // PA level
1313
14- #define CE_PIN 5
15- #define CSN_PIN 17
14+
15+ #define CE_A 5
16+ #define CSN_A 17
17+
18+ #define CE_B 16
19+ #define CSN_B 4
20+
21+ #define CE_C 15
22+ #define CSN_C 2
23+
24+ RF24 radioA (CE_A, CSN_A);
25+ RF24 radioB (CE_B, CSN_B);
26+ RF24 radioC (CE_C, CSN_C);
1627
1728#define SCREEN_WIDTH 128
1829#define SCREEN_HEIGHT 64
1930
20- RF24 radio (CE_PIN, CSN_PIN);
2131
22- const int num_channels = 64 ;
23- int value[num_channels];
24- int valuesDisplay[32 ];
25- int channels = 1 ;
26- const int num_reps = 50 ;
27- bool jamming = false ;
28- const byte address[6 ] = " 00001" ;
32+ const int num_channels = 64 ;
33+ int value[num_channels];
34+ int valuesDisplay[32 ];
35+ int channels = 1 ;
36+ const int num_reps = 50 ;
37+ bool jamming = false ;
38+ const byte address[6 ] = " 00001" ;
2939
3040uint8_t dataRateIndex = 0 ; // Index for cycling through data rates
3141uint8_t paLevelIndex = 0 ; // Index for cycling through PA levels
3242
3343extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2;
3444
3545
36-
3746void setRadioParameters () {
3847 switch (dataRateIndex) {
39- case 0 : radio .setDataRate (RF24_250KBPS); break ;
40- case 1 : radio .setDataRate (RF24_1MBPS); break ;
41- case 2 : radio .setDataRate (RF24_2MBPS); break ;
48+ case 0 : radioA. setDataRate (RF24_250KBPS); radioB. setDataRate (RF24_250KBPS); radioC .setDataRate (RF24_250KBPS); break ;
49+ case 1 : radioA. setDataRate (RF24_1MBPS); radioB. setDataRate (RF24_1MBPS); radioC .setDataRate (RF24_1MBPS); break ;
50+ case 2 : radioA .setDataRate (RF24_2MBPS); radioB. setDataRate (RF24_2MBPS); radioC. setDataRate (RF24_2MBPS); break ;
4251 }
4352
4453 switch (paLevelIndex) {
45- case 0 : radio .setPALevel (RF24_PA_MIN); break ;
46- case 1 : radio .setPALevel (RF24_PA_LOW); break ;
47- case 2 : radio .setPALevel (RF24_PA_HIGH); break ;
48- case 3 : radio .setPALevel (RF24_PA_MAX); break ;
54+ case 0 : radioA. setPALevel (RF24_PA_MIN); radioB. setPALevel (RF24_PA_MIN); radioC .setPALevel (RF24_PA_MIN); break ;
55+ case 1 : radioA. setPALevel (RF24_PA_LOW); radioB. setPALevel (RF24_PA_LOW); radioC .setPALevel (RF24_PA_LOW); break ;
56+ case 2 : radioA. setPALevel (RF24_PA_HIGH); radioB. setPALevel (RF24_PA_HIGH); radioC .setPALevel (RF24_PA_HIGH); break ;
57+ case 3 : radioA. setPALevel (RF24_PA_MAX); radioB. setPALevel (RF24_PA_MAX); radioC .setPALevel (RF24_PA_MAX); break ;
4958 }
5059
5160 Serial.print (" Data Rate: " );
@@ -55,31 +64,57 @@ void setRadioParameters() {
5564}
5665
5766void radioSetChannel (int channels) {
58- radio.setChannel (channels);
67+ radioA.setChannel (channels);
68+ radioB.setChannel (channels);
69+ radioC.setChannel (channels);
5970}
6071
6172void jammer () {
62- const char text[] = " xxxxxxxxxxxxxxxx" ;
73+ int methode = 1 ;
74+
75+ const char text[] = { 0xAA , 0x55 , 0xAA , 0x55 , 0xAA , 0x55 , 0xAA , 0x55 ,
76+ 0xAA , 0x55 , 0xAA , 0x55 , 0xAA , 0x55 , 0xAA , 0x55 };
77+
78+ if (methode = 0 ) {
6379 for (int i = ((channels * 5 ) + 1 ); i < ((channels * 5 ) + 23 ); i++) {
6480 radioSetChannel (i);
65- bool result = radio.write (&text, sizeof (text));
66- if (result) {
67- Serial.println (" Transmission successful" );
68- } else {
69- Serial.println (" Transmission failed" );
70- }
81+ bool resultA = radioA.write (&text, sizeof (text));
82+ bool resultB = radioB.write (&text, sizeof (text));
83+ bool resultC = radioC.write (&text, sizeof (text));
84+
7185 delay (10 );
7286 }
87+ }
88+
89+ if (methode = 1 ) {
90+ for (int i = 0 ; i < 22 ; i++) { // Jam across 22 channels
91+ int channelA = ((channels * 5 ) + 1 ) + i;
92+ int channelB = ((channels * 5 ) + 1 ) + i + 1 ;
93+ int channelC = ((channels * 5 ) + 1 ) + i + 2 ;
94+
95+ // Set each radio to a different channel
96+ radioA.setChannel (channelA);
97+ radioB.setChannel (channelB);
98+ radioC.setChannel (channelC);
99+
100+ // Transmit payload on all three channels simultaneously
101+ radioA.write (&text, sizeof (text));
102+ radioB.write (&text, sizeof (text));
103+ radioC.write (&text, sizeof (text));
104+
105+ delay (10 ); // Delay before hopping to the next set of channels
106+ }
107+ }
73108}
74109
75110void pressBt01 () {
76111 static unsigned long last_interrupt_time = 0 ;
77112 unsigned long interrupt_time = millis ();
78113 if (interrupt_time - last_interrupt_time > 200 ) {
79- if (channels < 13 ) {
114+ if (channels < 14 ) {
80115 channels++;
81116 } else {
82- channels = 0 ;
117+ channels = 1 ;
83118 }
84119 Serial.print (" Channel: " );
85120 Serial.println (channels);
@@ -119,6 +154,18 @@ void pressBt04() {
119154 last_interrupt_time = interrupt_time;
120155}
121156
157+ void configure (RF24 &radio) {
158+ radio.begin ();
159+ radio.openWritingPipe (0xFFFFFFFFFF );
160+ // radio.setAutoAck(false);
161+ radio.powerDown ();
162+ delay (500 );
163+ radio.powerUp ();
164+ radio.setPALevel (RF24_PA_MIN);
165+ radio.setDataRate (RF24_250KBPS);
166+ radio.stopListening ();
167+ }
168+
122169void jammerSetup (){
123170 Serial.begin (115200 );
124171
@@ -133,17 +180,28 @@ void jammerSetup(){
133180
134181 SPI.begin ();
135182
136- pinMode (CE_PIN, OUTPUT);
137- pinMode (CSN_PIN, OUTPUT);
183+ pinMode (CE_A, OUTPUT);
184+ pinMode (CSN_A, OUTPUT);
185+
186+ pinMode (CE_B, OUTPUT);
187+ pinMode (CSN_B, OUTPUT);
188+
189+ pinMode (CE_C, OUTPUT);
190+ pinMode (CSN_C, OUTPUT);
138191
139192 u8g2.begin ();
140193 u8g2.clearBuffer ();
141194 u8g2.sendBuffer ();
142195
143- radio.begin ();
196+
197+ configure (radioA);
198+ configure (radioB);
199+ configure (radioC);
200+
201+ // radio.begin();
144202 setRadioParameters ();
145- radio.openWritingPipe (address);
146- radio.stopListening ();
203+ // radio.openWritingPipe(address);
204+ // radio.stopListening();
147205
148206 Serial.println (" Radio configured and ready" );
149207}
@@ -203,9 +261,9 @@ void jammerLoop(){
203261 delay (50 );
204262
205263 if (jamming) {
206- u8g2.setCursor (80 , 60 );
264+ u8g2.setCursor (80 , 60 );
207265 u8g2.print (" Active " );
208- Serial.println (" Starting jamming on channel " + String (channels + 1 ));
266+ Serial.println (" Starting jamming on channel " + String (channels));
209267 jammer ();
210268 }
211269}
0 commit comments