acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

SX1273.cpp (1515B)

      1 #include "SX1273.h"
      2 #if !defined(RADIOLIB_EXCLUDE_SX127X)
      3 
      4 SX1273::SX1273(Module* mod) : SX1272(mod) {
      5 
      6 }
      7 
      8 int16_t SX1273::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   int16_t state = SX127x::begin(RADIOLIB_SX1272_CHIP_VERSION, syncWord, preambleLength);
     11   RADIOLIB_ASSERT(state);
     12 
     13   // configure publicly accessible settings
     14   state = setBandwidth(bw);
     15   RADIOLIB_ASSERT(state);
     16 
     17   state = setFrequency(freq);
     18   RADIOLIB_ASSERT(state);
     19 
     20   state = setSpreadingFactor(sf);
     21   RADIOLIB_ASSERT(state);
     22 
     23   state = setCodingRate(cr);
     24   RADIOLIB_ASSERT(state);
     25 
     26   state = setOutputPower(power);
     27   RADIOLIB_ASSERT(state);
     28 
     29   state = setGain(gain);
     30   RADIOLIB_ASSERT(state);
     31 
     32   return(state);
     33 }
     34 
     35 int16_t SX1273::setSpreadingFactor(uint8_t sf) {
     36   uint8_t newSpreadingFactor;
     37 
     38   // check allowed spreading factor values
     39   switch(sf) {
     40     case 6:
     41       newSpreadingFactor = RADIOLIB_SX127X_SF_6;
     42       break;
     43     case 7:
     44       newSpreadingFactor = RADIOLIB_SX127X_SF_7;
     45       break;
     46     case 8:
     47       newSpreadingFactor = RADIOLIB_SX127X_SF_8;
     48       break;
     49     case 9:
     50       newSpreadingFactor = RADIOLIB_SX127X_SF_9;
     51       break;
     52     default:
     53       return(RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
     54   }
     55 
     56   // set spreading factor and if successful, save the new setting
     57   int16_t state = setSpreadingFactorRaw(newSpreadingFactor);
     58   if(state == RADIOLIB_ERR_NONE) {
     59     SX127x::_sf = sf;
     60   }
     61 
     62   return(state);
     63 }
     64 
     65 #endif