mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Replace JP_STRICT build flag with runtime frequency detection
JP LBT mode now activates automatically based on operating frequency: - CH25: 920.800MHz - CH26: 921.000MHz - CH27: 921.200MHz (ARIB STD-T108, 200kHz grid) Changes: - Add isJapanMode() to RadioLibWrapper using getFreqMHz() - Add getFreqMHz() to CustomSX1262Wrapper and CustomLR1110Wrapper - Remove #ifdef JP_STRICT throughout, replaced by isJapanMode() - Remove -D JP_STRICT build flag from platformio.ini - MAX_TEXT_LEN dynamically determined by CR at runtime via getMaxTextLen() No build flags required: JP compliance activates automatically when device is configured to Japan 3 frequencies.
This commit is contained in:
parent
73ec37657c
commit
c725b82e77
8 changed files with 51 additions and 52 deletions
|
|
@ -169,10 +169,10 @@ bool RadioLibWrapper::isSendComplete() {
|
|||
void RadioLibWrapper::onSendFinished() {
|
||||
_radio->finishTransmit();
|
||||
_board->onAfterTransmit();
|
||||
#ifdef JP_STRICT
|
||||
// ARIB STD-T108: wait >= 50ms after TX before next transmission
|
||||
delay(50);
|
||||
#endif
|
||||
if (isJapanMode()) {
|
||||
// ARIB STD-T108: wait >= 50ms after TX before next transmission
|
||||
delay(50);
|
||||
}
|
||||
state = STATE_IDLE;
|
||||
}
|
||||
|
||||
|
|
@ -183,40 +183,39 @@ int16_t RadioLibWrapper::performChannelScan() {
|
|||
bool RadioLibWrapper::isChannelActive() {
|
||||
if (_threshold == 0) return false; // interference check is disabled
|
||||
|
||||
#ifdef JP_STRICT
|
||||
// ARIB STD-T108 compliant LBT: continuous RSSI sensing for >= 5ms
|
||||
// Energy-based sensing required; LoRa CAD not used here —
|
||||
// CAD detects only LoRa preambles and is not required by ARIB STD-T108
|
||||
uint32_t sense_start = millis();
|
||||
while (millis() - sense_start < 5) {
|
||||
if (getCurrentRSSI() > -80.0f) {
|
||||
// Channel busy: exponential backoff (tuned for JP 4s airtime)
|
||||
_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) {
|
||||
vTaskDelay(1); // yield CPU to FreeRTOS tasks including BLE
|
||||
// Activate JP_STRICT LBT on Japan 920MHz band 3 channels only
|
||||
// CH25=920.800MHz, CH26=921.000MHz, CH27=921.200MHz (ARIB STD-T108)
|
||||
if (isJapanMode()) {
|
||||
// ARIB STD-T108 compliant LBT: continuous RSSI sensing for >= 5ms
|
||||
// Energy-based sensing required; LoRa CAD not used
|
||||
uint32_t sense_start = millis();
|
||||
while (millis() - sense_start < 5) {
|
||||
if (getCurrentRSSI() > -80.0f) {
|
||||
// Channel busy: exponential backoff (tuned for JP 4s airtime)
|
||||
_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) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
vTaskDelay(1);
|
||||
}
|
||||
vTaskDelay(1); // yield CPU between RSSI samples
|
||||
// Channel free: reset busy counter and add small jitter
|
||||
_busy_count = 0;
|
||||
uint32_t jitter_until = millis() + random(0, 500);
|
||||
while (millis() < jitter_until) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Channel free: reset busy counter and add small jitter
|
||||
_busy_count = 0;
|
||||
uint32_t jitter_until = millis() + random(0, 500);
|
||||
while (millis() < jitter_until) {
|
||||
vTaskDelay(1); // yield CPU to FreeRTOS tasks including BLE
|
||||
}
|
||||
return false;
|
||||
|
||||
#else
|
||||
// Non-JP: original behavior (RSSI threshold only)
|
||||
return getCurrentRSSI() > _noise_floor + _threshold;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float RadioLibWrapper::getLastRSSI() const {
|
||||
return _radio->getRSSI();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue