From ab9cf0d52839bf28bd1108cd3efc9ae367ac05e4 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 27 Mar 2023 23:21:37 +0200 Subject: [PATCH] [SX126x] Unified getRSSI interface --- src/modules/SX126x/SX126x.cpp | 18 ++++-------------- src/modules/SX126x/SX126x.h | 13 +++---------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 4ffbc9e0..ea01e088 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1222,20 +1222,17 @@ float SX126x::getDataRate() const { } float SX126x::getRSSI(bool packet) { - - if (packet) { - // get last packet RSSI from packet status + if(packet) { + // get last packet RSSI from packet status uint32_t packetStatus = getPacketStatus(); uint8_t rssiPkt = packetStatus & 0xFF; return(-1.0 * rssiPkt/2.0); } else { - // get instantaneous RSSI value + // get instantaneous RSSI value uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU _mod->SPIreadStream(RADIOLIB_SX126X_CMD_GET_RSSI_INST, data, 3); - - return (float)data[0] / (-2.0); + return((float)data[0] / (-2.0)); } - } float SX126x::getSNR() { @@ -1337,13 +1334,6 @@ uint32_t SX126x::getTimeOnAir(size_t len) { } } -float SX126x::getRSSIInst() { - uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU - _mod->SPIreadStream(RADIOLIB_SX126X_CMD_GET_RSSI_INST, data, 3); - - return (float)data[0] / (-2.0); -} - int16_t SX126x::implicitHeader(size_t len) { return(setHeaderType(RADIOLIB_SX126X_LORA_HEADER_IMPLICIT, len)); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 6634ddf7..deb437af 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -915,11 +915,11 @@ class SX126x: public PhysicalLayer { float getDataRate() const; /*! - \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. + \brief GetsRSSI (Recorded Signal Strength Indicator). - \param packet Set to false to gets current RSSI measurement in LoRa mode. + \param packet Whether to read last packet RSSI, or the current value. - \returns RSSI of the last received packet in dBm. + \returns RSSI value in dBm. */ float getRSSI(bool packet = true); @@ -975,13 +975,6 @@ class SX126x: public PhysicalLayer { */ uint32_t getTimeOnAir(size_t len); - /*! - \brief Get instantaneous RSSI value during recption of the packet. Should switch to FSK receive mode for LBT implementation. - - \returns Instantaneous RSSI value in dBm, in steps of 0.5dBm - */ - float getRSSIInst(); - /*! \brief Set implicit header mode for future reception/transmission.