firmware icon indicating copy to clipboard operation
firmware copied to clipboard

fix(nrf24): power down WiFi PHY during jamming to clear 2.4GHz band

Open r13xr13 opened this issue 5 months ago • 4 comments

Problem

The NRF24 jammer transmits on 2.4GHz — the same ISM band as the ESP32 internal WiFi radio. When WiFi is active (station mode, AP mode, or sniffer), the two radios desense each other's front-ends. The jammer appears to transmit but the signal never reaches the target because the WiFi PHY is saturated. Users report "no jammers work" on v1.15 (#2508).

Additionally, on boards where NRF24 and CC1101 share physical SPI pins (SCK/MOSI/MISO), there is no coordination mechanism for SPI bus access, risking transaction corruption when both drivers are active.

Changes

src/modules/NRF24/nrf_jammer.cpp — WiFi power management during jamming:

  • Save current WiFi mode before entering the jammer loop
  • Stop WiFi and disable the PHY (esp_phy_disable()) to clear the 2.4GHz band
  • 10ms settle delay for RF front-end to power down
  • Restore WiFi mode and restart after jamming completes

src/main.cpp — Shared SPI bus mutex:

  • Added SemaphoreHandle_t cc_nrf_spi_mutex (file scope extern)
  • Initialized via xSemaphoreCreateMutex() in setup()
  • Declared extern in nrf_jammer.cpp for use in SPI-critical sections

Testing

  • Verified with WiFi active in station mode: jammer now locks the channel and holds it
  • SPI mutex prevents bus collisions when NRF24 and CC1101/LoRa share the same CC_NRF_SPI bus
  • WiFi state is fully restored — no connectivity loss after jamming stops

Fixes #2508, references #2511

r13xr13 avatar Jun 08 '26 06:06 r13xr13

On my Mac Studio and MacOS 26.5.1 it fails to compile with the following error message: src/modules/NRF24/nrf_jammer.cpp:22:10: fatal error: esp32-hal-semaphore.h: No such file or directory

Is this a mac related issue? I might just try on my linux machine later the day

pinchepasta avatar Jun 11 '26 12:06 pinchepasta

On my Mac Studio and MacOS 26.5.1 it fails to compile with the following error message: src/modules/NRF24/nrf_jammer.cpp:22:10: fatal error: esp32-hal-semaphore.h: No such file or directory

Is this a mac related issue? I might just try on my linux machine later the day

go with https://esptool.spacehuhn.com/ put the .bin file in the top and set it to 0x0 Best method until i get our flasher up. as your failing due to missing libs. confirmed working already but still let me know if after you try this it still gives you issues i'll take a closer look.

r13xr13 avatar Jun 11 '26 18:06 r13xr13

On my Mac Studio and MacOS 26.5.1 it fails to compile with the following error message: src/modules/NRF24/nrf_jammer.cpp:22:10: fatal error: esp32-hal-semaphore.h: No such file or directory Is this a mac related issue? I might just try on my linux machine later the day

go with https://esptool.spacehuhn.com/ put the .bin file in the top and set it to 0x0 Best method until i get our flasher up. as your failing due to missing libs. confirmed working already but still let me know if after you try this it still gives you issues i'll take a closer look.

I wasn't able to compile on my mac studio, I also tried on an macbook pro m1 and visual studio code, it always ends at this point. But on my x86 debian machine everything compiles perfectly fine. I guess it really is a mac related issue.

pinchepasta avatar Jun 12 '26 16:06 pinchepasta

On my Mac Studio and MacOS 26.5.1 it fails to compile with the following error message: src/modules/NRF24/nrf_jammer.cpp:22:10: fatal error: esp32-hal-semaphore.h: No such file or directory Is this a mac related issue? I might just try on my linux machine later the day

go with https://esptool.spacehuhn.com/ put the .bin file in the top and set it to 0x0 Best method until i get our flasher up. as your failing due to missing libs. confirmed working already but still let me know if after you try this it still gives you issues i'll take a closer look.

I wasn't able to compile on my mac studio, I also tried on an macbook pro m1 and visual studio code, it always ends at this point. But on my x86 debian machine everything compiles perfectly fine. I guess it really is a mac related issue.

TRY A VM IF YOU NEED TO BE ON THE MAC a friend also had this issue on the mac

r13xr13 avatar Jun 12 '26 16:06 r13xr13