From 29b8164cad0bdcba0820f356ccbf6e43fdca64d9 Mon Sep 17 00:00:00 2001 From: ZacJW Date: Sat, 12 Mar 2022 19:13:05 +0000 Subject: [PATCH 1/2] Added packetSnrRaw method that doesn't use float Some microcontrollers cannot use their floating-point coprocessor during interrupts (e.g. ESP32) which means they can't use the packetSnr method. packetSnrRaw allows the user to forgo the `* 0.25` in such cases --- src/LoRa.cpp | 7 ++++++- src/LoRa.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/LoRa.cpp b/src/LoRa.cpp index 210a589..04be069 100644 --- a/src/LoRa.cpp +++ b/src/LoRa.cpp @@ -268,7 +268,12 @@ int LoRaClass::packetRssi() float LoRaClass::packetSnr() { - return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25; + return packetSnrRaw() * 0.25; +} + +int LoRaClass::packetSnrRaw() +{ + return ((int8_t)readRegister(REG_PKT_SNR_VALUE)); } long LoRaClass::packetFrequencyError() diff --git a/src/LoRa.h b/src/LoRa.h index b312db5..20e4cbf 100644 --- a/src/LoRa.h +++ b/src/LoRa.h @@ -43,6 +43,7 @@ class LoRaClass : public Stream { int parsePacket(int size = 0); int packetRssi(); float packetSnr(); + int packetSnrRaw(); long packetFrequencyError(); int rssi(); From 38e60b90faf9293955890bdacef9cdcc79a95621 Mon Sep 17 00:00:00 2001 From: ZacJW Date: Sat, 12 Mar 2022 19:18:21 +0000 Subject: [PATCH 2/2] Added documentation for packetSnrRaw --- API.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/API.md b/API.md index db1cf1c..2d8cad8 100644 --- a/API.md +++ b/API.md @@ -204,6 +204,14 @@ float snr = LoRa.packetSnr(); Returns the estimated SNR of the received packet in dB. +### Packet SNR Raw + +```arduino +int snrRaw = LoRa.packetSnrRaw(); +``` + +Like [`LoRa.packetSnr()`](#packet-snr) except it returns an `int` that is 4 times the SNR of the received packet in dB. + ## RSSI ```arduino