diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index e0407eba..bc188f43 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -711,12 +711,25 @@ int16_t CC1101::setOOK(bool enableOOK) { return(setOutputPower(_power)); } -float CC1101::getRSSI() const { +float CC1101::getRSSI() { float rssi; - if(_rawRSSI >= 128) { - rssi = (((float)_rawRSSI - 256.0)/2.0) - 74.0; + + if (_directMode) { + if(_rawRSSI >= 128) { + rssi = (((float)_rawRSSI - 256.0)/2.0) - 74.0; + } else { + rssi = (((float)_rawRSSI)/2.0) - 74.0; + } } else { - rssi = (((float)_rawRSSI)/2.0) - 74.0; + uint8_t rawRssi = SPIreadRegister(RADIOLIB_CC1101_REG_RSSI); + if (rawRssi >= 128) + { + rssi = ((rawRssi - 256) / 2) - 74; + } + else + { + rssi = (rawRssi / 2) - 74; + } } return(rssi); } @@ -914,6 +927,7 @@ int16_t CC1101::directMode(bool sync) { SPIsendCommand(RADIOLIB_CC1101_CMD_IDLE); int16_t state = 0; + _directMode = sync; if (sync) { // set GDO0 and GDO2 mapping state |= SPIsetRegValue(RADIOLIB_CC1101_REG_IOCFG0, RADIOLIB_CC1101_GDOX_SERIAL_CLOCK , 5, 0); diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index e88d48e3..fd8cb621 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -791,9 +791,11 @@ class CC1101: public PhysicalLayer { /*! \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. - \returns Last packet RSSI in dBm. + or in asynchronous direct mode the current RSSI level + + \returns RSSI in dBm. */ - float getRSSI() const; + float getRSSI(); /*! \brief Gets LQI (Link Quality Indicator) of the last received packet. @@ -974,6 +976,7 @@ class CC1101: public PhysicalLayer { bool _promiscuous = false; bool _crcOn = true; + bool _directMode = true; uint8_t _syncWordLength = 2; int8_t _power = 0; diff --git a/src/modules/SX127x/SX1278.cpp b/src/modules/SX127x/SX1278.cpp index 685fe175..7d6d57aa 100644 --- a/src/modules/SX127x/SX1278.cpp +++ b/src/modules/SX127x/SX1278.cpp @@ -297,7 +297,7 @@ int16_t SX1278::setGain(uint8_t gain) { // gain set to 0, enable AGC loop state |= _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_RX_CONFIG, RADIOLIB_SX127X_AGC_AUTO_ON, 3, 3); } else { - state |= _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_RX_CONFIG, RADIOLIB_SX127X_AGC_AUTO_ON, 3, 3); + state |= _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_RX_CONFIG, RADIOLIB_SX1278_AGC_AUTO_OFF, 3, 3); state |= _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_LNA, (gain << 5) | RADIOLIB_SX127X_LNA_BOOST_ON); } diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 6f8dfdbb..31396428 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -827,7 +827,7 @@ int16_t SX127x::setBitRate(float br) { // check allowed bit rate if(_ook) { - RADIOLIB_CHECK_RANGE(br, 1.2, 32.768, RADIOLIB_ERR_INVALID_BIT_RATE); + RADIOLIB_CHECK_RANGE(br, 1.2, 32.768002, RADIOLIB_ERR_INVALID_BIT_RATE); // Found that 32.768 is 32.768002 } else { RADIOLIB_CHECK_RANGE(br, 1.2, 300.0, RADIOLIB_ERR_INVALID_BIT_RATE); }