From 2c826fb3dc23b1b7911e0cf12af45c6df3c6c194 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 29 Oct 2022 00:52:51 +0200 Subject: [PATCH] Added continual RSSI monitoring for tuned channel --- LoRa.cpp | 13 +++++++++++++ LoRa.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/LoRa.cpp b/LoRa.cpp index 1268516..ca28ab4 100644 --- a/LoRa.cpp +++ b/LoRa.cpp @@ -49,6 +49,7 @@ #define REG_MODEM_STAT 0x18 #define REG_PKT_SNR_VALUE 0x19 #define REG_PKT_RSSI_VALUE 0x1a +#define REG_RSSI_VALUE 0x1b #define REG_MODEM_CONFIG_1 0x1d #define REG_MODEM_CONFIG_2 0x1e #define REG_PREAMBLE_MSB 0x20 @@ -239,6 +240,18 @@ uint8_t LoRaClass::modemStatus() { return readRegister(REG_MODEM_STAT); } + +uint8_t LoRaClass::currentRssiRaw() { + uint8_t rssi = readRegister(REG_RSSI_VALUE); + return rssi; +} + +int ISR_VECT LoRaClass::currentRssi() { + int rssi = (int)readRegister(REG_RSSI_VALUE) - RSSI_OFFSET; + if (_frequency < 820E6) rssi -= 7; + return rssi; +} + uint8_t LoRaClass::packetRssiRaw() { uint8_t pkt_rssi_value = readRegister(REG_PKT_RSSI_VALUE); return pkt_rssi_value; diff --git a/LoRa.h b/LoRa.h index 09bdc54..02a48c9 100644 --- a/LoRa.h +++ b/LoRa.h @@ -31,7 +31,9 @@ public: int parsePacket(int size = 0); int packetRssi(); + int currentRssi(); uint8_t packetRssiRaw(); + uint8_t currentRssiRaw(); uint8_t packetSnrRaw(); float packetSnr(); long packetFrequencyError();