Use the RADIOLIB_CHECK_RANGE macro along with proper lower value (it has to be negative)

This commit is contained in:
obones 2022-08-25 10:39:21 +02:00
parent a7b42b61b2
commit 40599baef1
2 changed files with 2 additions and 4 deletions

View file

@ -873,8 +873,7 @@ float RF69::getRSSI() {
}
int16_t RF69::setRSSIThreshold(float dbm) {
if (dbm < 127.5 || dbm > 0)
return RADIOLIB_ERR_INVALID_RSSI_THRESHOLD;
RADIOLIB_CHECK_RANGE(dbm, -127.5, 0, RADIOLIB_ERR_INVALID_RSSI_THRESHOLD);
return _mod->SPIsetRegValue(RADIOLIB_RF69_REG_RSSI_THRESH, (uint8_t)(-2.0 * dbm), 7, 0);
}

View file

@ -1185,8 +1185,7 @@ int16_t SX127x::setCrcFiltering(bool crcOn) {
}
int16_t SX127x::setRSSIThreshold(float dbm) {
if (dbm < 127.5 || dbm > 0)
return RADIOLIB_ERR_INVALID_RSSI_THRESHOLD;
RADIOLIB_CHECK_RANGE(dbm, -127.5, 0, RADIOLIB_ERR_INVALID_RSSI_THRESHOLD);
return _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_RSSI_THRESH, (uint8_t)(-2.0 * dbm), 7, 0);
}