LCOV - code coverage report
Current view: top level - src/modules/SX127x - SX1276.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 8 53 15.1 %
Date: 2026-02-22 10:42:45 Functions: 3 5 60.0 %

          Line data    Source code
       1             : #include "SX1276.h"
       2             : #if !RADIOLIB_EXCLUDE_SX127X
       3             : 
       4           1 : SX1276::SX1276(Module* mod) : SX1278(mod) {
       5             : 
       6           1 : }
       7             : 
       8           0 : int16_t SX1276::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) {
       9             :   // execute common part
      10           0 :   const uint8_t versions[] = { RADIOLIB_SX1278_CHIP_VERSION, RADIOLIB_SX1278_CHIP_VERSION_ALT, RADIOLIB_SX1278_CHIP_VERSION_RFM9X };
      11           0 :   int16_t state = SX127x::begin(versions, 3, syncWord, preambleLength);
      12           0 :   RADIOLIB_ASSERT(state);
      13             : 
      14             :   // configure publicly accessible settings
      15           0 :   state = setBandwidth(bw);
      16           0 :   RADIOLIB_ASSERT(state);
      17             : 
      18           0 :   state = setFrequency(freq);
      19           0 :   RADIOLIB_ASSERT(state);
      20             : 
      21           0 :   state = setSpreadingFactor(sf);
      22           0 :   RADIOLIB_ASSERT(state);
      23             : 
      24           0 :   state = setCodingRate(cr);
      25           0 :   RADIOLIB_ASSERT(state);
      26             : 
      27           0 :   state = setOutputPower(power);
      28           0 :   RADIOLIB_ASSERT(state);
      29             : 
      30           0 :   state = setGain(gain);
      31           0 :   RADIOLIB_ASSERT(state);
      32             : 
      33             :   // set publicly accessible settings that are not a part of begin method
      34           0 :   state = setCRC(true);
      35           0 :   RADIOLIB_ASSERT(state);
      36             : 
      37           0 :   return(state);
      38             : }
      39             : 
      40           0 : int16_t SX1276::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, bool enableOOK) {
      41             :   // execute common part
      42           0 :   const uint8_t versions[] = { RADIOLIB_SX1278_CHIP_VERSION, RADIOLIB_SX1278_CHIP_VERSION_ALT, RADIOLIB_SX1278_CHIP_VERSION_RFM9X };
      43           0 :   int16_t state = SX127x::beginFSK(versions, 3, freqDev, rxBw, preambleLength, enableOOK);
      44           0 :   RADIOLIB_ASSERT(state);
      45             : 
      46             :   // configure settings not accessible by API
      47           0 :   state = configFSK();
      48           0 :   RADIOLIB_ASSERT(state);
      49             : 
      50             :   // configure publicly accessible settings
      51           0 :   state = setFrequency(freq);
      52           0 :   RADIOLIB_ASSERT(state);
      53             : 
      54           0 :   state = setBitRate(br);
      55           0 :   RADIOLIB_ASSERT(state);
      56             : 
      57           0 :   state = setOutputPower(power);
      58           0 :   RADIOLIB_ASSERT(state);
      59             : 
      60           0 :   if(enableOOK) {
      61           0 :     state = setDataShapingOOK(RADIOLIB_SHAPING_NONE);
      62           0 :     RADIOLIB_ASSERT(state);
      63             :   } else {
      64           0 :     state = setDataShaping(RADIOLIB_SHAPING_NONE);
      65           0 :     RADIOLIB_ASSERT(state);
      66             :   }
      67             : 
      68           0 :   return(state);
      69             : }
      70             : 
      71           1 : int16_t SX1276::setFrequency(float freq) {
      72           1 :   RADIOLIB_CHECK_RANGE(freq, 137.0f, 1020.0f, RADIOLIB_ERR_INVALID_FREQUENCY);
      73             : 
      74             :   // set frequency and if successful, save the new setting
      75           0 :   int16_t state = SX127x::setFrequencyRaw(freq);
      76           0 :   if(state == RADIOLIB_ERR_NONE) {
      77           0 :     SX127x::frequency = freq;
      78             :   }
      79           0 :   return(state);
      80             : }
      81             : 
      82           1 : int16_t SX1276::setModem(ModemType_t modem) {
      83           1 :   switch(modem) {
      84           0 :     case(ModemType_t::RADIOLIB_MODEM_LORA): {
      85           0 :       return(this->begin());
      86             :     } break;
      87           0 :     case(ModemType_t::RADIOLIB_MODEM_FSK): {
      88           0 :       return(this->beginFSK());
      89             :     } break;
      90           1 :     default:
      91           1 :       return(RADIOLIB_ERR_WRONG_MODEM);
      92             :   }
      93             : }
      94             : 
      95             : #endif

Generated by: LCOV version 1.14