Merge pull request #561 from obones/setRSSIThreshold

Introduce the setRSSIThreshold method
pull/609/head
Jan Gromeš 2022-08-25 19:28:20 +02:00 zatwierdzone przez GitHub
commit 1bd9409bcf
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 35 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

@ -872,6 +872,12 @@ float RF69::getRSSI() {
return(-1.0 * (_mod->SPIgetRegValue(RADIOLIB_RF69_REG_RSSI_VALUE)/2.0));
}
int16_t RF69::setRSSIThreshold(float dbm) {
RADIOLIB_CHECK_RANGE(dbm, -127.5, 0, RADIOLIB_ERR_INVALID_RSSI_THRESHOLD);
return _mod->SPIsetRegValue(RADIOLIB_RF69_REG_RSSI_THRESH, (uint8_t)(-2.0 * dbm), 7, 0);
}
void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
_mod->setRfSwitchPins(rxEn, txEn);
}

Wyświetl plik

@ -961,6 +961,15 @@ class RF69: public PhysicalLayer {
*/
float getRSSI();
/*!
\brief Sets the RSSI value above which the RSSI interrupt is signaled
\param dbm A dBm value between -127.5 and 0 inclusive
\returns \ref status_codes
*/
int16_t setRSSIThreshold(float dbm);
/*!
\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!

Wyświetl plik

@ -1184,6 +1184,12 @@ int16_t SX127x::setCrcFiltering(bool crcOn) {
}
}
int16_t SX127x::setRSSIThreshold(float dbm) {
RADIOLIB_CHECK_RANGE(dbm, -127.5, 0, RADIOLIB_ERR_INVALID_RSSI_THRESHOLD);
return _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_RSSI_THRESH, (uint8_t)(-2.0 * dbm), 7, 0);
}
int16_t SX127x::setRSSIConfig(uint8_t smoothingSamples, int8_t offset) {
// check active modem
if(getActiveModem() != RADIOLIB_SX127X_FSK_OOK) {

Wyświetl plik

@ -1227,6 +1227,15 @@ class SX127x: public PhysicalLayer {
*/
int16_t setDIOPreambleDetect(bool usePreambleDetect);
/*!
\brief Sets the RSSI value above which the RSSI interrupt is signaled
\param dbm A dBm value between -127.5 and 0 inclusive
\returns \ref status_codes
*/
int16_t setRSSIThreshold(float dbm);
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
protected:
#endif