[RFM9x] Update to 5.0.0

This commit is contained in:
jgromes 2021-11-14 11:43:25 +01:00
parent a229912789
commit 8e134a7980
5 changed files with 26 additions and 26 deletions

View file

@ -7,12 +7,12 @@ RFM95::RFM95(Module* mod) : SX1278(mod) {
int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) {
// execute common part // execute common part
int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength); int16_t state = SX127x::begin(RADIOLIB_RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength);
if(state == ERR_CHIP_NOT_FOUND) { if(state == RADIOLIB_ERR_CHIP_NOT_FOUND) {
// SX127X_REG_VERSION might be set 0x12 // SX127X_REG_VERSION might be set 0x12
state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength); state = SX127x::begin(RADIOLIB_RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength);
RADIOLIB_ASSERT(state); RADIOLIB_ASSERT(state);
} else if(state != ERR_NONE) { } else if(state != RADIOLIB_ERR_NONE) {
// some other error // some other error
return(state); return(state);
} }
@ -41,11 +41,11 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW
} }
int16_t RFM95::setFrequency(float freq) { int16_t RFM95::setFrequency(float freq) {
RADIOLIB_CHECK_RANGE(freq, 862.0, 1020.0, ERR_INVALID_FREQUENCY); RADIOLIB_CHECK_RANGE(freq, 862.0, 1020.0, RADIOLIB_ERR_INVALID_FREQUENCY);
// set frequency and if successful, save the new setting // set frequency and if successful, save the new setting
int16_t state = SX127x::setFrequencyRaw(freq); int16_t state = SX127x::setFrequencyRaw(freq);
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
SX127x::_freq = freq; SX127x::_freq = freq;
} }
return(state); return(state);

View file

@ -10,8 +10,8 @@
#include "../SX127x/SX1278.h" #include "../SX127x/SX1278.h"
// SX127X_REG_VERSION // SX127X_REG_VERSION
#define RFM9X_CHIP_VERSION_OFFICIAL 0x11 #define RADIOLIB_RFM9X_CHIP_VERSION_OFFICIAL 0x11
#define RFM9X_CHIP_VERSION_UNOFFICIAL 0x12 // according to datasheet, only 0x11 should be possible, but some modules seem to have 0x12 #define RADIOLIB_RFM9X_CHIP_VERSION_UNOFFICIAL 0x12 // according to datasheet, only 0x11 should be possible, but some modules seem to have 0x12
/*! /*!
\class RFM95 \class RFM95
@ -55,7 +55,7 @@ class RFM95: public SX1278 {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0);
// configuration methods // configuration methods

View file

@ -7,12 +7,12 @@ RFM96::RFM96(Module* mod) : SX1278(mod) {
int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) { int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) {
// execute common part // execute common part
int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength); int16_t state = SX127x::begin(RADIOLIB_RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength);
if(state == ERR_CHIP_NOT_FOUND) { if(state == RADIOLIB_ERR_CHIP_NOT_FOUND) {
// SX127X_REG_VERSION might be set 0x12 // SX127X_REG_VERSION might be set 0x12
state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength); state = SX127x::begin(RADIOLIB_RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength);
RADIOLIB_ASSERT(state); RADIOLIB_ASSERT(state);
} else if(state != ERR_NONE) { } else if(state != RADIOLIB_ERR_NONE) {
// some other error // some other error
return(state); return(state);
} }
@ -42,11 +42,11 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW
} }
int16_t RFM96::setFrequency(float freq) { int16_t RFM96::setFrequency(float freq) {
RADIOLIB_CHECK_RANGE(freq, 410.0, 525.0, ERR_INVALID_FREQUENCY); RADIOLIB_CHECK_RANGE(freq, 410.0, 525.0, RADIOLIB_ERR_INVALID_FREQUENCY);
// set frequency and if successful, save the new setting // set frequency and if successful, save the new setting
int16_t state = SX127x::setFrequencyRaw(freq); int16_t state = SX127x::setFrequencyRaw(freq);
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
SX127x::_freq = freq; SX127x::_freq = freq;
} }
return(state); return(state);

View file

@ -10,8 +10,8 @@
#include "../SX127x/SX1278.h" #include "../SX127x/SX1278.h"
// SX127X_REG_VERSION // SX127X_REG_VERSION
#define RFM9X_CHIP_VERSION_OFFICIAL 0x11 #define RADIOLIB_RFM9X_CHIP_VERSION_OFFICIAL 0x11
#define RFM9X_CHIP_VERSION_UNOFFICIAL 0x12 // according to datasheet, only 0x11 should be possible, but some modules seem to have 0x12 #define RADIOLIB_RFM9X_CHIP_VERSION_UNOFFICIAL 0x12 // according to datasheet, only 0x11 should be possible, but some modules seem to have 0x12
/*! /*!
\class RFM96 \class RFM96
@ -55,7 +55,7 @@ class RFM96: public SX1278 {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0);
// configuration methods // configuration methods

View file

@ -7,8 +7,8 @@ RFM97::RFM97(Module* mod) : RFM95(mod) {
int16_t RFM97::setSpreadingFactor(uint8_t sf) { int16_t RFM97::setSpreadingFactor(uint8_t sf) {
// check active modem // check active modem
if(getActiveModem() != SX127X_LORA) { if(getActiveModem() != RADIOLIB_SX127X_LORA) {
return(ERR_WRONG_MODEM); return(RADIOLIB_ERR_WRONG_MODEM);
} }
uint8_t newSpreadingFactor; uint8_t newSpreadingFactor;
@ -16,24 +16,24 @@ int16_t RFM97::setSpreadingFactor(uint8_t sf) {
// check allowed spreading factor values // check allowed spreading factor values
switch(sf) { switch(sf) {
case 6: case 6:
newSpreadingFactor = SX127X_SF_6; newSpreadingFactor = RADIOLIB_SX127X_SF_6;
break; break;
case 7: case 7:
newSpreadingFactor = SX127X_SF_7; newSpreadingFactor = RADIOLIB_SX127X_SF_7;
break; break;
case 8: case 8:
newSpreadingFactor = SX127X_SF_8; newSpreadingFactor = RADIOLIB_SX127X_SF_8;
break; break;
case 9: case 9:
newSpreadingFactor = SX127X_SF_9; newSpreadingFactor = RADIOLIB_SX127X_SF_9;
break; break;
default: default:
return(ERR_INVALID_SPREADING_FACTOR); return(RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
} }
// set spreading factor and if successful, save the new setting // set spreading factor and if successful, save the new setting
int16_t state = SX1278::setSpreadingFactorRaw(newSpreadingFactor); int16_t state = SX1278::setSpreadingFactorRaw(newSpreadingFactor);
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
SX127x::_sf = sf; SX127x::_sf = sf;
} }
return(state); return(state);