Skip to content

Commit 9f7f99b

Browse files
maholliprojectgus
authored andcommitted
lora: Fix CRC error IRQ bit mask for sx126x.
Fixes micropython#1112 which causes corrupt packets to silently be passed as valid by the driver.
1 parent 09a33ee commit 9f7f99b

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

micropython/lora/lora-sx126x/lora/sx126x.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,13 @@ def __init__(
224224

225225
# If DIO1 is set, mask in just the IRQs that the driver may need to be
226226
# interrupted by. This is important because otherwise an unrelated IRQ
227-
# can trigger the ISR and may not be reset by the driver, leaving DIO1 high.
228-
#
229-
# If DIO1 is not set, all IRQs can stay masked which is the power-on state.
227+
# can trigger the ISR and may not be reset by the driver, leaving DIO1
228+
# high.
230229
if dio1:
231-
# Note: we set both Irq mask and DIO1 mask to the same value, which is redundant
232-
# (one could be 0xFFFF) but may save a few bytes of bytecode.
233230
self._cmd(
234231
">BHHHH",
235232
_CMD_CFG_DIO_IRQ,
236-
(_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT), # IRQ mask
233+
(_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT | _IRQ_CRC_ERR), # IRQ mask
237234
(_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT), # DIO1 mask
238235
0x0, # DIO2Mask, not used
239236
0x0, # DIO3Mask, not used
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.5")
1+
metadata(version="0.1.6")
22
require("lora")
33
package("lora")

0 commit comments

Comments
 (0)