[SX126x] Implemented data rate check
This commit is contained in:
parent
a4b148d609
commit
a642f5a8df
2 changed files with 26 additions and 0 deletions
|
@ -980,6 +980,25 @@ int16_t SX126x::setDataRate(DataRate_t dr) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t SX126x::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.spreadingFactor, 5, 12, RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
|
||||
RADIOLIB_CHECK_RANGE(dr.lora.bandwidth, 0.0, 510.0, RADIOLIB_ERR_INVALID_BANDWIDTH);
|
||||
RADIOLIB_CHECK_RANGE(dr.lora.codingRate, 5, 8, RADIOLIB_ERR_INVALID_CODING_RATE);
|
||||
|
||||
}
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
||||
int16_t SX126x::setRxBandwidth(float rxBw) {
|
||||
// check active modem
|
||||
if(getPacketType() != RADIOLIB_SX126X_PACKET_TYPE_GFSK) {
|
||||
|
|
|
@ -778,6 +778,13 @@ class SX126x: public PhysicalLayer {
|
|||
*/
|
||||
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;
|
||||
|
||||
/*!
|
||||
\brief Sets FSK receiver bandwidth. Allowed values are 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5,
|
||||
23.4, 29.3, 39.0, 46.9, 58.6, 78.2, 93.8, 117.3, 156.2, 187.2, 234.3, 312.0, 373.6 and 467.0 kHz.
|
||||
|
|
Loading…
Add table
Reference in a new issue