From ce121c59da39884a9b89da105d1427b226806e6c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 12 May 2020 13:43:43 +0100 Subject: [PATCH] Add the low CTCSS threshold value. --- Conf.cpp | 18 +++++++++++---- Conf.h | 6 +++-- MMDVM.ini | 2 ++ MMDVMHost.cpp | 64 ++++++++++++++++++++++++++------------------------- Modem.cpp | 41 ++++++++++++++++++--------------- Modem.h | 5 ++-- Version.h | 2 +- 7 files changed, 79 insertions(+), 59 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 8c07bc6..fc0c4c0 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -193,7 +193,8 @@ m_fmAckLevel(80.0F), m_fmTimeout(180U), m_fmTimeoutLevel(80.0F), m_fmCTCSSFrequency(88.6F), -m_fmCTCSSThreshold(40U), +m_fmCTCSSHighThreshold(30U), +m_fmCTCSSLowThreshold(20U), m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), @@ -747,7 +748,11 @@ bool CConf::read() else if (::strcmp(key, "CTCSSFrequency") == 0) m_fmCTCSSFrequency = float(::atof(value)); else if (::strcmp(key, "CTCSSThreshold") == 0) - m_fmCTCSSThreshold = (unsigned int)::atoi(value); + m_fmCTCSSHighThreshold = m_fmCTCSSLowThreshold = (unsigned int)::atoi(value); + else if (::strcmp(key, "CTCSSHighThreshold") == 0) + m_fmCTCSSHighThreshold = (unsigned int)::atoi(value); + else if (::strcmp(key, "CTCSSLowThreshold") == 0) + m_fmCTCSSLowThreshold = (unsigned int)::atoi(value); else if (::strcmp(key, "CTCSSLevel") == 0) m_fmCTCSSLevel = float(::atof(value)); else if (::strcmp(key, "KerchunkTime") == 0) @@ -1606,9 +1611,14 @@ float CConf::getFMCTCSSFrequency() const return m_fmCTCSSFrequency; } -unsigned int CConf::getFMCTCSSThreshold() const +unsigned int CConf::getFMCTCSSHighThreshold() const { - return m_fmCTCSSThreshold; + return m_fmCTCSSHighThreshold; +} + +unsigned int CConf::getFMCTCSSLowThreshold() const +{ + return m_fmCTCSSLowThreshold; } float CConf::getFMCTCSSLevel() const diff --git a/Conf.h b/Conf.h index f5a40bd..51f7898 100644 --- a/Conf.h +++ b/Conf.h @@ -191,7 +191,8 @@ public: unsigned int getFMTimeout() const; float getFMTimeoutLevel() const; float getFMCTCSSFrequency() const; - unsigned int getFMCTCSSThreshold() const; + unsigned int getFMCTCSSHighThreshold() const; + unsigned int getFMCTCSSLowThreshold() const; float getFMCTCSSLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; @@ -458,7 +459,8 @@ private: unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCTCSSFrequency; - unsigned int m_fmCTCSSThreshold; + unsigned int m_fmCTCSSHighThreshold; + unsigned int m_fmCTCSSLowThreshold; float m_fmCTCSSLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/MMDVM.ini b/MMDVM.ini index 5e71a84..8a89cd5 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -162,6 +162,8 @@ AckLevel=50 TimeoutLevel=80 CTCSSFrequency=88.4 CTCSSThreshold=30 +# CTCSSHighThreshold=30 +# CTCSSLowThreshold=20 CTCSSLevel=20 KerchunkTime=0 HangTime=7 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 6b17c16..1c32ad6 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1209,35 +1209,36 @@ bool CMMDVMHost::createModem() m_modem->setYSFParams(lowDeviation, txHang); if (m_fmEnabled) { - std::string callsign = m_conf.getFMCallsign(); - unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); - unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); - unsigned int callsignTime = m_conf.getFMCallsignTime(); - unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); - float callsignHighLevel = m_conf.getFMCallsignHighLevel(); - float callsignLowLevel = m_conf.getFMCallsignLowLevel(); - bool callsignAtStart = m_conf.getFMCallsignAtStart(); - bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); - bool callsignAtLatch = m_conf.getFMCallsignAtLatch(); - std::string rfAck = m_conf.getFMRFAck(); - std::string extAck = m_conf.getFMExtAck(); - unsigned int ackSpeed = m_conf.getFMAckSpeed(); - unsigned int ackFrequency = m_conf.getFMAckFrequency(); - unsigned int ackMinTime = m_conf.getFMAckMinTime(); - unsigned int ackDelay = m_conf.getFMAckDelay(); - float ackLevel = m_conf.getFMAckLevel(); - unsigned int timeout = m_conf.getFMTimeout(); - float timeoutLevel = m_conf.getFMTimeoutLevel(); - float ctcssFrequency = m_conf.getFMCTCSSFrequency(); - unsigned int ctcssThreshold = m_conf.getFMCTCSSThreshold(); - float ctcssLevel = m_conf.getFMCTCSSLevel(); - unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); - unsigned int hangTime = m_conf.getFMHangTime(); - bool useCOS = m_conf.getFMUseCOS(); - bool cosInvert = m_conf.getFMCOSInvert(); - unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); - float maxDevLevel = m_conf.getFMMaxDevLevel(); - unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); + std::string callsign = m_conf.getFMCallsign(); + unsigned int callsignSpeed = m_conf.getFMCallsignSpeed(); + unsigned int callsignFrequency = m_conf.getFMCallsignFrequency(); + unsigned int callsignTime = m_conf.getFMCallsignTime(); + unsigned int callsignHoldoff = m_conf.getFMCallsignHoldoff(); + float callsignHighLevel = m_conf.getFMCallsignHighLevel(); + float callsignLowLevel = m_conf.getFMCallsignLowLevel(); + bool callsignAtStart = m_conf.getFMCallsignAtStart(); + bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); + bool callsignAtLatch = m_conf.getFMCallsignAtLatch(); + std::string rfAck = m_conf.getFMRFAck(); + std::string extAck = m_conf.getFMExtAck(); + unsigned int ackSpeed = m_conf.getFMAckSpeed(); + unsigned int ackFrequency = m_conf.getFMAckFrequency(); + unsigned int ackMinTime = m_conf.getFMAckMinTime(); + unsigned int ackDelay = m_conf.getFMAckDelay(); + float ackLevel = m_conf.getFMAckLevel(); + unsigned int timeout = m_conf.getFMTimeout(); + float timeoutLevel = m_conf.getFMTimeoutLevel(); + float ctcssFrequency = m_conf.getFMCTCSSFrequency(); + unsigned int ctcssHighThreshold = m_conf.getFMCTCSSHighThreshold(); + unsigned int ctcssLowThreshold = m_conf.getFMCTCSSLowThreshold(); + float ctcssLevel = m_conf.getFMCTCSSLevel(); + unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); + unsigned int hangTime = m_conf.getFMHangTime(); + bool useCOS = m_conf.getFMUseCOS(); + bool cosInvert = m_conf.getFMCOSInvert(); + unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); + float maxDevLevel = m_conf.getFMMaxDevLevel(); + unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); LogInfo("FM Parameters"); LogInfo(" Callsign: %s", callsign.c_str()); @@ -1260,7 +1261,8 @@ bool CMMDVMHost::createModem() LogInfo(" Timeout: %us", timeout); LogInfo(" Timeout Level: %.1f%%", timeoutLevel); LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency); - LogInfo(" CTCSS Threshold: %u", ctcssThreshold); + LogInfo(" CTCSS High Threshold: %u", ctcssHighThreshold); + LogInfo(" CTCSS Low Threshold: %u", ctcssLowThreshold); LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); @@ -1272,7 +1274,7 @@ bool CMMDVMHost::createModem() m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd, callsignAtLatch); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssHighThreshold, ctcssLowThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index edbebec..d913c6a 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -188,7 +188,8 @@ m_fmAckLevel(80.0F), m_fmTimeout(120U), m_fmTimeoutLevel(80.0F), m_fmCtcssFrequency(88.4F), -m_fmCtcssThreshold(25U), +m_fmCtcssHighThreshold(30U), +m_fmCtcssLowThreshold(20U), m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), @@ -1913,14 +1914,15 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; - m_fmCtcssFrequency = ctcssFrequency; - m_fmCtcssThreshold = ctcssThreshold; - m_fmCtcssLevel = ctcssLevel; + m_fmCtcssFrequency = ctcssFrequency; + m_fmCtcssHighThreshold = ctcssHighThreshold; + m_fmCtcssLowThreshold = ctcssLowThreshold; + m_fmCtcssLevel = ctcssLevel; m_fmKerchunkTime = kerchunkTime; m_fmHangTime = hangTime; @@ -2052,35 +2054,36 @@ bool CModem::setFMMiscParams() unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 14U; + buffer[1U] = 15U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = m_fmTimeout / 5U; buffer[4U] = (unsigned char)(m_fmTimeoutLevel * 2.55F + 0.5F); buffer[5U] = (unsigned char)m_fmCtcssFrequency; - buffer[6U] = m_fmCtcssThreshold; - buffer[7U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F); + buffer[6U] = m_fmCtcssHighThreshold; + buffer[7U] = m_fmCtcssLowThreshold; + buffer[8U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F); - buffer[8U] = m_fmKerchunkTime; - buffer[9U] = m_fmHangTime; + buffer[9U] = m_fmKerchunkTime; + buffer[10U] = m_fmHangTime; - buffer[10U] = 0x00U; + buffer[11U] = 0x00U; if (m_fmUseCOS) - buffer[10U] |= 0x01U; + buffer[11U] |= 0x01U; if (m_fmCOSInvert) - buffer[10U] |= 0x02U; + buffer[11U] |= 0x02U; - buffer[11U] = m_fmRFAudioBoost; + buffer[12U] = m_fmRFAudioBoost; - buffer[12U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); + buffer[13U] = (unsigned char)(m_fmMaxDevLevel * 2.55F + 0.5F); - buffer[13U] = (unsigned char)(m_rxLevel * 2.55F + 0.5F); + buffer[14U] = (unsigned char)(m_rxLevel * 2.55F + 0.5F); - // CUtils::dump(1U, "Written", buffer, 14U); + // CUtils::dump(1U, "Written", buffer, 15U); - int ret = m_serial->write(buffer, 14U); - if (ret != 14) + int ret = m_serial->write(buffer, 15U); + if (ret != 15) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 6404d89..495718f 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); virtual bool open(); @@ -204,7 +204,8 @@ private: unsigned int m_fmTimeout; float m_fmTimeoutLevel; float m_fmCtcssFrequency; - unsigned int m_fmCtcssThreshold; + unsigned int m_fmCtcssHighThreshold; + unsigned int m_fmCtcssLowThreshold; float m_fmCtcssLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; diff --git a/Version.h b/Version.h index 7bf2d5a..c48a90e 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200506"; +const char* VERSION = "20200512"; #endif