Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/LoRa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ int LoRaClass::packetRssi()
return (readRegister(REG_PKT_RSSI_VALUE) - (_frequency < RF_MID_BAND_THRESHOLD ? RSSI_OFFSET_LF_PORT : RSSI_OFFSET_HF_PORT));
}

#if !defined(ESP32)
float LoRaClass::packetSnr()
#else
double LoRaClass::packetSnr()
#endif
{
return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25;
}
Expand All @@ -284,8 +288,13 @@ long LoRaClass::packetFrequencyError()
freqError -= 524288; // B1000'0000'0000'0000'0000
}

#if !defined(ESP32)
const float fXtal = 32E6; // FXOSC: crystal oscillator (XTAL) frequency (2.5. Chip Specification, p. 14)
const float fError = ((static_cast<float>(freqError) * (1L << 24)) / fXtal) * (getSignalBandwidth() / 500000.0f); // p. 37
#else
const double fXtal = 32E6; // FXOSC: crystal oscillator (XTAL) frequency (2.5. Chip Specification, p. 14)
const double fError = ((static_cast<double>(freqError) * (1L << 24)) / fXtal) * (getSignalBandwidth() / 500000.0); // p. 37
#endif

return static_cast<long>(fError);
}
Expand Down
4 changes: 4 additions & 0 deletions src/LoRa.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class LoRaClass : public Stream {

int parsePacket(int size = 0);
int packetRssi();
#if !defined(ESP32)
float packetSnr();
#else
double packetSnr();
#endif
long packetFrequencyError();

int rssi();
Expand Down