[SX1278] New getInstRSSI to get current RSSI

pull/711/head
G4lile0 2023-03-24 20:30:06 +01:00
rodzic 9dae818033
commit 04e24ab9d1
2 zmienionych plików z 42 dodań i 0 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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.