Fix Flood jam: use transmit() not startTransmit; volatile pulse flag in noise ISR
startTransmit+next tick standby aborted packets before air complete. ISR must not read jamMode; use s_noiseIsPulse set in noiseGenStart. Made-with: Cursor
This commit is contained in:
13
src/main.cpp
13
src/main.cpp
@@ -87,6 +87,8 @@ static float jamFreq2 = JAM_LOCK_FREQ_2_MHZ;
|
||||
// Gate LFSR ISR so GDO0 is only toggled for radios in direct async TX (avoids driving idle CC1101).
|
||||
static volatile bool s_noiseEn1 = false;
|
||||
static volatile bool s_noiseEn2 = false;
|
||||
// ISR must not read jamMode (non-atomic); noiseGenStart sets this for PULSE vs PRNG.
|
||||
static volatile bool s_noiseIsPulse = false;
|
||||
|
||||
// Auto-reinit watchdog
|
||||
static uint32_t lastReInitCheck = 0;
|
||||
@@ -1075,16 +1077,17 @@ static void jamFloodTick() {
|
||||
(void)radio2.transmit(pkt, 60);
|
||||
}
|
||||
} else {
|
||||
// Flood mode: 64-byte payload, 2ms wait, async transmit.
|
||||
// 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, sizeof(pkt));
|
||||
(void)radio1.startTransmit(pkt, sizeof(pkt));
|
||||
(void)radio1.transmit(pkt, sizeof(pkt));
|
||||
}
|
||||
if (radio2Status == 2) {
|
||||
esp_fill_random(pkt, sizeof(pkt));
|
||||
(void)radio2.startTransmit(pkt, sizeof(pkt));
|
||||
(void)radio2.transmit(pkt, sizeof(pkt));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1557,7 +1560,7 @@ static inline IRAM_ATTR uint32_t lfsrStep(uint32_t s) {
|
||||
}
|
||||
|
||||
static void IRAM_ATTR noiseISR() {
|
||||
if (jamMode == JamMode::PULSE) {
|
||||
if (s_noiseIsPulse) {
|
||||
static uint32_t pulseToggle = 0;
|
||||
pulseToggle ^= 1;
|
||||
if (s_noiseEn1) gpio_set_level((gpio_num_t)CC1101_1_GDO0, pulseToggle);
|
||||
@@ -1585,6 +1588,8 @@ static void noiseGenStart() {
|
||||
s_lfsr = esp_random();
|
||||
if (s_lfsr == 0) s_lfsr = 0xDEADBEEFu; // LFSR must never be zero
|
||||
|
||||
s_noiseIsPulse = (jamMode == JamMode::PULSE);
|
||||
|
||||
pinMode(CC1101_1_GDO0, OUTPUT);
|
||||
pinMode(CC1101_2_GDO0, OUTPUT);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user