Introduce setRSSIThreshold on RF69 modules

This commit is contained in:
OBones 2022-08-23 17:41:37 +02:00
parent bedbf7bb94
commit fd3b165bf0
3 changed files with 21 additions and 0 deletions

View file

@ -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
/*!

View file

@ -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);
}

View file

@ -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!