diff --git a/include/esp32-lora.h b/include/esp32-lora.h index 6c75fe4..9a2aec6 100644 --- a/include/esp32-lora.h +++ b/include/esp32-lora.h @@ -64,6 +64,9 @@ #define DEFAULT_PREAMBLE 8 #define DEFAULT_CR 5 +#define DIO0_MODE_RXDONE 0xC0 +#define DIO0_MODE_TXDONE 0xBF + #define EV_DIO0 (1 << 0) enum freq { diff --git a/main/esp32-lora.c b/main/esp32-lora.c index 277b674..62fa6ea 100644 --- a/main/esp32-lora.c +++ b/main/esp32-lora.c @@ -243,6 +243,12 @@ void lora32_set_spreadfactor(lora32_cfg_t *lora, uint8_t factor) { void lora32_enable_continuous_rx(lora32_cfg_t *lora) { ESP_LOGD(TAG, "enabling continuous receive"); + if(lora->receive != NULL) { + uint8_t reg_mapping_1 = lora32_read_reg(lora, REG_DIO_MAPPING_1); + + lora32_write_reg(lora, REG_DIO_MAPPING_1, (reg_mapping_1 ^ DIO0_MODE_RXDONE)); + } + lora32_write_reg(lora, REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_RX_CONTINUOUS); }