From 3e1088f34ad9c4b1ee6c742910d89d009fcd479f Mon Sep 17 00:00:00 2001 From: Christophe Painchaud Date: Thu, 25 Mar 2021 13:39:44 +0100 Subject: [PATCH] styles and syntax changes --- keywords.txt | 4 ++++ src/modules/RF69/RF69.cpp | 7 ++++--- src/modules/SX127x/SX1272.cpp | 2 +- src/modules/SX127x/SX1272.h | 4 +++- src/modules/SX127x/SX1278.cpp | 7 +------ src/modules/SX127x/SX1278.h | 2 +- src/modules/SX127x/SX127x.cpp | 4 ++-- src/modules/SX127x/SX127x.h | 4 ++-- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/keywords.txt b/keywords.txt index fd9d2268..34f66d67 100644 --- a/keywords.txt +++ b/keywords.txt @@ -132,6 +132,9 @@ forceLDRO KEYWORD2 autoLDRO KEYWORD2 getChipVersion KEYWORD2 invertIQ KEYWORD2 +setOokThresholdType KEYWORD2 +setOokPeakThresholdDecrement KEYWORD2 +setOokFixedOrFloorThreshold KEYWORD2 # RF69-specific setAESKey KEYWORD2 @@ -139,6 +142,7 @@ enableAES KEYWORD2 disableAES KEYWORD2 getTemperature KEYWORD2 setAmbientTemperature KEYWORD2 +setLnaTestBoost KEYWORD2 # CC1101-specific getLQI KEYWORD2 diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 80d88f5e..4858380d 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -385,7 +385,7 @@ int16_t RF69::setOOK(bool enableOOK) { } int16_t RF69::setOokThresholdType(uint8_t type) { - if(type != RF69_OOK_THRESH_FIXED && type != RF69_OOK_THRESH_PEAK && RF69_OOK_THRESH_AVERAGE) + if(type != RF69_OOK_THRESH_FIXED && type != RF69_OOK_THRESH_PEAK && type != RF69_OOK_THRESH_AVERAGE) return ERR_INVALID_OOK_RSSI_PEAK_TYPE; int16_t state = ERR_NONE; @@ -788,8 +788,9 @@ int16_t RF69::setEncoding(uint8_t encoding) { } int16_t RF69::setLnaTestBoost(bool value) { - if(value) - return(_mod->SPIsetRegValue(RF69_REG_TEST_LNA, RF69_TEST_LNA_BOOST_HIGH, 7, 0)); + if(value) { + return (_mod->SPIsetRegValue(RF69_REG_TEST_LNA, RF69_TEST_LNA_BOOST_HIGH, 7, 0)); + } return(_mod->SPIsetRegValue(RF69_TEST_LNA_BOOST_NORMAL, RF69_TEST_LNA_BOOST_HIGH, 7, 0)); } diff --git a/src/modules/SX127x/SX1272.cpp b/src/modules/SX127x/SX1272.cpp index 183bbd85..755c39b4 100644 --- a/src/modules/SX127x/SX1272.cpp +++ b/src/modules/SX127x/SX1272.cpp @@ -330,7 +330,7 @@ int16_t SX1272::setDataShapingOOK(uint8_t sh) { return(state); } -float SX1272::getRSSI() { +float SX1272::getRSSI(bool skip_activation) { if(getActiveModem() == SX127X_LORA) { // RSSI calculation uses different constant for low-frequency and high-frequency ports float lastPacketRSSI = -139 + _mod->SPIgetRegValue(SX127X_REG_PKT_RSSI_VALUE); diff --git a/src/modules/SX127x/SX1272.h b/src/modules/SX127x/SX1272.h index 81b84cab..6ec58071 100644 --- a/src/modules/SX127x/SX1272.h +++ b/src/modules/SX127x/SX1272.h @@ -240,9 +240,11 @@ class SX1272: public SX127x { /*! \brief Gets recorded signal strength indicator of the latest received packet for LoRa modem, or current RSSI level for FSK modem. + \param skip_activation in OOK/FSK mode this function will put receiver in receive mode and then in standby. Make it TRUE if you don't want this behaviour. + \returns Last packet RSSI for LoRa modem, or current RSSI level for FSK modem. */ - float getRSSI(); + float getRSSI(bool skip_activation = false); /*! \brief Enables/disables CRC check of received packets. diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 6ff917bc..3e708bb3 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -315,12 +315,7 @@ int16_t SX1278::setOutputPower(int8_t power) { } int16_t SX1278::setGain(uint8_t gain) { - int16_t modem = getActiveModem(); - - // check active modem - if(modem != SX127X_LORA && modem != SX127X_FSK_OOK) { - return(ERR_WRONG_MODEM); - } + int16_t modem = getActiveModem(); // check allowed range if(gain > 6) { diff --git a/src/modules/SX127x/SX1278.h b/src/modules/SX127x/SX1278.h index 5be83794..40bcab66 100644 --- a/src/modules/SX127x/SX1278.h +++ b/src/modules/SX127x/SX1278.h @@ -248,7 +248,7 @@ class SX1278: public SX127x { /*! \brief Gets recorded signal strength indicator of the latest received packet for LoRa modem, or current RSSI level for FSK modem. - \param skip_activation in OOK/FSK mode this function will put receiver un receive mode and in standby. Make it TRUE if you don't want this behaviour. + \param skip_activation in OOK/FSK mode this function will put receiver in receive mode and then in standby. Make it TRUE if you don't want this behaviour. \returns Last packet RSSI for LoRa modem, or current RSSI level for FSK modem. */ diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 21bc79e7..a9127da9 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -848,7 +848,7 @@ int16_t SX127x::setOokThresholdType(uint8_t type) { return(state); } -int16_t SX127x::setOokFixedOrFloorThreshold(short int value) { +int16_t SX127x::setOokFixedOrFloorThreshold(uint8_t value) { // check active modem if(getActiveModem() != SX127X_FSK_OOK) { return(ERR_WRONG_MODEM); @@ -860,7 +860,7 @@ int16_t SX127x::setOokFixedOrFloorThreshold(short int value) { return(state); } -int16_t SX127x::setOokPeakThresholdDecrement(short int value) { +int16_t SX127x::setOokPeakThresholdDecrement(uint8_t value) { // check active modem if(getActiveModem() != SX127X_FSK_OOK) { return(ERR_WRONG_MODEM); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index fb8f1503..c1d53f0f 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -875,7 +875,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setOokPeakThresholdDecrement(short int value); + int16_t setOokPeakThresholdDecrement(uint8_t value); /*! \brief Fixed threshold for the Data Slicer in OOK mode @@ -885,7 +885,7 @@ class SX127x: public PhysicalLayer { \returns \ref status_codes */ - int16_t setOokFixedOrFloorThreshold(short int value); + int16_t setOokFixedOrFloorThreshold(uint8_t value); /*! \brief Query modem for the packet length of received payload.