[SX128x] Added get/set modem
This commit is contained in:
parent
301654ead4
commit
641a5b7985
2 changed files with 46 additions and 0 deletions
|
@ -856,6 +856,37 @@ int16_t SX128x::checkOutputPower(int8_t pwr, int8_t* clipped) {
|
||||||
return(RADIOLIB_ERR_NONE);
|
return(RADIOLIB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t SX128x::setModem(ModemType_t modem) {
|
||||||
|
switch(modem) {
|
||||||
|
case(ModemType_t::LoRa): {
|
||||||
|
return(this->begin());
|
||||||
|
} break;
|
||||||
|
case(ModemType_t::FSK): {
|
||||||
|
return(this->beginGFSK());
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
return(RADIOLIB_ERR_WRONG_MODEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t SX128x::getModem(ModemType_t* modem) {
|
||||||
|
if(!modem) {
|
||||||
|
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t packetType = getPacketType();
|
||||||
|
switch(packetType) {
|
||||||
|
case(RADIOLIB_SX128X_PACKET_TYPE_LORA):
|
||||||
|
*modem = ModemType_t::LoRa;
|
||||||
|
return(RADIOLIB_ERR_NONE);
|
||||||
|
case(RADIOLIB_SX128X_PACKET_TYPE_GFSK):
|
||||||
|
*modem = ModemType_t::FSK;
|
||||||
|
return(RADIOLIB_ERR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(RADIOLIB_ERR_WRONG_MODEM);
|
||||||
|
}
|
||||||
|
|
||||||
int16_t SX128x::setPreambleLength(uint32_t preambleLength) {
|
int16_t SX128x::setPreambleLength(uint32_t preambleLength) {
|
||||||
uint8_t modem = getPacketType();
|
uint8_t modem = getPacketType();
|
||||||
if((modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) || (modem == RADIOLIB_SX128X_PACKET_TYPE_RANGING)) {
|
if((modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) || (modem == RADIOLIB_SX128X_PACKET_TYPE_RANGING)) {
|
||||||
|
|
|
@ -672,6 +672,21 @@ class SX128x: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
int16_t checkOutputPower(int8_t pwr, int8_t* clipped) override;
|
int16_t checkOutputPower(int8_t pwr, int8_t* clipped) 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, LoRa or LR-FHSS.
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t setModem(ModemType_t modem) 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;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets preamble length for currently active modem. Allowed values range from 1 to 65535.
|
\brief Sets preamble length for currently active modem. Allowed values range from 1 to 65535.
|
||||||
\param preambleLength Preamble length to be set in symbols (LoRa) or bits (FSK/BLE/FLRC).
|
\param preambleLength Preamble length to be set in symbols (LoRa) or bits (FSK/BLE/FLRC).
|
||||||
|
|
Loading…
Add table
Reference in a new issue