From 3c6ad9802c54795154c379eacca612d607243b49 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Tue, 7 Dec 2021 10:02:19 +0100 Subject: [PATCH] Added API function allowing to query the current status of the RX audio squelch --- openrtx/include/rtx/OpMode.h | 10 ++++++++++ openrtx/include/rtx/OpMode_FM.h | 7 +++++++ openrtx/include/rtx/OpMode_M17.h | 10 ++++++++++ openrtx/include/rtx/rtx.h | 7 +++++++ openrtx/src/rtx/OpMode_FM.cpp | 5 +++++ openrtx/src/rtx/rtx.cpp | 5 +++++ 6 files changed, 44 insertions(+) diff --git a/openrtx/include/rtx/OpMode.h b/openrtx/include/rtx/OpMode.h index 9565b766..f01e33c3 100644 --- a/openrtx/include/rtx/OpMode.h +++ b/openrtx/include/rtx/OpMode.h @@ -88,6 +88,16 @@ public: { return NONE; } + + /** + * Check if RX squelch is open. + * + * @return true if RX squelch is open. + */ + virtual bool rxSquelchOpen() + { + return false; + } }; #endif /* OPMODE_H */ diff --git a/openrtx/include/rtx/OpMode_FM.h b/openrtx/include/rtx/OpMode_FM.h index e3774d3f..400559d9 100644 --- a/openrtx/include/rtx/OpMode_FM.h +++ b/openrtx/include/rtx/OpMode_FM.h @@ -81,6 +81,13 @@ public: return FM; } + /** + * Check if RX squelch is open. + * + * @return true if RX squelch is open. + */ + virtual bool rxSquelchOpen() override; + private: bool rfSqlOpen; ///< Flag for RF squelch status (analog squelch). diff --git a/openrtx/include/rtx/OpMode_M17.h b/openrtx/include/rtx/OpMode_M17.h index 21339400..16e21249 100644 --- a/openrtx/include/rtx/OpMode_M17.h +++ b/openrtx/include/rtx/OpMode_M17.h @@ -83,6 +83,16 @@ public: return M17; } + /** + * Check if RX squelch is open. + * + * @return true if RX squelch is open. + */ + virtual bool rxSquelchOpen() override + { + return false; + } + private: /** diff --git a/openrtx/include/rtx/rtx.h b/openrtx/include/rtx/rtx.h index 69371be4..3e02353a 100644 --- a/openrtx/include/rtx/rtx.h +++ b/openrtx/include/rtx/rtx.h @@ -131,6 +131,13 @@ void rtx_taskFunc(); */ float rtx_getRssi(); +/** + * Get current status of the RX squelch. This function is thread-safe and can + * be called also from threads other than the one running the RTX task. + * @return true if RX squelch is open. + */ +bool rtx_rxSquelchOpen(); + #ifdef __cplusplus } #endif diff --git a/openrtx/src/rtx/OpMode_FM.cpp b/openrtx/src/rtx/OpMode_FM.cpp index ab338ad4..cefe3a43 100644 --- a/openrtx/src/rtx/OpMode_FM.cpp +++ b/openrtx/src/rtx/OpMode_FM.cpp @@ -194,3 +194,8 @@ void OpMode_FM::update(rtxStatus_t *const status, const bool newCfg) // Sleep thread for 30ms for 33Hz update rate sleepFor(0u, 30u); } + +bool OpMode_FM::rxSquelchOpen() +{ + return sqlOpen; +} diff --git a/openrtx/src/rtx/rtx.cpp b/openrtx/src/rtx/rtx.cpp index 155fe170..b1664bdf 100644 --- a/openrtx/src/rtx/rtx.cpp +++ b/openrtx/src/rtx/rtx.cpp @@ -207,3 +207,8 @@ float rtx_getRssi() { return rssi; } + +bool rtx_rxSquelchOpen() +{ + return currMode->rxSquelchOpen(); +}