11
11
#define BT3 26 // data rate
12
12
#define BT4 25 // PA level
13
13
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);
16
27
17
28
#define SCREEN_WIDTH 128
18
29
#define SCREEN_HEIGHT 64
19
30
20
- RF24 radio (CE_PIN, CSN_PIN);
21
31
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" ;
29
39
30
40
uint8_t dataRateIndex = 0 ; // Index for cycling through data rates
31
41
uint8_t paLevelIndex = 0 ; // Index for cycling through PA levels
32
42
33
43
extern U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2;
34
44
35
45
36
-
37
46
void setRadioParameters () {
38
47
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 ;
42
51
}
43
52
44
53
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 ;
49
58
}
50
59
51
60
Serial.print (" Data Rate: " );
@@ -55,31 +64,57 @@ void setRadioParameters() {
55
64
}
56
65
57
66
void radioSetChannel (int channels) {
58
- radio.setChannel (channels);
67
+ radioA.setChannel (channels);
68
+ radioB.setChannel (channels);
69
+ radioC.setChannel (channels);
59
70
}
60
71
61
72
void 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 ) {
63
79
for (int i = ((channels * 5 ) + 1 ); i < ((channels * 5 ) + 23 ); i++) {
64
80
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
+
71
85
delay (10 );
72
86
}
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
+ }
73
108
}
74
109
75
110
void pressBt01 () {
76
111
static unsigned long last_interrupt_time = 0 ;
77
112
unsigned long interrupt_time = millis ();
78
113
if (interrupt_time - last_interrupt_time > 200 ) {
79
- if (channels < 13 ) {
114
+ if (channels < 14 ) {
80
115
channels++;
81
116
} else {
82
- channels = 0 ;
117
+ channels = 1 ;
83
118
}
84
119
Serial.print (" Channel: " );
85
120
Serial.println (channels);
@@ -119,6 +154,18 @@ void pressBt04() {
119
154
last_interrupt_time = interrupt_time;
120
155
}
121
156
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
+
122
169
void jammerSetup (){
123
170
Serial.begin (115200 );
124
171
@@ -133,17 +180,28 @@ void jammerSetup(){
133
180
134
181
SPI.begin ();
135
182
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);
138
191
139
192
u8g2.begin ();
140
193
u8g2.clearBuffer ();
141
194
u8g2.sendBuffer ();
142
195
143
- radio.begin ();
196
+
197
+ configure (radioA);
198
+ configure (radioB);
199
+ configure (radioC);
200
+
201
+ // radio.begin();
144
202
setRadioParameters ();
145
- radio.openWritingPipe (address);
146
- radio.stopListening ();
203
+ // radio.openWritingPipe(address);
204
+ // radio.stopListening();
147
205
148
206
Serial.println (" Radio configured and ready" );
149
207
}
@@ -203,9 +261,9 @@ void jammerLoop(){
203
261
delay (50 );
204
262
205
263
if (jamming) {
206
- u8g2.setCursor (80 , 60 );
264
+ u8g2.setCursor (80 , 60 );
207
265
u8g2.print (" Active " );
208
- Serial.println (" Starting jamming on channel " + String (channels + 1 ));
266
+ Serial.println (" Starting jamming on channel " + String (channels));
209
267
jammer ();
210
268
}
211
269
}
0 commit comments