diff --git a/src/TypeDef.h b/src/TypeDef.h index 0ac5d2ef..49a29f78 100644 --- a/src/TypeDef.h +++ b/src/TypeDef.h @@ -213,6 +213,11 @@ */ #define RADIOLIB_ERR_INVALID_DIO_PIN (-26) +/*! + \brief The supplied RSSI threshold is invalid. +*/ +#define RADIOLIB_ERR_INVALID_RSSI_THRESHOLD (-27) + // RF69-specific status codes /*! diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 9fc69ef2..db39ff70 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -872,6 +872,13 @@ float RF69::getRSSI() { return(-1.0 * (_mod->SPIgetRegValue(RADIOLIB_RF69_REG_RSSI_VALUE)/2.0)); } +int16_t RF69::setRSSIThreshold(float value) { + if (value < 127.5 || value > 0) + return RADIOLIB_ERR_INVALID_RSSI_THRESHOLD; + + return _mod->SPIsetRegValue(RADIOLIB_RF69_REG_RSSI_THRESH, (uint8_t)(-2.0 * value), 7, 0); +} + void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { _mod->setRfSwitchPins(rxEn, txEn); } diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index ef9969e2..cb81cc4e 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -961,6 +961,15 @@ class RF69: public PhysicalLayer { */ float getRSSI(); + /*! + \brief Sets the RSSI value above which the RSSI interrupt is signaled + + \param value A value between -127.5 and 0 inclusive + + \returns \ref status_codes + */ + int16_t setRSSIThreshold(float value); + /*! \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch!