LCOV - code coverage report
Current view: top level - src/protocols/PhysicalLayer - PhysicalLayer.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2026-11-08 19:43:08 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #if !defined(_RADIOLIB_PHYSICAL_LAYER_H)
       2             : #define _RADIOLIB_PHYSICAL_LAYER_H
       3             : 
       4             : #include "../../TypeDef.h"
       5             : #include "../../Module.h"
       6             : 
       7             : // common IRQ values - the IRQ flags in RadioLibIrqFlags_t arguments are offset by this value
       8             : enum RadioLibIrqType_t {
       9             :   RADIOLIB_IRQ_TX_DONE = 0x00,
      10             :   RADIOLIB_IRQ_RX_DONE = 0x01,
      11             :   RADIOLIB_IRQ_PREAMBLE_DETECTED = 0x02,
      12             :   RADIOLIB_IRQ_SYNC_WORD_VALID = 0x03,
      13             :   RADIOLIB_IRQ_HEADER_VALID = 0x04,
      14             :   RADIOLIB_IRQ_HEADER_ERR = 0x05,
      15             :   RADIOLIB_IRQ_CRC_ERR = 0x06,
      16             :   RADIOLIB_IRQ_CAD_DONE = 0x07,
      17             :   RADIOLIB_IRQ_CAD_DETECTED = 0x08,
      18             :   RADIOLIB_IRQ_TIMEOUT = 0x09,
      19             :   RADIOLIB_IRQ_NOT_SUPPORTED = 0x1F, // this must be the last value, intentionally set to 31
      20             : };
      21             : 
      22             : // some commonly used default values - defined here to ensure all modules have the same default behavior
      23             : #define RADIOLIB_IRQ_RX_DEFAULT_FLAGS       ((1UL << RADIOLIB_IRQ_RX_DONE) | (1UL << RADIOLIB_IRQ_TIMEOUT) | (1UL << RADIOLIB_IRQ_CRC_ERR) | (1UL << RADIOLIB_IRQ_HEADER_VALID) | (1UL << RADIOLIB_IRQ_HEADER_ERR))
      24             : #define RADIOLIB_IRQ_RX_DEFAULT_MASK        ((1UL << RADIOLIB_IRQ_RX_DONE))
      25             : #define RADIOLIB_IRQ_CAD_DEFAULT_FLAGS      ((1UL << RADIOLIB_IRQ_CAD_DETECTED) | (1UL << RADIOLIB_IRQ_CAD_DONE))
      26             : #define RADIOLIB_IRQ_CAD_DEFAULT_MASK       ((1UL << RADIOLIB_IRQ_CAD_DETECTED) | (1UL << RADIOLIB_IRQ_CAD_DONE))
      27             : 
      28             : /*!
      29             :   \struct LoRaRate_t
      30             :   \brief Data rate structure interpretation in case LoRa is used
      31             : */
      32             : struct LoRaRate_t {
      33             :   /*! \brief LoRa spreading factor */
      34             :   uint8_t spreadingFactor;
      35             :   
      36             :   /*! \brief LoRa bandwidth in Hz */
      37             :   uint32_t bandwidth;
      38             : 
      39             :   /*! \brief LoRa coding rate denominator */
      40             :   uint8_t codingRate;
      41             : };
      42             : 
      43             : /*!
      44             :   \struct FSKRate_t
      45             :   \brief Data rate structure interpretation in case FSK is used
      46             : */
      47             : struct FSKRate_t {
      48             :   /*! \brief FSK bit rate in bps */
      49             :   uint32_t bitRate;
      50             :   
      51             :   /*! \brief FSK frequency deviation in Hz */
      52             :   uint32_t freqDev;
      53             : };
      54             : 
      55             : /*!
      56             :   \struct LrFhssRate_t
      57             :   \brief Data rate structure interpretation in case LR-FHSS is used
      58             : */
      59             : struct LrFhssRate_t {
      60             :   /*! \brief Bandwidth */
      61             :   uint8_t bw;
      62             : 
      63             :   /*! \brief Coding rate */
      64             :   uint8_t cr;
      65             : 
      66             :   /*! \brief Grid spacing */
      67             :   bool narrowGrid;
      68             : };
      69             : 
      70             : /*!
      71             :   \union DataRate_t
      72             :   \brief Common data rate structure
      73             : */
      74             : union DataRate_t {
      75             :   /*! \brief Interpretation for LoRa modems */
      76             :   LoRaRate_t lora;
      77             : 
      78             :   /*! \brief Interpretation for FSK modems */
      79             :   FSKRate_t fsk;
      80             : 
      81             :   /*! \brief Interpretation for LR-FHSS modems */
      82             :   LrFhssRate_t lrFhss;
      83             : };
      84             : 
      85             : struct LoRaPacketConfig_t {
      86             :   /*! \brief LoRa preamble length */
      87             :   uint16_t preambleLength;
      88             : 
      89             :   /*! \brief LoRa implicit header mode */
      90             :   bool implicitHeader;
      91             : 
      92             :   /*! \brief LoRa CRC mode */
      93             :   bool crcEnabled;
      94             : 
      95             :   /*! \brief LoRa low data rate optimization */
      96             :   bool ldrOptimize;
      97             : };
      98             : 
      99             : struct FSKPacketConfig_t {
     100             :   /*! \brief FSK preamble length in bits */
     101             :   uint16_t preambleLength;
     102             : 
     103             :   /*! \brief Length of the sync word in bits */
     104             :   uint8_t syncWordLength;
     105             : 
     106             :   /*! \brief FSK CRC length in bytes */
     107             :   uint8_t crcLength;
     108             : };
     109             : 
     110             : struct LrFhssPacketConfig_t {
     111             :   /*! \brief LR-FHSS header count (1 - 4) */
     112             :   uint8_t hdrCount;
     113             : };
     114             : 
     115             : /*!
     116             :   \union PacketConfig_t
     117             :   \brief Common packet configuration structure
     118             : */
     119             : union PacketConfig_t {
     120             :   LoRaPacketConfig_t lora;
     121             :   FSKPacketConfig_t fsk;
     122             :   LrFhssPacketConfig_t lrFhss;
     123             : };
     124             : 
     125             : /*!
     126             :   \struct CADScanConfig_t
     127             :   \brief Channel scan configuration interpretation in case LoRa CAD is used
     128             : */
     129             : struct CADScanConfig_t {
     130             :   /*! \brief Number of symbols to consider signal present */
     131             :   uint8_t symNum;
     132             :   
     133             :   /*! \brief Number of peak detection symbols */
     134             :   uint8_t detPeak;
     135             :   
     136             :   /*! \brief Number of minimum detection symbols */
     137             :   uint8_t detMin;
     138             :   
     139             :   /*! \brief Exit mode after signal detection is complete - module-specific value */
     140             :   uint8_t exitMode;
     141             :   
     142             :   /*! \brief Rx packet timeout in microseconds */
     143             :   RadioLibTime_t rxTimeout;
     144             : 
     145             :   /*! \brief Rx sync timeout in symbols */
     146             :   RadioLibTime_t rxSymbols;
     147             : 
     148             :   /*! \brief Optional IRQ flags to set, bits offset by the value of RADIOLIB_IRQ_ */
     149             :   RadioLibIrqFlags_t irqFlags;
     150             : 
     151             :   /*! \brief Optional IRQ mask to set, bits offset by the value of RADIOLIB_IRQ_ */
     152             :   RadioLibIrqFlags_t irqMask;
     153             : };
     154             : 
     155             : /*!
     156             :   \struct RSSIScanConfig_t
     157             :   \brief Channel scan configuration interpretation in case RSSI threshold is used
     158             : */
     159             : struct RSSIScanConfig_t {
     160             :   /*! \brief RSSI limit in dBm */
     161             :   float limit;
     162             : };
     163             : 
     164             : /*!
     165             :   \union ChannelScanConfig_t
     166             :   \brief Common channel scan configuration structure
     167             : */
     168             : union ChannelScanConfig_t {
     169             :   /*! \brief Interpretation for modems that use CAD (usually LoRa modems)*/
     170             :   CADScanConfig_t cad;
     171             : 
     172             :   /*! \brief Interpretation for modems that use RSSI threshold*/
     173             :   RSSIScanConfig_t rssi;
     174             : };
     175             : 
     176             : struct StandbyConfig_t {
     177             :   /*! \brief Module-specific standby mode configuration. */
     178             :   uint8_t mode;
     179             : };
     180             : 
     181             : struct ReceiveConfig_t {
     182             :   /*! \brief  Raw timeout value. Some modules use this argument to specify operation mode (single vs. continuous receive). */
     183             :   uint32_t timeout;
     184             : 
     185             :   /*! \brief LoRa sync timeout, given as the number of LoRa symbols. */
     186             :   uint16_t syncSymbols;
     187             : 
     188             :   /*! \brief Sets the IRQ flags. */
     189             :   RadioLibIrqFlags_t irqFlags;
     190             :   
     191             :   /*! \brief Sets the mask of IRQ flags that will trigger the radio interrupt pin. */
     192             :   RadioLibIrqFlags_t irqMask;
     193             :   
     194             :   /*! \brief Packet length, needed for some modules under special circumstances (e.g. LoRa implicit header mode). */
     195             :   size_t len;
     196             : };
     197             : 
     198             : struct TransmitConfig_t {
     199             :   /*! \brief Binary data that will be transmitted. */
     200             :   const uint8_t* data;
     201             : 
     202             :   /*! \brief Length of binary data to transmit (in bytes). */
     203             :   size_t len;
     204             : 
     205             :   /*! \brief Node address to transmit the packet to. Only used in FSK mode. */
     206             :   uint8_t addr;
     207             : };
     208             : 
     209             : struct SleepConfig_t {
     210             :   /*! \brief Module-specific sleep mode configuration. */
     211             :   uint8_t mode;
     212             : };
     213             : 
     214             : union RadioModeConfig_t {
     215             :   /*! \brief Interpretation for standby mode */
     216             :   StandbyConfig_t standby;
     217             : 
     218             :   /*! \brief Interpretation for Rx mode */
     219             :   ReceiveConfig_t receive;
     220             : 
     221             :   /*! \brief Interpretation for Tx mode */
     222             :   TransmitConfig_t transmit;
     223             : 
     224             :   /*! \brief Interpretation for scanning */
     225             :   ChannelScanConfig_t scan;
     226             : 
     227             :   /*! \brief Interpretation for sleep mode */
     228             :   SleepConfig_t sleep;
     229             : };
     230             : 
     231             : /*!
     232             :   \enum ModemType_t
     233             :   \brief Type of modem, used by setModem.
     234             : */
     235             : enum ModemType_t {
     236             :   RADIOLIB_MODEM_FSK = 0,
     237             :   RADIOLIB_MODEM_LORA,
     238             :   RADIOLIB_MODEM_LRFHSS,
     239             :   RADIOLIB_MODEM_NONE,  // last entry
     240             : };
     241             : 
     242             : /*!
     243             :   \enum RadioModeType_t
     244             :   \brief Basic radio operating modes, used by stageMode.
     245             : */
     246             : enum RadioModeType_t {
     247             :   RADIOLIB_RADIO_MODE_NONE = 0,
     248             :   RADIOLIB_RADIO_MODE_STANDBY,
     249             :   RADIOLIB_RADIO_MODE_RX,
     250             :   RADIOLIB_RADIO_MODE_TX,
     251             :   RADIOLIB_RADIO_MODE_SCAN,
     252             :   RADIOLIB_RADIO_MODE_SLEEP,
     253             : };
     254             : 
     255             : #define RADIOLIB_LORA_SYNC_WORD_PRIVATE                         (0x12UL << 0)   //  7     0     LoRa sync word: private network
     256             : #define RADIOLIB_LORA_SYNC_WORD_PUBLIC                          (0x34UL << 0)   //  7     0                     public network (LoRaWAN)
     257             : 
     258             : #define RADIOLIB_LR_FHSS_CR_5_6                                 (0x00UL << 0)   //  7     0     LR-FHSS coding rate: 5/6
     259             : #define RADIOLIB_LR_FHSS_CR_2_3                                 (0x01UL << 0)   //  7     0                          2/3
     260             : #define RADIOLIB_LR_FHSS_CR_1_2                                 (0x02UL << 0)   //  7     0                          1/2
     261             : #define RADIOLIB_LR_FHSS_CR_1_3                                 (0x03UL << 0)   //  7     0                          1/3
     262             : #define RADIOLIB_LR_FHSS_BW_39_06                               (0x00UL << 0)   //  7     0     LR-FHSS bandwidth: 39.06 kHz
     263             : #define RADIOLIB_LR_FHSS_BW_85_94                               (0x01UL << 0)   //  7     0                        85.94 kHz
     264             : #define RADIOLIB_LR_FHSS_BW_136_72                              (0x02UL << 0)   //  7     0                        136.72 kHz
     265             : #define RADIOLIB_LR_FHSS_BW_183_59                              (0x03UL << 0)   //  7     0                        183.59 kHz
     266             : #define RADIOLIB_LR_FHSS_BW_335_94                              (0x04UL << 0)   //  7     0                        335.94 kHz
     267             : #define RADIOLIB_LR_FHSS_BW_386_72                              (0x05UL << 0)   //  7     0                        386.72 kHz
     268             : #define RADIOLIB_LR_FHSS_BW_722_66                              (0x06UL << 0)   //  7     0                        722.66 kHz
     269             : #define RADIOLIB_LR_FHSS_BW_773_44                              (0x07UL << 0)   //  7     0                        773.44 kHz
     270             : #define RADIOLIB_LR_FHSS_BW_1523_4                              (0x08UL << 0)   //  7     0                        1523.4 kHz
     271             : #define RADIOLIB_LR_FHSS_BW_1574_2                              (0x09UL << 0)   //  7     0                        1574.2 kHz
     272             : 
     273             : #define RADIOLIB_FLRC_BR_2600                                   (0x00UL << 0)   //  7     0     bitrate/bandwidth: 2600 kbps, 2666 kHz
     274             : #define RADIOLIB_FLRC_BR_2080                                   (0x01UL << 0)   //  7     0                        2080 kbps, 2222 kHz
     275             : #define RADIOLIB_FLRC_BR_1300                                   (0x02UL << 0)   //  7     0                        1300 kbps, 1333 kHz
     276             : #define RADIOLIB_FLRC_BR_1040                                   (0x03UL << 0)   //  7     0                        1040 kbps, 1333 kHz
     277             : #define RADIOLIB_FLRC_BR_650                                    (0x04UL << 0)   //  7     0                        650 kbps, 888 kHz
     278             : #define RADIOLIB_FLRC_BR_520                                    (0x05UL << 0)   //  7     0                        520 kbps, 769 kHz
     279             : #define RADIOLIB_FLRC_BR_325                                    (0x06UL << 0)   //  7     0                        325 kbps, 444 kHz
     280             : #define RADIOLIB_FLRC_BR_260                                    (0x07UL << 0)   //  7     0                        260 kbps, 444 kHz
     281             : #define RADIOLIB_FLRC_CR_1_2                                    (0x00UL << 0)   //  7     0     coding rate: 1/2
     282             : #define RADIOLIB_FLRC_CR_3_4                                    (0x01UL << 0)   //  7     0                  3/4
     283             : #define RADIOLIB_FLRC_CR_1_0                                    (0x02UL << 0)   //  7     0                  1 (un-coded)
     284             : #define RADIOLIB_FLRC_CR_2_3                                    (0x03UL << 0)   //  7     0                  2/3
     285             : 
     286             : #define RADIOLIB_LR_FHSS_BIT_RATE                               (488.28215f)    //  31    0     LR FHSS bit rate: 488.28215 bps
     287             : #define RADIOLIB_LR_FHSS_HEADER_BITS                            (114)           //  7     0     LR FHSS packet bit widths: header
     288             : #define RADIOLIB_LR_FHSS_FRAG_BITS                              (48)            //  7     0                                payload fragment
     289             : #define RADIOLIB_LR_FHSS_BLOCK_PREAMBLE_BITS                    (2)             //  7     0                                block preamble
     290             : #define RADIOLIB_LR_FHSS_BLOCK_BITS                             (RADIOLIB_LR_FHSS_FRAG_BITS + RADIOLIB_LR_FHSS_BLOCK_PREAMBLE_BITS)
     291             : 
     292             : struct ConfigLoRa_t {
     293             :   /*! \brief Carrier frequency in MHz. Defaults to 434.0 MHz. */
     294             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(434);
     295             :   /*! \brief LoRa bandwidth in kHz. Defaults to 125.0 kHz. */
     296             :   uint32_t bandwidth = RADIOLIB_UNIT_KILO(125);
     297             :   /*! \brief LoRa spreading factor. Defaults to 9. */
     298             :   uint8_t spreadingFactor = 9;
     299             :   /*! \brief LoRa coding rate. Defaults to 7 (coding rate 4/7). Allowed values range from 4 to 8. Note that a value of 4 means no coding,
     300             :   is undocumented and not recommended without your own FEC. */
     301             :   uint8_t codingRate = 7;
     302             :   /*! \brief 1-byte LoRa sync word. Defaults to RADIOLIB_LORA_SYNC_WORD_PRIVATE (0x12). */
     303             :   uint8_t syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
     304             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     305             :   int8_t power = 10;
     306             :   /*! \brief LoRa preamble length in symbols. Defaults to 8 symbols. */
     307             :   uint16_t preambleLength = 8;
     308             : };
     309             : 
     310             : struct ConfigFSK_t {
     311             :   /*! \brief Carrier frequency in MHz. Defaults to 434.0 MHz. */
     312             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(434);
     313             :   /*! \brief FSK bit rate in kbps. Defaults to 4.8 kbps. */
     314             :   uint32_t bitRate = 4800;
     315             :   /*! \brief FSK frequency deviation in kHz. Defaults to 5.0 kHz. */
     316             :   uint32_t frequencyDeviation = RADIOLIB_UNIT_KILO(5);
     317             :   /*! \brief FSK receiver bandwidth in kHz. Defaults to 125.0 kHz. */
     318             :   uint32_t receiverBandwidth = RADIOLIB_UNIT_KILO(125);
     319             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     320             :   int8_t power = 10;
     321             :   /*! \brief FSK preamble length in bits. Defaults to 16 bits. */
     322             :   uint16_t preambleLength = 16;
     323             : };
     324             : 
     325             : struct ConfigBPSK_t {
     326             :   /*! \brief Carrier frequency in MHz. Defaults to 434.0 MHz. */
     327             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(434);
     328             :   /*! \brief FSK bit rate in kbps. Defaults to 4.8 kbps. */
     329             :   uint32_t bitRate = 4800;
     330             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     331             :   int8_t power = 10;
     332             : };
     333             : 
     334             : struct ConfigOOK_t {
     335             :   /*! \brief Carrier frequency in MHz. Defaults to 434.0 MHz. */
     336             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(434);
     337             :   /*! \brief FSK bit rate in kbps. Defaults to 4.8 kbps. */
     338             :   uint32_t bitRate = 4800;
     339             :   /*! \brief FSK receiver bandwidth in kHz. Defaults to 125.0 kHz. */
     340             :   uint32_t receiverBandwidth = RADIOLIB_UNIT_KILO(125);
     341             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     342             :   int8_t power = 10;
     343             :   /*! \brief FSK preamble length in bits. Defaults to 16 bits. */
     344             :   uint16_t preambleLength = 16;
     345             : };
     346             : 
     347             : struct ConfigLRFHSS_t {
     348             :   /*! \brief Carrier frequency in MHz. Defaults to 434.0 MHz. */
     349             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(434);
     350             :   /*! \brief LR-FHSS bandwidth, one of RADIOLIB_LR_FHSS_BW_* values. Defaults to 722.66 kHz. */
     351             :   uint8_t bandwidth = RADIOLIB_LR_FHSS_BW_722_66;
     352             :   /*! \brief LR-FHSS coding rate, one of RADIOLIB_LR_FHSS_CR_* values. Defaults to 2/3 coding rate. */
     353             :   uint8_t codingRate = RADIOLIB_LR_FHSS_CR_2_3;
     354             :   /*! \brief Whether to use narrow (3.9 kHz) or wide (25.39 kHz) grid spacing. Defaults to true (narrow/non-FCC) grid. */
     355             :   bool narrowGrid = true;
     356             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     357             :   int8_t power = 10;
     358             : };
     359             : 
     360             : struct ConfigFLRC_t {
     361             :   /*! \brief Carrier frequency in MHz. Defaults to 434.0 MHz. */
     362             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(434);
     363             :   /*! \brief FLRC bit rate in kbps. Defaults to 650 kbps. */
     364             :   uint32_t bitRate = RADIOLIB_UNIT_KILO(650);
     365             :   /*! \brief FLRC coding rate. Defaults to RADIOLIB_FLRC_CR_2_3 (coding rate 2/3). */
     366             :   uint8_t codingRate = RADIOLIB_FLRC_CR_2_3;
     367             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     368             :   int8_t power = 10;
     369             :   /*! \brief FLRC preamble length in bits. Defaults to 16 bits. */
     370             :   uint16_t preambleLength = 16;
     371             :   /*! \brief Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. */
     372             :   uint8_t dataShaping = RADIOLIB_SHAPING_0_5;
     373             : };
     374             : 
     375             : struct ConfigBLE_t {
     376             :   /*! \brief Carrier frequency in MHz. Defaults to 2400.0 MHz. */
     377             :   uint32_t frequency = RADIOLIB_UNIT_MEGA(2400);
     378             :   /*! \brief BLE bit rate in kbps. Defaults to 800 kbps. */
     379             :   uint16_t bitRate = 800;
     380             :   /*! \brief BLE frequency deviation in kHz. Defaults to 400.0 kHz. */
     381             :   uint32_t frequencyDeviation = RADIOLIB_UNIT_KILO(400);
     382             :   /*! \brief Output power in dBm. Defaults to 10 dBm. */
     383             :   int8_t power = 10;
     384             :   /*! \brief Time-bandwidth product of the Gaussian filter to be used for shaping. Defaults to 0.5. */
     385             :   uint8_t dataShaping = RADIOLIB_SHAPING_0_5;
     386             : };
     387             : 
     388             : /*!
     389             :   \defgroup module_config_vars Module Hardware Configuration Variables
     390             :   \brief A centralized list of all module configurations which are not part of the various Config_t structures.
     391             :   When changing these values it has to be done prior to radio initialization using the begin() method!
     392             : */
     393             : 
     394             : /*!
     395             :   \class PhysicalLayer
     396             : 
     397             :   \brief Provides common interface for protocols that run on %LoRa/FSK modules, such as RTTY or LoRaWAN.
     398             :   Also extracts some common module-independent methods. Using this interface class allows to use the protocols
     399             :   on various modules without much code duplicity. Because this class is used mainly as interface,
     400             :   all of its virtual members must be implemented in the module class.
     401             : */
     402             : class PhysicalLayer {
     403             :   public:
     404             : 
     405             :     /*! \brief  Frequency step of the synthesizer in Hz. */
     406             :     float freqStep;
     407             : 
     408             :     /*! \brief  Maximum length of packet that can be received by the module. */
     409             :     size_t maxPacketLength;
     410             : 
     411             :     /*!
     412             :       \brief Whether to reset the module on startup. Setting to false allows to restore radio operation
     413             :       by calling begin after deep sleep mode on some platforms (like ESP32).
     414             :       \ingroup module_config_vars
     415             :     */
     416             :     bool resetOnStartup = true;
     417             : 
     418             :     // constructor
     419             : 
     420             :     /*!
     421             :       \brief Default constructor.
     422             :     */
     423             :     PhysicalLayer();
     424             : 
     425             :     /*!
     426             :       \brief Default destructor.
     427             :     */
     428          54 :     virtual ~PhysicalLayer() = default;
     429             : 
     430             :     // basic methods
     431             : 
     432             :     #if defined(RADIOLIB_BUILD_ARDUINO)
     433             :     /*!
     434             :       \brief Arduino Flash String transmit method.
     435             :       \param str Pointer to Arduino Flash String that will be transmitted.
     436             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     437             :       \returns \ref status_codes
     438             :     */
     439             :     int16_t transmit(__FlashStringHelper* fstr, uint8_t addr = 0);
     440             : 
     441             :     /*!
     442             :       \brief Arduino String transmit method.
     443             :       \param str Address of Arduino string that will be transmitted.
     444             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     445             :       \returns \ref status_codes
     446             :     */
     447             :     int16_t transmit(String& str, uint8_t addr = 0);
     448             :     #endif
     449             : 
     450             :     /*!
     451             :       \brief C-string transmit method.
     452             :       \param str C-string that will be transmitted.
     453             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     454             :       \returns \ref status_codes
     455             :     */
     456             :     int16_t transmit(const char* str, uint8_t addr = 0);
     457             : 
     458             :     /*!
     459             :       \brief Binary transmit method. Must be implemented in module class.
     460             :       \param data Binary data that will be transmitted.
     461             :       \param len Length of binary data to transmit (in bytes).
     462             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     463             :       \returns \ref status_codes
     464             :     */
     465             :     virtual int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0);
     466             : 
     467             :     #if defined(RADIOLIB_BUILD_ARDUINO)
     468             :     /*!
     469             :       \brief Arduino String receive method.
     470             :       \param str Address of Arduino String to save the received data.
     471             :       \param len Expected number of characters in the message. Leave as 0 if expecting a unknown size packet.
     472             :       \param timeout Reception timeout in milliseconds. If set to 0,
     473             :       timeout period will be calculated automatically based on the radio configuration.
     474             :       \returns \ref status_codes
     475             :     */
     476             :     int16_t receive(String& str, size_t len = 0, RadioLibTime_t timeout = 0);
     477             :     #endif
     478             : 
     479             :     /*!
     480             :       \brief Sets module to sleep.
     481             :       \returns \ref status_codes
     482             :     */
     483             :     virtual int16_t sleep();
     484             : 
     485             :     /*!
     486             :       \brief Sets module to standby.
     487             :       \returns \ref status_codes
     488             :     */
     489             :     virtual int16_t standby();
     490             : 
     491             :     /*!
     492             :       \brief Sets module to a specific standby mode.
     493             :       \returns \ref status_codes
     494             :     */
     495             :     virtual int16_t standby(uint8_t mode);
     496             : 
     497             :     /*!
     498             :       \brief Sets module to received mode using its default configuration.
     499             :       \returns \ref status_codes
     500             :     */
     501             :     virtual int16_t startReceive();
     502             : 
     503             :     /*!
     504             :       \brief Interrupt-driven receive method. A DIO pin will be activated when full packet is received. 
     505             :       Must be implemented in module class.
     506             :       \param timeout Raw timeout value. Some modules use this argument to specify operation mode
     507             :       (single vs. continuous receive).
     508             :       \param irqFlags Sets the IRQ flags.
     509             :       \param irqMask Sets the mask of IRQ flags that will trigger the radio interrupt pin.
     510             :       \param len Packet length, needed for some modules under special circumstances (e.g. LoRa implicit header mode).
     511             :       \returns \ref status_codes
     512             :     */
     513             :     virtual int16_t startReceive(uint32_t timeout, RadioLibIrqFlags_t irqFlags = RADIOLIB_IRQ_RX_DEFAULT_FLAGS, RadioLibIrqFlags_t irqMask = RADIOLIB_IRQ_RX_DEFAULT_MASK, size_t len = 0);
     514             : 
     515             :     /*!
     516             :       \brief Binary receive method. Must be implemented in module class.
     517             :       \param data Pointer to array to save the received binary data.
     518             :       \param len Packet length, needed for some modules under special circumstances (e.g. LoRa implicit header mode).
     519             :       \param timeout Reception timeout in milliseconds. If set to 0,
     520             :       timeout period will be calculated automatically based on the radio configuration.
     521             :       \returns \ref status_codes
     522             :     */
     523             :     virtual int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0);
     524             : 
     525             :     #if defined(RADIOLIB_BUILD_ARDUINO)
     526             :     /*!
     527             :       \brief Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking.
     528             :       Interrupt pin will be activated when transmission finishes.
     529             :       \param str Address of Arduino String that will be transmitted.
     530             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     531             :       \returns \ref status_codes
     532             :     */
     533             :     int16_t startTransmit(String& str, uint8_t addr = 0);
     534             :     #endif
     535             : 
     536             :     /*!
     537             :       \brief Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking.
     538             :       Interrupt pin will be activated when transmission finishes.
     539             :       \param str C-string that will be transmitted.
     540             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     541             :       \returns \ref status_codes
     542             :     */
     543             :     int16_t startTransmit(const char* str, uint8_t addr = 0);
     544             : 
     545             :     /*!
     546             :       \brief Interrupt-driven binary transmit method.
     547             :       \param data Binary data that will be transmitted.
     548             :       \param len Length of binary data to transmit (in bytes).
     549             :       \param addr Node address to transmit the packet to. Only used in FSK mode.
     550             :       \returns \ref status_codes
     551             :     */
     552             :     virtual int16_t startTransmit(const uint8_t* data, size_t len, uint8_t addr = 0);
     553             : 
     554             :     /*!
     555             :       \brief Clean up after transmission is done.
     556             :       \returns \ref status_codes
     557             :     */
     558             :     virtual int16_t finishTransmit();
     559             : 
     560             :     /*!
     561             :       \brief Clean up after reception is done.
     562             :       \returns \ref status_codes
     563             :     */
     564             :     virtual int16_t finishReceive();
     565             : 
     566             :     #if defined(RADIOLIB_BUILD_ARDUINO)
     567             :     /*!
     568             :       \brief Reads data that was received after calling startReceive method.
     569             :       \param str Address of Arduino String to save the received data.
     570             :       \param len Expected number of characters in the message. When set to 0, the packet length will be retrieved 
     571             :       automatically. When more bytes than received are requested, only the number of bytes requested will be returned.
     572             :       \returns \ref status_codes
     573             :     */
     574             :     int16_t readData(String& str, size_t len = 0);
     575             :     #endif
     576             : 
     577             :     /*!
     578             :       \brief Reads data that was received after calling startReceive method.
     579             :       \param data Pointer to array to save the received binary data.
     580             :       \param len Number of bytes that will be read. When set to 0, the packet length will be retrieved automatically.
     581             :       When more bytes than received are requested, only the number of bytes requested will be returned.
     582             :       \returns \ref status_codes
     583             :     */
     584             :     virtual int16_t readData(uint8_t* data, size_t len);
     585             : 
     586             :     /*!
     587             :       \brief Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class.
     588             :       While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode.
     589             :       \param frf 24-bit raw frequency value to start transmitting at. Required for quick frequency shifts in RTTY.
     590             :       \returns \ref status_codes
     591             :     */
     592             :     virtual int16_t transmitDirect(uint32_t frf = 0);
     593             : 
     594             :     /*!
     595             :       \brief Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). Must be implemented in module class.
     596             :       While in direct mode, the module will not be able to transmit or receive packets. Can only be activated in FSK mode.
     597             :       \returns \ref status_codes
     598             :     */
     599             :     virtual int16_t receiveDirect();
     600             : 
     601             :     // configuration methods
     602             : 
     603             :     /*!
     604             :       \brief Sets carrier frequency. Must be implemented in module class.
     605             :       \param freq Carrier frequency to be set in Hz.
     606             :       \returns \ref status_codes
     607             :     */
     608             :     virtual int16_t setFrequency(uint32_t freq);
     609             : 
     610             :     /*!
     611             :       \brief Sets FSK bit rate. Only available in FSK mode. Must be implemented in module class.
     612             :       \param br Bit rate to be set (in bps).
     613             :       \returns \ref status_codes
     614             :     */
     615             :     virtual int16_t setBitRate(uint32_t br);
     616             : 
     617             :     /*!
     618             :       \brief Sets FSK frequency deviation from carrier frequency. Only available in FSK mode.
     619             :       Must be implemented in module class.
     620             :       \param freqDev Frequency deviation to be set in Hz.
     621             :       \returns \ref status_codes
     622             :     */
     623             :     virtual int16_t setFrequencyDeviation(uint32_t freqDev);
     624             : 
     625             :     /*!
     626             :       \brief Sets LoRa spreading factor. Must be implemented in module class.
     627             :       \param sf LoRa spreading factor to be set.
     628             :       \returns \ref status_codes
     629             :     */
     630             :     virtual int16_t setSpreadingFactor(uint8_t sf);
     631             : 
     632             :     /*!
     633             :       \brief Sets LoRa bandwidth. Must be implemented in module class.
     634             :       \param bw LoRa bandwidth to be set in Hz.
     635             :       \returns \ref status_codes
     636             :     */
     637             :     virtual int16_t setBandwidth(uint32_t bw);
     638             : 
     639             :     /*!
     640             :       \brief Sets LoRa coding rate denominator. Must be implemented in module class.
     641             :       \param cr LoRa coding rate denominator to be set. Allowed values range from 4 to 8.
     642             :        Note that a value of 4 means no coding, is undocumented and not recommended without your own FEC.
     643             :       \param longInterleave Enable long interleaver when set to true.
     644             :       Note that with long interleaver enabled, CR 4/7 is not possible, 
     645             :       there are packet length restrictions,
     646             :       and it is not compatible with SX127x radios!
     647             :       \returns \ref status_codes
     648             :     */
     649             :     virtual int16_t setCodingRate(uint8_t cr, bool longInterleave = false);
     650             : 
     651             :     /*!
     652             :       \brief Sets LR-FHSS configuration. Must be implemented in module class.
     653             :       \param bw LR-FHSS bandwidth, one of RADIOLIB_LR_FHSS_BW_* values.
     654             :       \param cr LR-FHSS coding rate, one of RADIOLIB_LR_FHSS_CR_* values.
     655             :       \param narrowGrid True for narrow (non-FCC) hopping grid; false for wide (FCC) grid.
     656             :       \param hdrCount Header packet count, 1 - 4. Defaults to 3.
     657             :       \param hopSeed 9-bit seed number for PRNG generation of the hopping sequence. Defaults to 0x13A.
     658             :       \returns \ref status_codes
     659             :     */
     660             :     virtual int16_t setLrFhssConfig(uint8_t bw, uint8_t cr, bool narrowGrid, uint8_t hdrCount = 3, uint16_t hopSeed = 0x13A);
     661             : 
     662             :     /*!
     663             :       \brief Sets GFSK data shaping. Only available in FSK mode. Must be implemented in module class.
     664             :       \param sh Shaping to be set. See \ref config_shaping for possible values.
     665             :       \returns \ref status_codes
     666             :     */
     667             :     virtual int16_t setDataShaping(uint8_t sh);
     668             : 
     669             :     /*!
     670             :       \brief Sets FSK data encoding. Only available in FSK mode. Must be implemented in module class.
     671             :       \param encoding Encoding to be used. See \ref config_encoding for possible values.
     672             :       \returns \ref status_codes
     673             :     */
     674             :     virtual int16_t setEncoding(uint8_t encoding);
     675             : 
     676             :     /*!
     677             :       \brief Set IQ inversion. Must be implemented in module class if the module supports it.
     678             :       \param enable True to use inverted IQ, false for non-inverted.
     679             :       \returns \ref status_codes
     680             :     */
     681             :     virtual int16_t invertIQ(bool enable);
     682             : 
     683             :     /*!
     684             :       \brief Set output power. Must be implemented in module class if the module supports it.
     685             :       \param power Output power in dBm. The allowed range depends on the module used.
     686             :       \returns \ref status_codes
     687             :     */
     688             :     virtual int16_t setOutputPower(int8_t power);
     689             : 
     690             :     /*!
     691             :       \brief Sets offset of the output power. Useful for devices where the radio has an external power amplifier,
     692             :       or of the RF system has a known loss between the radio and the antenna.
     693             :       NOTE: This method must be called BEFORE any calls to radio.begin() or radio.setOutputPower()
     694             :       for the offset to be applied!
     695             :       \param offset Offset to apply. If the PA has a linear gain of 12 dB, call radio.setOutputPowerOffset(12).
     696             :       If the setup has 1 dB of loss, call radio.setOutputPowerOffset(-1) to compensate.
     697             :       \returns \ref status_codes
     698             :     */
     699             :     int16_t setOutputPowerOffset(int8_t offset);
     700             : 
     701             :     /*!
     702             :       \brief Sets offset of the output power. Useful for devices where the radio has an external power amplifier,
     703             :       or of the RF system has a known loss between the radio and the antenna.
     704             :       This overload allows to compensate a non-linear PA gain, dependant on the radio power output via a lookup table.
     705             :       NOTE: This method must be called BEFORE any calls to radio.begin() or radio.setOutputPower()
     706             :       for the offset to be applied!
     707             :       \param lut Pointer to a lookup table to use - for each output power configuration, value from the lookup table
     708             :       will be applied as offset.
     709             :       NOTE: The lookup table must be monotonically decreasing (values are always either lowering 
     710             :       or remaining the same) and in 1 dB steps.
     711             :       \param steps Number of steps/entries in the lookup table - this depends on the range of output power
     712             :       by the radio module. Different radio modules support different output power ranges!
     713             :       \returns \ref status_codes
     714             :     */
     715             :     int16_t setOutputPowerOffset(const int8_t* lut, size_t steps);
     716             : 
     717             :     /*!
     718             :       \brief Set sync word. Must be implemented in module class if the module supports it.
     719             :       \param sync Pointer to the sync word.
     720             :       \param len Sync word length in bytes. Maximum length depends on the module used.
     721             :       \returns \ref status_codes
     722             :     */
     723             :     virtual int16_t setSyncWord(uint8_t* sync, size_t len);
     724             : 
     725             :     /*!
     726             :       \brief Set preamble length. Must be implemented in module class if the module supports it.
     727             :       \param len Preamble length in symbols (LoRa) or bits (FSK). Maximum length depends on the module used.
     728             :       \param detLen Minimum detected preamble length during reception. Allowed values depend on the module used.
     729             :       \returns \ref status_codes
     730             :     */
     731             :     virtual int16_t setPreambleLength(size_t len, size_t detLen = 0xFFFFFFFF);
     732             :     
     733             :     /*!
     734             :       \brief Set data rate. Must be implemented in module class if the module supports it.
     735             :       \param dr Data rate struct.
     736             :       \param modem The modem corresponding to the requested datarate (FSK, LoRa or LR-FHSS). 
     737             :       Defaults to currently active modem if not supplied.
     738             :       \returns \ref status_codes
     739             :     */
     740             :     virtual int16_t setDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE);
     741             : 
     742             :     /*!
     743             :       \brief Check the data rate can be configured by this module. Must be implemented in module class if the module supports it.
     744             :       \param dr Data rate struct.
     745             :       \param modem The modem corresponding to the requested datarate (FSK, LoRa or LR-FHSS). 
     746             :       Defaults to currently active modem if not supplied.
     747             :       \returns \ref status_codes
     748             :     */
     749             :     virtual int16_t checkDataRate(DataRate_t dr, ModemType_t modem = RADIOLIB_MODEM_NONE);
     750             : 
     751             :     /*!
     752             :       \brief Query modem for the packet length of received payload. Must be implemented in module class.
     753             :       \param update Update received packet length. Will return cached value when set to false.
     754             :       \returns Length of last received packet in bytes.
     755             :     */
     756             :     virtual size_t getPacketLength(bool update = true);
     757             : 
     758             :     /*!
     759             :       \brief Gets RSSI (Received Signal Strength Indicator) of the last received packet.
     760             :       \returns RSSI of the last received packet in dBm.
     761             :     */
     762             :     virtual float getRSSI();
     763             : 
     764             :     /*!
     765             :       \brief Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
     766             :       \returns SNR of the last received packet in dB.
     767             :     */
     768             :     virtual float getSNR();
     769             : 
     770             :     /*!
     771             :       \brief Convert from bytes to LoRa symbols.
     772             :       \param dr Data rate.
     773             :       \param pc Packet configuration.
     774             :       \param len Payload length in bytes.
     775             :       \returns The total number of LoRa symbols, including preamble, sync and possible header.
     776             :     */
     777             :     static float getNumSymbols(DataRate_t dr, PacketConfig_t pc, size_t len);
     778             :     
     779             :     /*!
     780             :       \brief Calculate the expected time-on-air for a given modem, data rate, packet configuration and payload size.
     781             :       \param modem Modem type.
     782             :       \param dr Data rate.
     783             :       \param pc Packet config.
     784             :       \param len Payload length in bytes.
     785             :       \returns Expected time-on-air in microseconds.
     786             :     */
     787             :     virtual RadioLibTime_t calculateTimeOnAir(ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len);
     788             : 
     789             :     /*!
     790             :       \brief Get expected time-on-air for a given size of payload
     791             :       \param len Payload length in bytes.
     792             :       \returns Expected time-on-air in microseconds.
     793             :     */
     794             :     virtual RadioLibTime_t getTimeOnAir(size_t len);
     795             : 
     796             :     /*!
     797             :       \brief Calculate the timeout value for this specific module / series 
     798             :       (in number of symbols or units of time).
     799             :       \param timeoutUs Timeout in microseconds to listen for.
     800             :       \returns Timeout value in a unit that is specific for the used module.
     801             :     */
     802             :     virtual RadioLibTime_t calculateRxTimeout(RadioLibTime_t timeoutUs);
     803             : 
     804             :     /*!
     805             :       \brief Convert from radio-agnostic IRQ flags to radio-specific flags.
     806             :       \param irq Radio-agnostic IRQ flags.
     807             :       \returns Flags for a specific radio module.
     808             :     */
     809             :     uint32_t getIrqMapped(RadioLibIrqFlags_t irq);
     810             : 
     811             :     /*!
     812             :       \brief Check whether a specific IRQ bit is set (e.g. RxTimeout, CadDone).
     813             :       \param irq IRQ type to check, one of RADIOLIB_IRQ_*.
     814             :       \returns 1 when requested IRQ is set, 0 when it is not or RADIOLIB_ERR_UNSUPPORTED if the IRQ is not supported.
     815             :     */
     816             :     int16_t checkIrq(RadioLibIrqType_t irq);
     817             : 
     818             :     /*!
     819             :       \brief Set interrupt on specific IRQ bit(s) (e.g. RxTimeout, CadDone).
     820             :       Keep in mind that not all radio modules support all RADIOLIB_IRQ_ flags!
     821             :       \param irq Flags to set, multiple bits may be enabled. IRQ to enable corresponds to the bit index (RadioLibIrq_t).
     822             :       For example, if bit 0 is enabled, the module will enable its RADIOLIB_IRQ_TX_DONE (if it is supported).
     823             :       \returns \ref status_codes
     824             :     */
     825             :     int16_t setIrq(RadioLibIrqFlags_t irq);
     826             : 
     827             :     /*!
     828             :       \brief Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
     829             :       Keep in mind that not all radio modules support all RADIOLIB_IRQ_ flags!
     830             :       \param irq Flags to set, multiple bits may be enabled. IRQ to enable corresponds to the bit index (RadioLibIrq_t).
     831             :       For example, if bit 0 is enabled, the module will enable its RADIOLIB_IRQ_TX_DONE (if it is supported).
     832             :       \returns \ref status_codes
     833             :     */
     834             :     int16_t clearIrq(RadioLibIrqFlags_t irq);
     835             : 
     836             :     /*!
     837             :       \brief Read currently active IRQ flags.
     838             :       Must be implemented in module class.
     839             :       \returns IRQ flags.
     840             :     */
     841             :     virtual uint32_t getIrqFlags();
     842             : 
     843             :     /*!
     844             :       \brief Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone).
     845             :       Must be implemented in module class.
     846             :       \param irq Module-specific IRQ flags.
     847             :       \returns \ref status_codes
     848             :     */
     849             :     virtual int16_t setIrqFlags(uint32_t irq);
     850             : 
     851             :     /*!
     852             :       \brief Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
     853             :       Must be implemented in module class.
     854             :       \param irq Module-specific IRQ flags.
     855             :       \returns \ref status_codes
     856             :     */
     857             :     virtual int16_t clearIrqFlags(uint32_t irq);
     858             : 
     859             :     /*!
     860             :       \brief Interrupt-driven channel activity detection method. Interrupt will be activated
     861             :       when packet is detected. Must be implemented in module class.
     862             :       \returns \ref status_codes
     863             :     */
     864             :     virtual int16_t startChannelScan();
     865             : 
     866             :     /*!
     867             :       \brief Interrupt-driven channel activity detection method. interrupt will be activated
     868             :       when packet is detected. Must be implemented in module class.
     869             :       \param config Scan configuration structure. Interpretation depends on currently active modem.
     870             :       \returns \ref status_codes
     871             :     */
     872             :     virtual int16_t startChannelScan(const ChannelScanConfig_t &config);
     873             : 
     874             :     /*!
     875             :       \brief Read the channel scan result
     876             :       \returns \ref status_codes
     877             :     */
     878             :     virtual int16_t getChannelScanResult();
     879             : 
     880             :     /*!
     881             :       \brief Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules,
     882             :       or RSSI measurement for FSK modules.
     883             :       \returns RADIOLIB_CHANNEL_FREE when channel is free,
     884             :       RADIOLIB_LORA_DETECTED when occupied or other \ref status_codes.
     885             :     */
     886             :     virtual int16_t scanChannel();
     887             : 
     888             :     /*!
     889             :       \brief Check whether the current communication channel is free or occupied. Performs CAD for LoRa modules,
     890             :       or RSSI measurement for FSK modules.
     891             :       \param config Scan configuration structure. Interpretation depends on currently active modem.
     892             :       \returns RADIOLIB_CHANNEL_FREE when channel is free,
     893             :       RADIOLIB_LORA_DETECTED when occupied or other \ref status_codes.
     894             :     */
     895             :     virtual int16_t scanChannel(const ChannelScanConfig_t &config);
     896             : 
     897             :     /*!
     898             :       \brief Get truly random number in range 0 - max.
     899             :       \param max The maximum value of the random number (non-inclusive).
     900             :       \returns Random number.
     901             :     */
     902             :     int32_t random(int32_t max);
     903             : 
     904             :     /*!
     905             :       \brief Get truly random number in range min - max.
     906             :       \param min The minimum value of the random number (inclusive).
     907             :       \param max The maximum value of the random number (non-inclusive).
     908             :       \returns Random number.
     909             :     */
     910             :     int32_t random(int32_t min, int32_t max);
     911             : 
     912             :     /*!
     913             :       \brief Get one truly random byte from RSSI noise. Must be implemented in module class.
     914             :       \returns TRNG byte.
     915             :     */
     916             :     virtual uint8_t randomByte();
     917             : 
     918             :     /*!
     919             :       \brief Configure module parameters for direct modes. Must be called prior to "ham" modes like RTTY or AX.25.
     920             :       Only available in FSK mode.
     921             :       \returns \ref status_codes
     922             :     */
     923             :     int16_t startDirect();
     924             : 
     925             :     #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
     926             :     /*!
     927             :       \brief Set sync word to be used to determine start of packet in direct reception mode.
     928             :       \param syncWord Sync word bits.
     929             :       \param len Sync word length in bits. Set to zero to disable sync word matching.
     930             :       \returns \ref status_codes
     931             :     */
     932             :     int16_t setDirectSyncWord(uint32_t syncWord, uint8_t len);
     933             : 
     934             :     /*!
     935             :       \brief Set interrupt service routine function to call when data bit is received in direct mode.
     936             :       Must be implemented in module class.
     937             :       \param func Pointer to interrupt service routine.
     938             :     */
     939             :     virtual void setDirectAction(void (*func)(void));
     940             : 
     941             :     /*!
     942             :       \brief Function to read and process data bit in direct reception mode. Must be implemented in module class.
     943             :       \param pin Pin on which to read.
     944             :     */
     945             :     virtual void readBit(uint32_t pin);
     946             : 
     947             :     /*!
     948             :       \brief Get the number of direct mode bytes currently available in buffer.
     949             :       \returns Number of available bytes.
     950             :     */
     951             :     int16_t available();
     952             : 
     953             :     /*!
     954             :       \brief Forcefully drop synchronization.
     955             :     */
     956             :     void dropSync();
     957             : 
     958             :     /*!
     959             :       \brief Get data from direct mode buffer.
     960             :       \param drop Drop synchronization on read - next reading will require waiting for the sync word again.
     961             :       Defaults to true.
     962             :       \returns Byte from direct mode buffer.
     963             :     */
     964             :     uint8_t read(bool drop = true);
     965             :     #endif
     966             : 
     967             :     /*!
     968             :       \brief Sets interrupt service routine to call when IRQ is activated.
     969             :       \param func ISR to call.
     970             :       \param rising Whether to activate on rising (true) or falling (false) edge, defaults to rising.
     971             :     */
     972             :     virtual void setIrqAction(void (*func)(void), bool rising = true);
     973             : 
     974             :     /*!
     975             :       \brief Clears interrupt service routine to call when IRQ is activated.
     976             :     */
     977             :     virtual void clearIrqAction();
     978             : 
     979             :     /*!
     980             :       \brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
     981             :       using its default parameters.
     982             :       \param modem Modem type to set. Not all modems are implemented by all radio modules!
     983             :       \returns \ref status_codes
     984             :     */
     985             :     virtual int16_t setModem(ModemType_t modem);
     986             : 
     987             :     /*!
     988             :       \brief Get modem currently in use by the radio.
     989             :       \param modem Pointer to a variable to save the retrieved configuration into.
     990             :       \returns \ref status_codes
     991             :     */
     992             :     virtual int16_t getModem(ModemType_t* modem);
     993             : 
     994             :     /*!
     995             :       \brief Read the operating mode the radio is in, as the chip reports it.
     996             :       Unlike PhysicalLayer::stagedMode, which is what was last asked of the radio, this reads the
     997             :       hardware, so a caller can tell a radio that has left a mode on its own - a receive that did not
     998             :       survive a frame, or a chip that lost its state - from one that is still in it.
     999             :       \param mode Pointer to the variable to save the mode into. A mode the chip reports that has no
    1000             :       RadioModeType_t equivalent, frequency synthesis for example, is reported as
    1001             :       RADIOLIB_RADIO_MODE_NONE.
    1002             :       \returns \ref status_codes
    1003             :     */
    1004             :     virtual int16_t getMode(RadioModeType_t* mode);
    1005             : 
    1006             :     /*!
    1007             :       \brief Stage mode of the radio to be launched later using launchMode.
    1008             :       \param mode Radio mode to prepare.
    1009             :       \param cfg Configuration of this mode (mode-dependent).
    1010             :       \returns \ref status_codes
    1011             :     */
    1012             :     virtual int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg);
    1013             : 
    1014             :     /*!
    1015             :       \brief Launch previously staged mode.
    1016             :       \returns \ref status_codes
    1017             :     */
    1018             :     virtual int16_t launchMode();
    1019             : 
    1020             :     /*!
    1021             :       \brief Write a payload into the transmit buffer without staging or starting a transmission.
    1022             :       This allows the payload write, which is the slowest part of starting a transmission, to be done
    1023             :       while the radio is busy with something else - during a channel scan, for example. The
    1024             :       transmission is staged afterwards by calling stageMode with RADIOLIB_RADIO_MODE_TX and
    1025             :       RadioModeConfig_t::transmit.data set to NULL, which sets the packet parameters and the IRQ
    1026             :       mapping for the payload already in the buffer; transmit.len must still be set to its length.
    1027             :       The buffer holds exactly this payload after the call, whether or not one was written before.
    1028             :       \param data Payload to write into the transmit buffer.
    1029             :       \param len Payload length in bytes.
    1030             :       \returns \ref status_codes
    1031             :     */
    1032             :     virtual int16_t writeTxBuffer(const uint8_t* data, size_t len);
    1033             : 
    1034             :     /*!
    1035             :       \brief Discard a payload previously written by writeTxBuffer. On radios whose transmit buffer
    1036             :       is simply overwritten by the next write there is nothing to discard, and this reports success
    1037             :       without touching the radio.
    1038             :       \returns \ref status_codes
    1039             :     */
    1040             :     virtual int16_t clearTxBuffer();
    1041             : 
    1042             :     #if RADIOLIB_INTERRUPT_TIMING
    1043             : 
    1044             :     /*!
    1045             :       \brief Set function to be called to set up the timing interrupt.
    1046             :       For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing
    1047             :       \param func Setup function to be called, with one argument (pulse length in microseconds).
    1048             :     */
    1049             :     void setInterruptSetup(void (*func)(uint32_t));
    1050             : 
    1051             :     /*!
    1052             :       \brief Set timing interrupt flag.
    1053             :       For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing
    1054             :     */
    1055             :     void setTimerFlag();
    1056             : 
    1057             :     #endif
    1058             : 
    1059             :     /*!
    1060             :       \brief Calculates sleep and wake cycles for startReceiveDutyCycle methods so that the receiver should not miss any messages.
    1061             :       Useful only for LoRa modems. 
    1062             :       \param txPreLen Expected preamble length of the messages to receive.
    1063             :       If set to zero, the receiver preamble length will be used.
    1064             :       This value cannot exceed the configured preamble length. If the sender preamble length is variable, set the
    1065             :       maximum expected length by calling setPreambleLength(maximumExpectedLength) prior to this method, and use the
    1066             :       minimum expected length here.
    1067             :       \param rxPreLen Currently configured preamble length of the receiver (this radio).
    1068             :       \param minSymbols Ensure that the unit will catch at least this many symbols of any preamble of the specified senderPreambleLength.
    1069             :       To reliably latch a preamble, the receiver requires 8 symbols for SF7-12 and 12 symbols for SF5-6.
    1070             :       If set to zero, the minimum required symbols will be used.
    1071             :       \param dr Pointer to structure holding LoRa data rate information (only spreading factor and bandwidth are used).
    1072             :       \param wakePeriod Pointer to variable where the calculated wake period in microseconds will be stored.
    1073             :       \param sleePeriod Pointer to variable where the calculated sleep period in microseconds will be stored.
    1074             :       \returns \ref status_codes
    1075             :     */
    1076             :     int16_t calculateRxDutyCycle(size_t txPreLen, size_t rxPreLen, uint16_t minSymbols, DataRate_t* dr, uint32_t* wakePeriod, uint32_t* sleepPeriod);
    1077             : 
    1078             :     /*!
    1079             :       \brief Get the minimum output power supported by the radio.
    1080             :       This includes any previously configured PA offset.
    1081             :       \returns The minimum supported output power in dBm.
    1082             :     */
    1083             :     int8_t getOutputPowerMin() const { return(powerMin); }
    1084             :     
    1085             :     /*!
    1086             :       \brief Get the maximum output power supported by the radio.
    1087             :       This includes any previously configured PA offset.
    1088             :       \returns The maximum supported output power in dBm.
    1089             :     */
    1090             :     int8_t getOutputPowerMax() const { return(powerMax); }
    1091             : 
    1092             : #if !RADIOLIB_GODMODE
    1093             :   protected:
    1094             : #endif
    1095             :     int8_t powerMin = 0, powerMax = 0;
    1096             :     uint8_t paSteps = 0;
    1097             :     
    1098             :     uint32_t irqMap[10] = { 0 };
    1099             :     RadioModeType_t stagedMode = RADIOLIB_RADIO_MODE_NONE;
    1100             :     
    1101             :     /*!
    1102             :       \brief Apply output power offset and check power configuration range is feasible for the radio.
    1103             :       \param base Base value of the PA lookup table.
    1104             :       NOTE: If the radio implements multiple power-devepended transmit paths,
    1105             :       the base needs to be the minimum!
    1106             :       \param pwrReq Pointer to variable holding power requested by the user.
    1107             :       \param pwrRadio Pointer to variable where resulting power with applied offset will be saved.
    1108             :       \returns \ref status_codes
    1109             :     */
    1110             :     int16_t applyOutputPowerOffset(int8_t base, const int8_t* pwrReq, int8_t* pwrRadio);
    1111             :     int16_t findRxBw(uint32_t rxBw, const uint32_t* rxBwAvg, const uint8_t* lut, size_t lutSize, uint32_t rxBwMax, uint8_t* val);
    1112             : 
    1113             : #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
    1114             :     void updateDirectBuffer(uint8_t bit);
    1115             : #endif
    1116             : 
    1117             : #if !RADIOLIB_GODMODE
    1118             :   private:
    1119             : #endif
    1120             : 
    1121             :     #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
    1122             :     uint8_t bufferBitPos = 0;
    1123             :     uint8_t bufferWritePos = 0;
    1124             :     uint8_t bufferReadPos = 0;
    1125             :     uint8_t buffer[RADIOLIB_STATIC_ARRAY_SIZE] = { 0 };
    1126             :     uint32_t syncBuffer = 0;
    1127             :     uint32_t directSyncWord = 0;
    1128             :     uint8_t directSyncWordLen = 0;
    1129             :     uint32_t directSyncWordMask = 0;
    1130             :     bool gotSync = false;
    1131             :     #endif
    1132             : 
    1133             :     virtual Module* getMod() = 0;
    1134             : 
    1135             :     // allow specific classes access the private getMod method
    1136             :     friend class AFSKClient;
    1137             :     friend class RTTYClient;
    1138             :     friend class MorseClient;
    1139             :     friend class HellClient;
    1140             :     friend class SSTVClient;
    1141             :     friend class AX25Client;
    1142             :     friend class FSK4Client;
    1143             :     friend class PagerClient;
    1144             :     friend class BellClient;
    1145             :     friend class FT8Client;
    1146             :     friend class LoRaWANNode;
    1147             :     friend class M17Client;
    1148             : 
    1149             :     int8_t paOffsetLut[48] = { 0 };
    1150             : };
    1151             : 
    1152             : #endif

Generated by: LCOV version 1.14