Fix two critical bugs + update file header

- handleSweepSettings: clamp was max 3 MHz / 20 steps (old limits); now 50/80 MHz
  and 100 steps so the default 20/46 MHz spans survive a UI Apply click
- handleToggle: toggle-on path never set jammingEnabled=true, causing sweep loop
  and watchdog to stay silent and NVS to persist false; now set before startJamming
- Update file header comment to reflect actual bands (300-320 + 390-436 MHz)

Made-with: Cursor
This commit is contained in:
drjones
2026-03-10 00:27:27 -07:00
parent 9a7afae767
commit d5aac24676

View File

@@ -1,8 +1,10 @@
/**
* Dual CC1101 always-on key-fob jammer (315 MHz + 433.92 MHz).
* Dual CC1101 always-on key-fob jammer.
* ESP32-S3 DevKitC-1: two CC1101 on shared SPI.
* On power-up, WiFi AP + web UI starts immediately; both radios begin jamming.
* Simultaneous jamming on both 315 MHz and 433.92 MHz frequencies with adjustable power.
* Radio 1: sweeps 300320 MHz (US band — Honda 303.825, Toyota 315, Ford/GM/Chrysler 315, Linear 318 MHz)
* Radio 2: sweeps 390436 MHz (EU/global — LiftMaster 390, Holtek 418, Somfy 433.42, EU 433.92, Nero 434.42 MHz)
* FM noise via LEDC on GDO0 pins (±120 kHz bandwidth per hop).
* WiFi AP + web UI on boot; OTA updates via ArduinoOTA.
*/
#include <Arduino.h>
@@ -749,7 +751,11 @@ static void handleToggle() {
if (jammingEnabled) {
stopJamming();
} else {
jammingEnabled = true; // must be set before startJamming so sweep loop and watchdog see it
startJamming();
if (radio1Status != 2 && radio2Status != 2) {
jammingEnabled = false; // both radios failed — don't pretend we're jamming
}
}
// Save new state
@@ -809,10 +815,10 @@ static void handleSweepSettings() {
extractInt( "\"dwell_ms\":", sweepDwellMs, 1, 500);
uint32_t s1 = sweep1Steps, s2 = sweep2Steps;
extractInt( "\"steps1\":", s1, 2, 20); sweep1Steps = (uint8_t)s1;
extractInt( "\"steps2\":", s2, 2, 20); sweep2Steps = (uint8_t)s2;
extractFloat("\"span1_mhz\":", sweep1SpanMhz, 0.1f, 3.0f);
extractFloat("\"span2_mhz\":", sweep2SpanMhz, 0.1f, 3.0f);
extractInt( "\"steps1\":", s1, 2, 100); sweep1Steps = (uint8_t)s1;
extractInt( "\"steps2\":", s2, 2, 100); sweep2Steps = (uint8_t)s2;
extractFloat("\"span1_mhz\":", sweep1SpanMhz, 0.1f, 50.0f);
extractFloat("\"span2_mhz\":", sweep2SpanMhz, 0.1f, 80.0f);
preferences.putInt("sweepDwell", (int)sweepDwellMs);
preferences.putInt("sweep1Steps", sweep1Steps);