diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index a59572e4..9316eae2 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1020,6 +1020,21 @@ int16_t SX128x::setAccessAddress(uint32_t addr) { return(SX128x::writeRegister(RADIOLIB_SX128X_REG_ACCESS_ADDRESS_BYTE_3, addrBuff, 4)); } +int16_t SX128x::setHighSensitivityMode(bool hsm) { + // update register + uint8_t RxGain = 0; + int16_t state = readRegister(RADIOLIB_SX128X_REG_GAIN_MODE, &RxGain, 1); + RADIOLIB_ASSERT(state); + if (hsm) { + RxGain |= 0xC0; // Set bits 6 and 7 + } else { + RxGain &= ~0xC0; // Unset bits 6 and 7 + } + state = writeRegister(RADIOLIB_SX128X_REG_GAIN_MODE, &RxGain, 1); + RADIOLIB_ASSERT(state); + return(0); +} + float SX128x::getRSSI() { // get packet status uint8_t packetStatus[5]; diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index cf358c74..5c18d6d1 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -713,6 +713,15 @@ class SX128x: public PhysicalLayer { */ int16_t setAccessAddress(uint32_t addr); +/*! + \brief Enables or disables receiver high sensitivity mode. + + \param True to enable and false to disable. + + \returns 0 +*/ + int16_t setHighSensitivityMode(bool hsm = false); + /*! \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.