From f4fac4c09ef5f278f51ff928e33e5c370f363605 Mon Sep 17 00:00:00 2001 From: Christophe Painchaud Date: Wed, 17 Mar 2021 00:56:25 +0100 Subject: [PATCH] SX127x::setOokFixedOrFloorThreshold --- src/modules/SX127x/SX127x.cpp | 15 ++++++++++++++- src/modules/SX127x/SX127x.h | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index dc150637..ef495e67 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -844,10 +844,23 @@ int16_t SX127x::setOokThresholdType(uint8_t type) { int16_t state = ERR_NONE; state = _mod->SPIsetRegValue(SX127X_REG_OOK_PEAK, type, 4, 3, 5); - + return(state); } +int16_t SX127x::setOokFixedOrFloorThreshold(short int value) { + // check active modem + if(getActiveModem() != SX127X_FSK_OOK) { + return(ERR_WRONG_MODEM); + } + + int16_t state = ERR_NONE; + state = _mod->SPIsetRegValue(SX127X_REG_OOK_FIX, value, 7, 0, 5); + + return(state); +} + + int16_t SX127x::setOOK(bool enableOOK) { // check active modem diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 49170d51..94a1bbcf 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -868,6 +868,15 @@ class SX127x: public PhysicalLayer { */ int16_t setOokThresholdType(uint8_t type); + /*! + \brief Fixed threshold for the Data Slicer in OOK mode + Floor threshold for the Data Slicer in OOK when Peak mode is used + + \param value (in DB) + + \returns \ref status_codes + */ + int16_t setOokFixedOrFloorThreshold(short int value); /*! \brief Query modem for the packet length of received payload.