[SX127x] Added get/set modem

This commit is contained in:
jgromes 2024-10-26 14:00:48 +01:00
parent f64cf1b986
commit 301654ead4
14 changed files with 151 additions and 0 deletions

View file

@ -585,4 +585,17 @@ void SX1272::errataFix(bool rx) {
mod->SPIsetRegValue(0x31, 0b10000000, 7, 7); mod->SPIsetRegValue(0x31, 0b10000000, 7, 7);
} }
int16_t SX1272::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}
#endif #endif

View file

@ -301,6 +301,14 @@ class SX1272: public SX127x {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t explicitHeader(); int16_t explicitHeader();
/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
protected: protected:

View file

@ -115,4 +115,17 @@ int16_t SX1273::checkDataRate(DataRate_t dr) {
return(state); return(state);
} }
int16_t SX1273::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}
#endif #endif

View file

@ -62,6 +62,14 @@ class SX1273: public SX1272 {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t checkDataRate(DataRate_t dr) override; int16_t checkDataRate(DataRate_t dr) override;
/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
private: private:

View file

@ -79,4 +79,17 @@ int16_t SX1276::setFrequency(float freq) {
return(state); return(state);
} }
int16_t SX1276::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}
#endif #endif

View file

@ -62,6 +62,14 @@ class SX1276: public SX1278 {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t setFrequency(float freq) override; int16_t setFrequency(float freq) override;
/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
private: private:

View file

@ -157,4 +157,17 @@ int16_t SX1277::checkDataRate(DataRate_t dr) {
return(state); return(state);
} }
int16_t SX1277::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}
#endif #endif

View file

@ -83,6 +83,14 @@ class SX1277: public SX1278 {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t checkDataRate(DataRate_t dr) override; int16_t checkDataRate(DataRate_t dr) override;
/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
private: private:

View file

@ -705,4 +705,17 @@ void SX1278::errataFix(bool rx) {
mod->SPIsetRegValue(0x30, fixedRegs[2]); mod->SPIsetRegValue(0x30, fixedRegs[2]);
} }
int16_t SX1278::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}
#endif #endif

View file

@ -313,6 +313,14 @@ class SX1278: public SX127x {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t explicitHeader(); int16_t explicitHeader();
/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
protected: protected:

View file

@ -79,4 +79,17 @@ int16_t SX1279::setFrequency(float freq) {
return(state); return(state);
} }
int16_t SX1279::setModem(ModemType_t modem) {
switch(modem) {
case(ModemType_t::LoRa): {
return(this->begin());
} break;
case(ModemType_t::FSK): {
return(this->beginFSK());
} break;
default:
return(RADIOLIB_ERR_WRONG_MODEM);
}
}
#endif #endif

View file

@ -62,6 +62,14 @@ class SX1279: public SX1278 {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t setFrequency(float freq) override; int16_t setFrequency(float freq) override;
/*!
\brief Set modem for the radio to use. Will perform full reset and reconfigure the radio
using its default parameters.
\param modem Modem type to set - FSK or LoRa.
\returns \ref status_codes
*/
int16_t setModem(ModemType_t modem) override;
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
private: private:

View file

@ -1754,6 +1754,24 @@ int16_t SX127x::invertIQ(bool enable) {
return(state); return(state);
} }
int16_t SX127x::getModem(ModemType_t* modem) {
if(!modem) {
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
}
int16_t packetType = getActiveModem();
switch(packetType) {
case(RADIOLIB_SX127X_LORA):
*modem = ModemType_t::LoRa;
return(RADIOLIB_ERR_NONE);
case(RADIOLIB_SX127X_FSK_OOK):
*modem = ModemType_t::FSK;
return(RADIOLIB_ERR_NONE);
}
return(RADIOLIB_ERR_WRONG_MODEM);
}
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
void SX127x::setDirectAction(void (*func)(void)) { void SX127x::setDirectAction(void (*func)(void)) {
setDio1Action(func, this->mod->hal->GpioInterruptRising); setDio1Action(func, this->mod->hal->GpioInterruptRising);

View file

@ -1149,6 +1149,13 @@ class SX127x: public PhysicalLayer {
*/ */
int16_t invertIQ(bool enable) override; int16_t invertIQ(bool enable) override;
/*!
\brief Get modem currently in use by the radio.
\param modem Pointer to a variable to save the retrieved configuration into.
\returns \ref status_codes
*/
int16_t getModem(ModemType_t* modem) override;
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
/*! /*!
\brief Set interrupt service routine function to call when data bit is received in direct mode. \brief Set interrupt service routine function to call when data bit is received in direct mode.