Skip to content

Commit 3209e33

Browse files
committed
Fix #448: AS923, AU915 enforce dwell time based on TxParam
1 parent b7d4433 commit 3209e33

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/lmic/lmic_as923.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,28 @@ LMICas923_initJoinLoop(void) {
370370
void
371371
LMICas923_updateTx(ostime_t txbeg) {
372372
u4_t freq = LMIC.channelFreq[LMIC.txChnl];
373+
u4_t dwellDelay;
374+
u4_t globalDutyDelay;
375+
373376
// Update global/band specific duty cycle stats
374377
ostime_t airtime = calcAirTime(LMIC.rps, LMIC.dataLen);
375378
// Update channel/global duty cycle stats
376379
xref2band_t band = &LMIC.bands[freq & 0x3];
377380
LMIC.freq = freq & ~(u4_t)3;
378381
LMIC.txpow = LMICas923_getMaxEIRP(LMIC.txParam);
379382
band->avail = txbeg + airtime * band->txcap;
380-
if (LMIC.globalDutyRate != 0)
381-
LMIC.globalDutyAvail = txbeg + (airtime << LMIC.globalDutyRate);
383+
dwellDelay = globalDutyDelay = 0;
384+
if (LMIC.globalDutyRate != 0) {
385+
globalDutyDelay = (airtime << LMIC.globalDutyRate);
386+
}
387+
if (LMICas923_getUplinkDwellBit(LMIC.txParam)) {
388+
dwellDelay = AS923_UPLINK_DWELL_TIME_osticks;
389+
}
390+
if (dwellDelay > globalDutyDelay) {
391+
globalDutyDelay = dwellDelay;
392+
}
393+
if (globalDutyDelay != 0)
394+
LMIC.globalDutyAvail = txbeg + globalDutyDelay;
382395
}
383396

384397

src/lmic/lmic_au921.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,23 @@ void LMICau921_updateTx(ostime_t txbeg) {
239239
LMIC.freq = AU921_500kHz_UPFBASE + (chnl - 64)*AU921_500kHz_UPFSTEP;
240240
}
241241

242-
// Update global duty cycle stats
242+
// Update global duty cycle stat and deal with dwell time.
243+
u4_t dwellDelay;
244+
u4_t globalDutyDelay;
245+
dwellDelay = globalDutyDelay = 0;
246+
243247
if (LMIC.globalDutyRate != 0) {
244248
ostime_t airtime = calcAirTime(LMIC.rps, LMIC.dataLen);
245-
LMIC.globalDutyAvail = txbeg + (airtime << LMIC.globalDutyRate);
249+
globalDutyDelay = txbeg + (airtime << LMIC.globalDutyRate);
250+
}
251+
if (LMICau921_getUplinkDwellBit(LMIC.txParam)) {
252+
dwellDelay = AS923_UPLINK_DWELL_TIME_osticks;
253+
}
254+
if (dwellDelay > globalDutyDelay) {
255+
globalDutyDelay = dwellDelay;
256+
}
257+
if (globalDutyDelay != 0) {
258+
LMIC.globalDutyAvail = txbeg + globalDutyDelay;
246259
}
247260
}
248261

0 commit comments

Comments
 (0)