diff --git a/keywords.txt b/keywords.txt index 9457fcb0..f6bc613b 100644 --- a/keywords.txt +++ b/keywords.txt @@ -246,6 +246,7 @@ spectralScanAbort KEYWORD2 spectralScanGetStatus KEYWORD2 spectralScanGetResult KEYWORD2 setPaRampTime KEYWORD2 +hopLRFHSS KEYWORD2 # nRF24 setIrqAction KEYWORD2 diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 224858eb..777dce09 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -235,8 +235,7 @@ int16_t SX126x::transmit(const uint8_t* data, size_t len, uint8_t addr) { break; } else { // handle frequency hop - this->setLRFHSSHop(this->lrFhssHopNum % 16); - clearIrqStatus(); + this->hopLRFHSS(); } } } @@ -477,6 +476,16 @@ int16_t SX126x::standby(uint8_t mode, bool wakeup) { return(this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_STANDBY, data, 1)); } +int16_t SX126x::hopLRFHSS() { + if(!(this->getIrqFlags() & RADIOLIB_SX126X_IRQ_LR_FHSS_HOP)) { + return(RADIOLIB_ERR_TX_TIMEOUT); + } + + int16_t state = this->setLRFHSSHop(this->lrFhssHopNum % 16); + RADIOLIB_ASSERT(state); + return(clearIrqStatus()); +} + void SX126x::setDio1Action(void (*func)(void)) { this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()), func, this->mod->hal->GpioInterruptRising); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index e37265b0..371926ca 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -628,6 +628,13 @@ class SX126x: public PhysicalLayer { */ int16_t standby(uint8_t mode, bool wakeup = true); + /*! + \brief Handle LR-FHSS hop. + When using LR-FHSS in interrupt-driven mode, this method MUST be called each time an interrupt is triggered! + \returns \ref status_codes + */ + int16_t hopLRFHSS(); + // interrupt methods /*!