Revert to a44462e (pre-frequency-change state)

Made-with: Cursor
This commit is contained in:
drjones
2026-04-02 20:07:48 -07:00
parent 112e03c2a9
commit 9ed90ab4ae
2 changed files with 29 additions and 52 deletions

View File

@@ -1065,49 +1065,39 @@ static void stopJamming() {
}
// Packet-flood jam: PRNG frames on both radios (shared SPI — sequential).
//
// Uses startTransmit() (non-blocking) so the CC1101 finishes each packet autonomously
// and returns to IDLE on its own. The 3ms guard (JAM_SPECIAL_DELAY_MS) is just over
// the 2.59ms on-air time for a 61-byte packet at 250 kbps, so we restart cleanly
// without ever cutting a packet short. Duty cycle: ~85% vs. the previous 26%.
//
// RadioLib's transmit() wraps startTransmit()+finishTransmit(); finishTransmit() has
// a timeout bug at 250 kbps (timeout = 0ms) causing it to immediately return
// RADIOLIB_ERR_TX_TIMEOUT while the CC1101 is still transmitting. Using startTransmit()
// directly avoids that entirely — we just let the CC1101 run and restart after 3ms.
static void jamFloodTick() {
if (!s_floodJamActive || !jammingEnabled) return;
static uint8_t pkt[JAM_FLOOD_PKT_BYTES];
static uint32_t lastMs = 0;
const uint32_t now = millis();
const uint32_t delay = (jamMode == JamMode::SPECIAL)
? (uint32_t)JAM_SPECIAL_DELAY_MS
: (uint32_t)JAM_FLOOD_DELAY_MS;
if ((uint32_t)(now - lastMs) < delay) return;
lastMs = now; // timestamp BEFORE SPI — gives tightest pacing
static uint32_t lastMs;
if (jamMode == JamMode::SPECIAL) {
// Exact cypher-pulse clone: 60-byte payload, 10ms wait, blocking transmit.
if ((uint32_t)(millis() - lastMs) < 10u) return;
if (radio1Status == 2) {
esp_fill_random(pkt, JAM_FLOOD_PKT_BYTES);
(void)radio1.startTransmit(pkt, JAM_FLOOD_PKT_BYTES);
esp_fill_random(pkt, 60);
(void)radio1.transmit(pkt, 60);
}
if (radio2Status == 2) {
esp_fill_random(pkt, JAM_FLOOD_PKT_BYTES);
(void)radio2.startTransmit(pkt, JAM_FLOOD_PKT_BYTES);
esp_fill_random(pkt, 60);
(void)radio2.transmit(pkt, 60);
}
} else {
// FLOOD mode: same non-blocking approach, same packet size.
// Flood: full transmit() — startTransmit() without finishTransmit() was aborting
// each packet on the next tick (standby() at start of TX), so almost no on-air energy.
if ((uint32_t)(millis() - lastMs) < 2u) return;
if (radio1Status == 2) {
esp_fill_random(pkt, JAM_FLOOD_PKT_BYTES);
(void)radio1.startTransmit(pkt, JAM_FLOOD_PKT_BYTES);
esp_fill_random(pkt, sizeof(pkt));
(void)radio1.transmit(pkt, sizeof(pkt));
}
if (radio2Status == 2) {
esp_fill_random(pkt, JAM_FLOOD_PKT_BYTES);
(void)radio2.startTransmit(pkt, JAM_FLOOD_PKT_BYTES);
esp_fill_random(pkt, sizeof(pkt));
(void)radio2.transmit(pkt, sizeof(pkt));
}
}
lastMs = millis(); // record time AFTER transmit completes
}
static int hexNibble(char c) {
@@ -2260,8 +2250,7 @@ static void handleRoot() {
}
server.setContentLength(sizeof(kHtml) - 1);
server.send(200, "text/html; charset=utf-8", "");
// Use length-aware overload — avoids constructing a 15 KB String on a fragmented heap.
server.sendContent(kHtml, sizeof(kHtml) - 1);
server.sendContent(kHtml);
}
static void handleLog() {
@@ -2613,8 +2602,8 @@ void setup() {
jamPower = kPowerTable[jamPowerIdx];
preferences.putInt("jamPowerIdx", (int)jamPowerIdx);
capHistoryLoad();
// Boot policy: Direct mode — OOK + 1 MHz LFSR, ~100% duty cycle, covers 314316 MHz and 432434 MHz.
jamMode = JamMode::DIRECT;
// Boot policy: always start in Special jam (60 B PRNG / 10 ms); persists to NVS for startJamming().
jamMode = JamMode::SPECIAL;
preferences.putUChar("jamMode", (uint8_t)jamMode);
logLine("[NVS] jam at boot: always ON | jamPower=" + String(jamPower) + " dBm | jam_mode=" +
String(jamModeToCstr(jamMode)) + " (default on power-up)");