From 0b835f9fcf1af1d8eab55605cb0bd94d5a221ae5 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 14:27:23 +0900 Subject: [PATCH 1/4] Added getRSSIInst command for SX126x --- src/modules/SX126x/SX126x.cpp | 7 +++++++ src/modules/SX126x/SX126x.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 63b5ebc8..db491cdf 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1130,6 +1130,13 @@ uint32_t SX126x::getTimeOnAir(size_t len) { } } +uint8_t SX126x::getRSSIInst() { + uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU + SPIreadCommand(SX126X_CMD_GET_RSSI_INST, data, 3); + + return data[0]; +} + int16_t SX126x::implicitHeader(size_t len) { return(setHeaderType(SX126X_LORA_HEADER_IMPLICIT, len)); } diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 46b510f8..b0c50b79 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -806,6 +806,13 @@ class SX126x: public PhysicalLayer { */ uint32_t getTimeOnAir(size_t len); + /*! + \brief Get instantaneous RSSI value in FSK mode. Can be used for LBT implementation, checking for interference before transmitting. + + \returns Instantaneous RSSI value in (-2)*dBm + */ + uint8_t getRSSIInst(); + /*! \brief Set implicit header mode for future reception/transmission. From 318ac691d01d7ac7d74c022a9f8b5fd001fdcaa2 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 14:59:32 +0900 Subject: [PATCH 2/4] comments --- src/modules/SX126x/SX126x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index b0c50b79..16a955a5 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -807,9 +807,9 @@ class SX126x: public PhysicalLayer { uint32_t getTimeOnAir(size_t len); /*! - \brief Get instantaneous RSSI value in FSK mode. Can be used for LBT implementation, checking for interference before transmitting. + \brief Get instantaneous RSSI value during recption of the packet. Should switch to FSK receive mode for LBT implementation. - \returns Instantaneous RSSI value in (-2)*dBm + \returns Instantaneous RSSI value in (-2)*dBm. */ uint8_t getRSSIInst(); From d6330cfe443cefa67899065bb1b803b629e07300 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 16:51:05 +0900 Subject: [PATCH 3/4] Convert arbitrary unit to dBm --- src/modules/SX126x/SX126x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index db491cdf..cbe356fb 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1130,11 +1130,11 @@ uint32_t SX126x::getTimeOnAir(size_t len) { } } -uint8_t SX126x::getRSSIInst() { +float SX126x::getRSSIInst() { uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU SPIreadCommand(SX126X_CMD_GET_RSSI_INST, data, 3); - return data[0]; + return (float)data[0] / (-2.0); } int16_t SX126x::implicitHeader(size_t len) { From 07cc802f9b0bc223450cc376b5d0d313a93d9230 Mon Sep 17 00:00:00 2001 From: Kihun Song Date: Thu, 4 Feb 2021 17:02:52 +0900 Subject: [PATCH 4/4] Convert arbitrary unit to dBm --- src/modules/SX126x/SX126x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 16a955a5..ee99a27f 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -809,9 +809,9 @@ class SX126x: public PhysicalLayer { /*! \brief Get instantaneous RSSI value during recption of the packet. Should switch to FSK receive mode for LBT implementation. - \returns Instantaneous RSSI value in (-2)*dBm. + \returns Instantaneous RSSI value in dBm, in steps of 0.5dBm */ - uint8_t getRSSIInst(); + float getRSSIInst(); /*! \brief Set implicit header mode for future reception/transmission.