aboutsummaryrefslogtreecommitdiff
path: root/src/rf/nrf24.cpp
diff options
context:
space:
mode:
authorkrolyxon <me@krolyxon.com>2026-05-14 23:19:41 +0530
committerkrolyxon <me@krolyxon.com>2026-05-14 23:19:41 +0530
commit58c9c8f51dcec555250195d127a49572c1b9fd9a (patch)
treebbf6f4003fbb36882ee81ed511eec66fd15e735f /src/rf/nrf24.cpp
parent206ed229198be252a9ae94342b39618aaab55925 (diff)
add .clang-format, and apply formatting
Diffstat (limited to 'src/rf/nrf24.cpp')
-rw-r--r--src/rf/nrf24.cpp211
1 files changed, 106 insertions, 105 deletions
diff --git a/src/rf/nrf24.cpp b/src/rf/nrf24.cpp
index fb6e1ee..dad0f11 100644
--- a/src/rf/nrf24.cpp
+++ b/src/rf/nrf24.cpp
@@ -21,19 +21,19 @@ const byte zigbee_channels[] = {11, 15, 20, 25};
const byte rc_channels[] = {1, 3, 5, 7};
void initNRF(RF24 &radio) {
- if (!radio.begin(RADIO_SPI)) {
- Serial.println("NRF not found");
- return;
- }
-
- radio.setAutoAck(false);
- radio.stopListening();
- radio.setRetries(0, 0);
- radio.setPALevel(RF24_PA_MAX, true);
- radio.setDataRate(RF24_2MBPS);
- radio.openWritingPipe(0xE7E7E7E7E7LL);
- radio.setCRCLength(RF24_CRC_DISABLED);
- Serial.println("NRF Initialized");
+ if (!radio.begin(RADIO_SPI)) {
+ Serial.println("NRF not found");
+ return;
+ }
+
+ radio.setAutoAck(false);
+ radio.stopListening();
+ radio.setRetries(0, 0);
+ radio.setPALevel(RF24_PA_MAX, true);
+ radio.setDataRate(RF24_2MBPS);
+ radio.openWritingPipe(0xE7E7E7E7E7LL);
+ radio.setCRCLength(RF24_CRC_DISABLED);
+ Serial.println("NRF Initialized");
}
// void startBleJammer() {
@@ -110,107 +110,108 @@ void initNRF(RF24 &radio) {
// }
void startJammer(const char *name, const byte *channels, size_t channelCount) {
- initNRF(radio1);
- initNRF(radio2);
-
- Serial.println("NRF JAMMER STARTED");
-
- const char payload[] = "xxxxxxxxxxxxxxxx";
-
- u8g2.clearBuffer();
- u8g2.setFont(u8g2_font_6x10_tr);
- u8g2.drawStr(0, 15, "NRF24 Jammer");
- u8g2.drawStr(0, 35, name);
- u8g2.drawStr(0, 55, "BACK = Exit");
- u8g2.sendBuffer();
-
- while (true) {
- for (size_t i = 0; i < channelCount; i++) {
- // radio1.setChannel(channels[i]);
- // radio1.write(&payload, sizeof(payload));
-
- // Optional second NRF
- // radio2.setChannel(channels[i]);
- // radio2.write(&payload, sizeof(payload));
-
- radio1.setChannel(channels[i]);
- radio2.setChannel(channels[(i + 1) % channelCount]);
-
- radio1.writeFast(&payload, sizeof(payload));
- radio2.writeFast(&payload, sizeof(payload));
+ initNRF(radio1);
+ initNRF(radio2);
+
+ Serial.println("NRF JAMMER STARTED");
+
+ const char payload[] = "xxxxxxxxxxxxxxxx";
+
+ u8g2.clearBuffer();
+ u8g2.setFont(u8g2_font_6x10_tr);
+ u8g2.drawStr(0, 15, "NRF24 Jammer");
+ u8g2.drawStr(0, 35, name);
+ u8g2.drawStr(0, 55, "BACK = Exit");
+ u8g2.sendBuffer();
+
+ while (true) {
+ for (size_t i = 0; i < channelCount; i++) {
+ // radio1.setChannel(channels[i]);
+ // radio1.write(&payload, sizeof(payload));
+
+ // Optional second NRF
+ // radio2.setChannel(channels[i]);
+ // radio2.write(&payload, sizeof(payload));
+
+ radio1.setChannel(channels[i]);
+ radio2.setChannel(channels[(i + 1) % channelCount]);
+
+ radio1.writeFast(&payload, sizeof(payload));
+ radio2.writeFast(&payload, sizeof(payload));
+ }
+
+ if (btnBack()) {
+ Serial.println("Jammer stopped");
+ radio1.powerDown();
+ radio2.powerDown();
+ return;
+ }
}
- if (btnBack()) {
- Serial.println("Jammer stopped");
- radio1.powerDown();
- radio2.powerDown();
- return;
- }
- }
-
- // while (true) {
- // for (size_t i = 0; i < channelCount; i++)
- //{
- // radio1.setChannel(channels[i]);
- // radio2.setChannel(channels[(i + 1) % channelCount]);
+ // while (true) {
+ // for (size_t i = 0; i < channelCount; i++)
+ //{
+ // radio1.setChannel(channels[i]);
+ // radio2.setChannel(channels[(i + 1) % channelCount]);
- // radio1.writeFast(&payload, sizeof(payload));
- // radio2.writeFast(&payload, sizeof(payload));
+ // radio1.writeFast(&payload, sizeof(payload));
+ // radio2.writeFast(&payload, sizeof(payload));
- // radio1.txStandBy(1);
- // radio2.txStandBy(1);
+ // radio1.txStandBy(1);
+ // radio2.txStandBy(1);
- // delayMicroseconds(200);
- //}
+ // delayMicroseconds(200);
+ //}
- // if (btnBack())
- //{
- // Serial.println("Jammer stopped");
+ // if (btnBack())
+ //{
+ // Serial.println("Jammer stopped");
- // radio1.powerDown();
- // radio2.powerDown();
+ // radio1.powerDown();
+ // radio2.powerDown();
- // return;
- //}
- //}
+ // return;
+ //}
+ //}
}
void NRFToolsMenu(int index) {
- switch (index) {
- case 0:
- // startBleJammer();
- // BLE
- startJammer("BLE", bleChannels,
- sizeof(bleChannels) / sizeof(bleChannels[0]));
-
- break;
- case 1:
- // startBluetoothJammer();
- // Bluetooth
- startJammer("Bluetooth", bluetoothChannels,
- sizeof(bluetoothChannels) / sizeof(bluetoothChannels[0]));
- break;
-
- case 2:
- startJammer("WiFi", wifiChannels,
- sizeof(wifiChannels) / sizeof(wifiChannels[0]));
- break;
- case 3:
- startJammer("USB Wireless", usbWireless_channels,
- sizeof(usbWireless_channels) / sizeof(usbWireless_channels[0]));
- break;
- case 4:
- startJammer("Video TX", videoTransmitter_channels,
- sizeof(videoTransmitter_channels) /
- sizeof(videoTransmitter_channels[0]));
- break;
- case 5:
- break;
- startJammer("RC", rc_channels,
- sizeof(rc_channels) / sizeof(rc_channels[0]));
- break;
- case 6:
-
- break;
- }
+ switch (index) {
+ case 0:
+ // startBleJammer();
+ // BLE
+ startJammer("BLE", bleChannels,
+ sizeof(bleChannels) / sizeof(bleChannels[0]));
+
+ break;
+ case 1:
+ // startBluetoothJammer();
+ // Bluetooth
+ startJammer("Bluetooth", bluetoothChannels,
+ sizeof(bluetoothChannels) / sizeof(bluetoothChannels[0]));
+ break;
+
+ case 2:
+ startJammer("WiFi", wifiChannels,
+ sizeof(wifiChannels) / sizeof(wifiChannels[0]));
+ break;
+ case 3:
+ startJammer("USB Wireless", usbWireless_channels,
+ sizeof(usbWireless_channels) /
+ sizeof(usbWireless_channels[0]));
+ break;
+ case 4:
+ startJammer("Video TX", videoTransmitter_channels,
+ sizeof(videoTransmitter_channels) /
+ sizeof(videoTransmitter_channels[0]));
+ break;
+ case 5:
+ break;
+ startJammer("RC", rc_channels,
+ sizeof(rc_channels) / sizeof(rc_channels[0]));
+ break;
+ case 6:
+
+ break;
+ }
}