Skip to content

Commit 319c686

Browse files
committed
Fix #436: FSK irqs set OPMODE_STANDBY before SLEEP
1 parent a4d2494 commit 319c686

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lmic/radio.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,7 @@ void radio_irq_handler_v2 (u1_t dio, ostime_t now) {
12201220
if( (readReg(RegOpMode) & OPMODE_LORA) != 0) { // LORA modem
12211221
u1_t flags = readReg(LORARegIrqFlags);
12221222
LMIC.saveIrqFlags = flags;
1223+
LMICOS_logEventUint32("radio_irq_handler_v2: LoRa", flags);
12231224
LMIC_X_DEBUG_PRINTF("IRQ=%02x\n", flags);
12241225
if( flags & IRQ_LORA_TXDONE_MASK ) {
12251226
// save exact tx time
@@ -1258,6 +1259,9 @@ void radio_irq_handler_v2 (u1_t dio, ostime_t now) {
12581259
} else { // FSK modem
12591260
u1_t flags1 = readReg(FSKRegIrqFlags1);
12601261
u1_t flags2 = readReg(FSKRegIrqFlags2);
1262+
1263+
LMICOS_logEventUint32("radio_irq_handler_v2: FSK", (flags2 << UINT32_C(8)) | flags1);
1264+
12611265
if( flags2 & IRQ_FSK2_PACKETSENT_MASK ) {
12621266
// save exact tx time
12631267
LMIC.txend = now;
@@ -1275,10 +1279,15 @@ void radio_irq_handler_v2 (u1_t dio, ostime_t now) {
12751279
// indicate timeout
12761280
LMIC.dataLen = 0;
12771281
} else {
1278-
ASSERT(0);
1282+
// ASSERT(0);
1283+
// we're not sure why we're here... treat as timeout.
1284+
LMIC.dataLen = 0;
12791285
}
1286+
1287+
// in FSK, we need to put the radio in standby first.
1288+
opmode(OPMODE_STANDBY);
12801289
}
1281-
// go from stanby to sleep
1290+
// go from standby to sleep
12821291
opmode(OPMODE_SLEEP);
12831292
// run os job (use preset func ptr)
12841293
os_setCallback(&LMIC.osjob, LMIC.osjob.func);

0 commit comments

Comments
 (0)