From b48567722bd61a3c5bb0f0fccca84fdd4be45e84 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Aug 2023 18:40:38 +0200 Subject: [PATCH] [SX127x] Added method to get CAD result --- src/modules/SX127x/SX127x.cpp | 7 +++++++ src/modules/SX127x/SX127x.h | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 3e5cccb4..6009b177 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -701,6 +701,13 @@ int16_t SX127x::startChannelScan() { return(state); } +int16_t SX127x::getChannelScanResult() { + if(this->getIRQFlags() & RADIOLIB_SX127X_CLEAR_IRQ_FLAG_CAD_DETECTED == RADIOLIB_SX127X_CLEAR_IRQ_FLAG_CAD_DETECTED) { + return(RADIOLIB_PREAMBLE_DETECTED); + } + return(RADIOLIB_CHANNEL_FREE); +} + int16_t SX127x::setSyncWord(uint8_t syncWord) { // check active modem if(getActiveModem() != RADIOLIB_SX127X_LORA) { diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index b18f6791..6544016d 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -834,7 +834,13 @@ class SX127x: public PhysicalLayer { DIO1 will be activated if there's no preamble detected before timeout. \returns \ref status_codes */ - int16_t startChannelScan(); + int16_t startChannelScan() override; + + /*! + \brief Read the channel scan result. + \returns \ref status_codes + */ + int16_t getChannelScanResult() override; // configuration methods @@ -1016,11 +1022,11 @@ class SX127x: public PhysicalLayer { int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK); /*! - \brief Get expected time-on-air for a given size of payload + \brief Get expected time-on-air for a given size of payload. \param len Payload length in bytes. \returns Expected time-on-air in microseconds. */ - uint32_t getTimeOnAir(size_t len); + uint32_t getTimeOnAir(size_t len) override; /*! \brief Enable CRC filtering and generation.