diff --git a/include/esp32-lora.h b/include/esp32-lora.h index 9a2aec6..3bba6b1 100644 --- a/include/esp32-lora.h +++ b/include/esp32-lora.h @@ -64,8 +64,8 @@ #define DEFAULT_PREAMBLE 8 #define DEFAULT_CR 5 -#define DIO0_MODE_RXDONE 0xC0 -#define DIO0_MODE_TXDONE 0xBF +#define DIO0_MODE_RXDONE 0x00 +#define DIO0_MODE_TXDONE 0x40 #define EV_DIO0 (1 << 0) diff --git a/main/esp32-lora.c b/main/esp32-lora.c index ec30995..6c15b6a 100644 --- a/main/esp32-lora.c +++ b/main/esp32-lora.c @@ -143,6 +143,8 @@ void lora32_send(lora32_cfg_t *lora, uint8_t *data, uint8_t len) { lora32_write_reg(lora, REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX); + lora32_write_reg(lora, REG_DIO_MAPPING_1, DIO0_MODE_TXDONE); + ESP_LOGD(TAG, "lora32_send waiting for TX to finish"); // can be made async by waiting for DIO0 and checking for IRQ_TX_DONE_MASK @@ -244,9 +246,7 @@ 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_DIO_MAPPING_1, DIO0_MODE_RXDONE); } lora32_write_reg(lora, REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_RX_CONTINUOUS);