Skip to content

Commit f2aad64

Browse files
committed
JP LBT: scale jitter by airtime instead of fixed 500ms
Replaced fixed random(0, 500) jitter with airtime-scaled random(0, airtime_ms / JP_LBT_JITTER_DIVISOR) (divisor=32). At SF12/BW125 this gives ~245ms max jitter (vs previous 500ms). Tested divisors 16 and 32 — both 3/3 success with no measurable difference in delivery time. Divisor 32 adopted as it halves the unnecessary wait without observable downside. The divisor is a named constant (JP_LBT_JITTER_DIVISOR) to make future tuning straightforward.
1 parent 5448ecf commit f2aad64

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/helpers/radiolib/RadioLibWrappers.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,15 @@ bool RadioLibWrapper::isChannelActive() {
209209
}
210210
YIELD_TASK();
211211
}
212-
// Channel free: reset busy counter and add small jitter
212+
// Channel free: reset busy counter and add airtime-scaled jitter.
213+
// JP_LBT_JITTER_DIVISOR controls jitter upper bound:
214+
// /8 -> SF12/BW125 ~975ms, SF7/BW62.5 ~50ms
215+
// /16 -> SF12/BW125 ~490ms, SF7/BW62.5 ~25ms (default)
216+
// /32 -> SF12/BW125 ~245ms, SF7/BW62.5 ~12ms
213217
_busy_count = 0;
214-
uint32_t jitter_until = millis() + random(0, 500);
218+
static const uint8_t JP_LBT_JITTER_DIVISOR = 32;
219+
uint32_t airtime_ms = getEstAirtimeFor(MAX_TRANS_UNIT);
220+
uint32_t jitter_until = millis() + random(0, airtime_ms / JP_LBT_JITTER_DIVISOR);
215221
while (millis() < jitter_until) {
216222
YIELD_TASK();
217223
}

0 commit comments

Comments
 (0)