diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 4ea1671f..99f4b27f 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -393,8 +393,7 @@ int16_t SX128x::receive(uint8_t* data, size_t len, RadioLibTime_t timeout) { // check whether this was a timeout or not if((getIrqStatus() & RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT) || softTimeout) { - standby(); - clearIrqStatus(); + (void)finishReceive(); return(RADIOLIB_ERR_RX_TIMEOUT); } @@ -569,6 +568,15 @@ int16_t SX128x::readData(uint8_t* data, size_t len) { return(state); } +int16_t SX128x::finishReceive() { + // clear interrupt flags + int16_t state = clearIrqStatus(); + RADIOLIB_ASSERT(state); + + // set mode to standby to disable RF switch + return(standby()); +} + uint32_t SX128x::getIrqFlags() { return((uint32_t)this->getIrqStatus()); } diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index b216cc6a..e4d85359 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -564,6 +564,12 @@ class SX128x: public PhysicalLayer { \returns \ref status_codes */ int16_t readData(uint8_t* data, size_t len) override; + + /*! + \brief Clean up after reception is done. + \returns \ref status_codes + */ + int16_t finishReceive() override; /*! \brief Read currently active IRQ flags.