Browse Source

Add ARIB STD-T108 LBT path to isChannelActive()

In JP 920MHz band (CH25-27): 5ms continuous RSSI sensing at -80dBm
absolute threshold, exponential backoff (2000-16000ms) on busy, jitter
(0-500ms) on free, then falls through to CAD if enabled.
Non-JP path: existing relative-RSSI threshold + CAD unchanged.
Add YIELD_TASK() macro and _busy_count field for backoff tracking.
pull/2218/head
me 1 month ago
parent
commit
17cccc93d6
  1. 36
      src/helpers/radiolib/RadioLibWrappers.cpp
  2. 3
      src/helpers/radiolib/RadioLibWrappers.h

36
src/helpers/radiolib/RadioLibWrappers.cpp

@ -2,6 +2,12 @@
#define RADIOLIB_STATIC_ONLY 1 #define RADIOLIB_STATIC_ONLY 1
#include "RadioLibWrappers.h" #include "RadioLibWrappers.h"
#ifdef NRF52_PLATFORM
#define YIELD_TASK() vTaskDelay(1)
#else
#define YIELD_TASK() delay(1)
#endif
#define STATE_IDLE 0 #define STATE_IDLE 0
#define STATE_RX 1 #define STATE_RX 1
#define STATE_TX_WAIT 3 #define STATE_TX_WAIT 3
@ -184,10 +190,34 @@ int16_t RadioLibWrapper::performChannelScan() {
} }
bool RadioLibWrapper::isChannelActive() { bool RadioLibWrapper::isChannelActive() {
// int.thresh: RSSI-based interference detection (relative to noise floor) if (isJapanMode()) {
if (_threshold != 0 && getCurrentRSSI() > _noise_floor + _threshold) return true; // ARIB STD-T108: 5ms continuous RSSI sensing, -80dBm absolute threshold
uint32_t sense_start = millis();
while (millis() - sense_start < 5) {
if (getCurrentRSSI() > -80.0f) {
_busy_count++;
uint32_t base_ms = 2000;
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)16000);
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
while (millis() < backoff_until) {
YIELD_TASK();
}
return true;
}
YIELD_TASK();
}
_busy_count = 0;
uint32_t jitter_until = millis() + random(0, 500);
while (millis() < jitter_until) {
YIELD_TASK();
}
// JP RSSI sensing passed; fall through to CAD if enabled
} else {
// Non-JP: RSSI-based interference detection (relative to noise floor)
if (_threshold != 0 && getCurrentRSSI() > _noise_floor + _threshold) return true;
}
// cad: hardware channel activity detection // hardware channel activity detection (JP and non-JP)
if (_cad_enabled) { if (_cad_enabled) {
int16_t result = performChannelScan(); int16_t result = performChannelScan();
// scanChannel() triggers DIO interrupt (CAD done) which sets STATE_INT_READY // scanChannel() triggers DIO interrupt (CAD done) which sets STATE_INT_READY

3
src/helpers/radiolib/RadioLibWrappers.h

@ -15,6 +15,7 @@ protected:
uint32_t n_recv, n_sent, n_recv_errors; uint32_t n_recv, n_sent, n_recv_errors;
int16_t _noise_floor, _threshold; int16_t _noise_floor, _threshold;
bool _cad_enabled; bool _cad_enabled;
uint8_t _busy_count;
uint16_t _num_floor_samples; uint16_t _num_floor_samples;
int32_t _floor_sample_sum; int32_t _floor_sample_sum;
uint8_t _preamble_sf; uint8_t _preamble_sf;
@ -26,7 +27,7 @@ protected:
virtual void doResetAGC(); virtual void doResetAGC();
public: public:
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board), _preamble_sf(0) { n_recv = n_sent = 0; } RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board), _busy_count(0), _preamble_sf(0) { n_recv = n_sent = 0; }
void begin() override; void begin() override;
virtual void powerOff() { _radio->sleep(); } virtual void powerOff() { _radio->sleep(); }

Loading…
Cancel
Save