Skip to content

Commit c7c0154

Browse files
committed
JP_STRICT: remove CAD, limit backoff to JP_STRICT only
- Remove hardware CAD (scanChannel): not required by ARIB STD-T108, only LoRa preamble detection, adds unnecessary latency - Move exponential backoff and jitter inside JP_STRICT ifdef - Non-JP restored to original single-line RSSI check - Tune backoff for 4s airtime: base_ms=2000, max=16000ms Test results (16-byte simultaneous DM, SF12/BW125/CR4-8, JP_STRICT): - 3/3 success, delivered within 0:14-1:02
1 parent 5fcf25a commit c7c0154

1 file changed

Lines changed: 15 additions & 29 deletions

File tree

src/helpers/radiolib/RadioLibWrappers.cpp

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -184,53 +184,39 @@ bool RadioLibWrapper::isChannelActive() {
184184
if (_threshold == 0) return false; // interference check is disabled
185185

186186
#ifdef JP_STRICT
187-
// 5ms continuous RSSI sensing
187+
// ARIB STD-T108 compliant LBT: continuous RSSI sensing for >= 5ms
188+
// Energy-based sensing required; LoRa CAD not used here —
189+
// CAD detects only LoRa preambles and is not required by ARIB STD-T108
188190
uint32_t sense_start = millis();
189191
while (millis() - sense_start < 5) {
190192
if (getCurrentRSSI() > -80.0f) {
191-
// RSSI busy: backoff and return without CAD
193+
// Channel busy: exponential backoff (tuned for JP 4s airtime)
192194
_busy_count++;
193-
uint32_t base_ms = 3000;
194-
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)20000);
195+
uint32_t base_ms = 2000;
196+
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)16000);
195197
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
196198
while (millis() < backoff_until) {
197-
vTaskDelay(1);
199+
vTaskDelay(1); // yield CPU to FreeRTOS tasks including BLE
198200
}
199201
return true;
200202
}
201-
vTaskDelay(1);
203+
vTaskDelay(1); // yield CPU between RSSI samples
202204
}
203-
#endif
204-
205-
// CAD
206-
int16_t result = performChannelScan();
207-
state = STATE_IDLE;
208-
startRecv();
209-
210-
if (result != RADIOLIB_CHANNEL_FREE) {
211-
// CAD busy: backoff
212-
_busy_count++;
213-
uint32_t base_ms = 3000;
214-
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)20000);
215-
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
216-
while (millis() < backoff_until) {
217-
vTaskDelay(1);
218-
}
219-
return true;
220-
}
221-
205+
// Channel free: reset busy counter and add small jitter
222206
_busy_count = 0;
223-
224-
// Small jitter even when channel is free to prevent simultaneous TX
225-
// from two nodes that both detect a free channel at the same time
226207
uint32_t jitter_until = millis() + random(0, 500);
227208
while (millis() < jitter_until) {
228209
vTaskDelay(1); // yield CPU to FreeRTOS tasks including BLE
229210
}
230-
231211
return false;
212+
213+
#else
214+
// Non-JP: original behavior (RSSI threshold only)
215+
return getCurrentRSSI() > _noise_floor + _threshold;
216+
#endif
232217
}
233218

219+
234220
float RadioLibWrapper::getLastRSSI() const {
235221
return _radio->getRSSI();
236222
}

0 commit comments

Comments
 (0)