[SX1278] New getInstRSSI to get current RSSI

This commit is contained in:
G4lile0 2023-03-24 20:30:06 +01:00
parent 9dae818033
commit 04e24ab9d1
2 changed files with 42 additions and 0 deletions

View file

@ -421,6 +421,39 @@ float SX1278::getRSSI(bool skipReceive) {
}
}
float SX1278::getInstRSSI(bool skipReceive) {
if(getActiveModem() == RADIOLIB_SX127X_LORA) {
// for LoRa, get current RSSI
float currentRSSI;
// RSSI calculation uses different constant for low-frequency and high-frequency ports
if(_freq < 868.0) {
currentRSSI = -164 + _mod->SPIgetRegValue(RADIOLIB_SX127X_REG_RSSI_VALUE);
} else {
currentRSSI = -157 + _mod->SPIgetRegValue(RADIOLIB_SX127X_REG_RSSI_VALUE);
}
return(currentRSSI);
} else {
// enable listen mode
if(!skipReceive) {
startReceive();
}
// read the value for FSK
float rssi = (float)_mod->SPIgetRegValue(RADIOLIB_SX127X_REG_RSSI_VALUE_FSK) / -2.0;
// set mode back to standby
if(!skipReceive) {
standby();
}
// return the value
return(rssi);
}
}
int16_t SX1278::setCRC(bool enable, bool mode) {
if(getActiveModem() == RADIOLIB_SX127X_LORA) {
// set LoRa CRC

View file

@ -257,6 +257,15 @@ class SX1278: public SX127x {
*/
float getRSSI(bool skipReceive = false);
/*!
\brief Gets current signal strength indicator of for LoRa modem, or current RSSI level for FSK modem.
\param skipReceive Set to true to skip putting radio in receive mode for the RSSI measurement in FKS/OOK mode.
\returns Current packet RSSI for LoRa modem, or FSK modem.
*/
float getInstRSSI(bool skipReceive = false);
/*!
\brief Enables/disables CRC check of received packets.