From 8a536bcc90b96d6c0c1421de08c7a64f881178e9 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 19 Jan 2017 18:03:36 +0100 Subject: [PATCH] Added getModemConfig --- RH_RF95.cpp | 13 +++++++++++++ RH_RF95.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/RH_RF95.cpp b/RH_RF95.cpp index 2ec8fe7..8beda8f 100644 --- a/RH_RF95.cpp +++ b/RH_RF95.cpp @@ -472,6 +472,19 @@ bool RH_RF95::setModemConfig(ModemConfigChoice index) return true; } +// Return the Modem configs +bool RH_RF95::getModemConfig(ModemConfigChoice index, ModemConfig* config) +{ + if (index > (signed int)(sizeof(MODEM_CONFIG_TABLE) / sizeof(ModemConfig))) + return false; + + memcpy_P(config, &MODEM_CONFIG_TABLE[index], sizeof(RH_RF95::ModemConfig)); + + return true; +} + + + void RH_RF95::setPreambleLength(uint16_t bytes) { spiWrite(RH_RF95_REG_20_PREAMBLE_MSB, bytes >> 8); diff --git a/RH_RF95.h b/RH_RF95.h index 07cc39a..acb99dc 100644 --- a/RH_RF95.h +++ b/RH_RF95.h @@ -602,6 +602,13 @@ class RH_RF95 : public RHSPIDriver /// \return true if index is a valid choice. bool setModemConfig(ModemConfigChoice index); + /// Get the values of one of the predefined modem configurations. + /// + /// \param[in] index The configuration choice. + /// \param[in] config A ModemConfig structure that will contains values of the modem configuration values. + /// \return true if index is a valid choice and config has been filled with values + bool getModemConfig(ModemConfigChoice index, ModemConfig* config); + /// Tests whether a new message is available /// from the Driver. /// On most drivers, this will also put the Driver into RHModeRx mode until