[LLCC68] Fixed set data rate for LLCC68 (#946)
This commit is contained in:
parent
a642f5a8df
commit
f109fd0158
2 changed files with 75 additions and 0 deletions
|
@ -53,4 +53,65 @@ int16_t LLCC68::setSpreadingFactor(uint8_t sf) {
|
||||||
return(SX1262::setSpreadingFactor(sf));
|
return(SX1262::setSpreadingFactor(sf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t LLCC68::setDataRate(DataRate_t dr) {
|
||||||
|
int16_t state = RADIOLIB_ERR_UNKNOWN;
|
||||||
|
|
||||||
|
// select interpretation based on active modem
|
||||||
|
uint8_t modem = this->getPacketType();
|
||||||
|
if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
|
||||||
|
// set the bit rate
|
||||||
|
state = this->setBitRate(dr.fsk.bitRate);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// set the frequency deviation
|
||||||
|
state = this->setFrequencyDeviation(dr.fsk.freqDev);
|
||||||
|
|
||||||
|
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
|
||||||
|
// set the spreading factor
|
||||||
|
state = this->setSpreadingFactor(dr.lora.spreadingFactor);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// set the bandwidth
|
||||||
|
state = this->setBandwidth(dr.lora.bandwidth);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// set the coding rate
|
||||||
|
state = this->setCodingRate(dr.lora.codingRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t LLCC68::checkDataRate(DataRate_t dr) {
|
||||||
|
int16_t state = RADIOLIB_ERR_UNKNOWN;
|
||||||
|
|
||||||
|
// select interpretation based on active modem
|
||||||
|
uint8_t modem = this->getPacketType();
|
||||||
|
if(modem == RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.fsk.bitRate, 0.6, 300.0, RADIOLIB_ERR_INVALID_BIT_RATE);
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.fsk.freqDev, 0.6, 200.0, RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION);
|
||||||
|
|
||||||
|
} else if(modem == RADIOLIB_SX126X_PACKET_TYPE_LORA) {
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.lora.bandwidth, 100.0, 510.0, RADIOLIB_ERR_INVALID_BANDWIDTH);
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.lora.codingRate, 5, 8, RADIOLIB_ERR_INVALID_CODING_RATE);
|
||||||
|
uint8_t bw_div2 = dr.lora.bandwidth / 2 + 0.01;
|
||||||
|
switch (bw_div2) {
|
||||||
|
case 62: // 125.0:
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.lora.spreadingFactor, 5, 9, RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
|
||||||
|
break;
|
||||||
|
case 125: // 250.0
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.lora.spreadingFactor, 5, 10, RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
|
||||||
|
break;
|
||||||
|
case 250: // 500.0
|
||||||
|
RADIOLIB_CHECK_RANGE(dr.lora.spreadingFactor, 5, 11, RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return(RADIOLIB_ERR_INVALID_BANDWIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,6 +56,20 @@ class LLCC68: public SX1262 {
|
||||||
*/
|
*/
|
||||||
int16_t setSpreadingFactor(uint8_t sf);
|
int16_t setSpreadingFactor(uint8_t sf);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Set data.
|
||||||
|
\param dr Data rate struct. Interpretation depends on currently active modem (FSK or LoRa).
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t setDataRate(DataRate_t dr) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Check the data rate can be configured by this module.
|
||||||
|
\param dr Data rate struct. Interpretation depends on currently active modem (FSK or LoRa).
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t checkDataRate(DataRate_t dr) override;
|
||||||
|
|
||||||
#if !RADIOLIB_GODMODE
|
#if !RADIOLIB_GODMODE
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue