diff --git a/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino b/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino index 84434f93..f61f1602 100644 --- a/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino +++ b/examples/SX126x/SX126x_Receive_Interrupt/SX126x_Receive_Interrupt.ino @@ -77,6 +77,7 @@ void setup() { // lora.sleep() // lora.transmit(); // lora.receive(); + // lora.readData(); // lora.scanChannel(); } @@ -110,9 +111,6 @@ void loop() { // reset flag receivedFlag = false; - // put module to standby while reading data - lora.standby(); - // you can read received data as an Arduino String String str; int state = lora.readData(str); diff --git a/src/modules/SX126x.cpp b/src/modules/SX126x.cpp index 829d8e66..e38b594c 100644 --- a/src/modules/SX126x.cpp +++ b/src/modules/SX126x.cpp @@ -256,12 +256,6 @@ int16_t SX126x::receive(uint8_t* data, size_t len) { } } - // put radio to standby - state = standby(); - if(state != ERR_NONE) { - return(state); - } - // read the received data return(readData(data, len)); } @@ -446,6 +440,12 @@ int16_t SX126x::startReceive(uint32_t timeout) { } int16_t SX126x::readData(uint8_t* data, size_t len) { + // set mode to standby + int16_t state = standby(); + if(state != ERR_NONE) { + return(state); + } + // check integrity CRC uint16_t irq = getIrqStatus(); if((irq & SX126X_IRQ_CRC_ERR) || (irq & SX126X_IRQ_HEADER_ERR)) { @@ -460,7 +460,7 @@ int16_t SX126x::readData(uint8_t* data, size_t len) { } // read packet data - int16_t state = readBuffer(data, length); + state = readBuffer(data, length); if(state != ERR_NONE) { return(state); }