Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ SPIClass CC_NRF_SPI(VSPI);
SPIClass CC_NRF_SPI(HSPI);
#endif

// Shared SPI bus mutex for CC_NRF_SPI (coordinates access between NRF24, CC1101, LoRa, W5500)
SemaphoreHandle_t cc_nrf_spi_mutex = NULL;

// Navigation Variables
volatile bool NextPress = false;
volatile bool PrevPress = false;
Expand Down Expand Up @@ -412,6 +415,10 @@ void startup_sound() {
** Where the devices are started and variables set
*********************************************************************/
void setup() {

// Create shared SPI bus mutex for CC_NRF_SPI (NRF24, CC1101, LoRa, W5500)
cc_nrf_spi_mutex = xSemaphoreCreateMutex();

Serial.setRxBufferSize(
SAFE_STACK_BUFFER_SIZE / 4
); // Must be invoked before Serial.begin(). Default is 256 chars
Expand Down
33 changes: 33 additions & 0 deletions src/modules/NRF24/nrf_jammer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "esp_phy_init.h"
#include "esp_wifi.h"
/**
* @file nrf_jammer.cpp
* @brief Enhanced 2.4 GHz jammer with 12 modes and dual strategy.
Expand All @@ -17,6 +19,11 @@
*/

#include "nrf_jammer.h"
#include "esp32-hal-semaphore.h"

// Shared SPI bus mutex (defined in main.cpp)
extern SemaphoreHandle_t cc_nrf_spi_mutex;

#include "core/display.h"
#include "core/mykeyboard.h"
#include <LittleFS.h>
Expand Down Expand Up @@ -599,6 +606,17 @@ static void runJammer(NRF24_MODE nrfMode, NrfJamMode jamMode) {
vTaskDelay(50 / portTICK_PERIOD_MS);
}


// Power down WiFi PHY during jamming to clear 2.4GHz band
wifi_mode_t savedWifiMode = WIFI_MODE_NULL;
esp_wifi_get_mode(&savedWifiMode);
if (savedWifiMode != WIFI_MODE_NULL) {
esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
esp_wifi_stop();
esp_phy_disable();
delay(10); // Wait for RF front-end to settle
}

bool running = true;
bool redraw = false;

Expand Down Expand Up @@ -630,6 +648,7 @@ static void runJammer(NRF24_MODE nrfMode, NrfJamMode jamMode) {
// ── Config: press SEL to edit mode config ───────────────
if (check(SelPress)) {
if (CHECK_NRF_SPI(nrfMode)) NRFradio.stopConstCarrier();

editModeConfig(currentMode);

// Re-apply config after edit
Expand Down Expand Up @@ -659,6 +678,7 @@ static void runJammer(NRF24_MODE nrfMode, NrfJamMode jamMode) {
bool nowFlood = (cfg.strategy >= 1);
if (prevFlood != nowFlood) {
NRFradio.stopConstCarrier();

if (nowFlood) {
applyJamConfig(cfg, true);
} else {
Expand All @@ -683,6 +703,7 @@ static void runJammer(NRF24_MODE nrfMode, NrfJamMode jamMode) {
bool nowFlood = (cfg.strategy >= 1);
if (prevFlood != nowFlood) {
NRFradio.stopConstCarrier();

if (nowFlood) {
applyJamConfig(cfg, true);
} else {
Expand Down Expand Up @@ -742,9 +763,16 @@ static void runJammer(NRF24_MODE nrfMode, NrfJamMode jamMode) {
// ── Cleanup ─────────────────────────────────────────────────
if (CHECK_NRF_SPI(nrfMode)) {
NRFradio.stopConstCarrier();

NRFradio.flush_tx();
NRFradio.powerDown();
}
// Restore WiFi state after jamming completes
if (savedWifiMode != WIFI_MODE_NULL) {
esp_wifi_set_mode(savedWifiMode);
esp_wifi_start();
}

if (CHECK_NRF_UART(nrfMode) || CHECK_NRF_BOTH(nrfMode)) { NRFSerial.println("OFF"); }
}

Expand Down Expand Up @@ -896,6 +924,7 @@ void nrf_channel_jammer() {
if (CHECK_NRF_SPI(mode)) {
if (paused) {
NRFradio.stopConstCarrier();

} else {
initCW(channel);
}
Expand Down Expand Up @@ -924,6 +953,7 @@ void nrf_channel_jammer() {
}

if (CHECK_NRF_SPI(mode)) NRFradio.stopConstCarrier();

if (CHECK_NRF_UART(mode) || CHECK_NRF_BOTH(mode)) NRFSerial.println("OFF");
}

Expand Down Expand Up @@ -1079,6 +1109,7 @@ void nrf_channel_hopper() {

if (CHECK_NRF_SPI(nrfMode)) {
NRFradio.stopConstCarrier();

NRFradio.powerDown();
}
if (CHECK_NRF_UART(nrfMode) || CHECK_NRF_BOTH(nrfMode)) { NRFSerial.println("OFF"); }
Expand All @@ -1094,4 +1125,6 @@ void nrf_channel_hopper() {

delay(50);
}


}