From 11cd5679a78aab7a3050567e2d955e21e6f43a4f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 18 Apr 2020 13:43:36 +0100 Subject: [PATCH] Simplify the FM configuration. --- Conf.cpp | 18 +++++------------- Conf.h | 6 ++---- MMDVM.ini | 5 ++--- MMDVMHost.cpp | 12 +++++------- Modem.cpp | 29 ++++++++++++----------------- Modem.h | 4 ++-- Version.h | 2 +- 7 files changed, 29 insertions(+), 47 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index d97fae7..1663d48 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -179,8 +179,7 @@ m_fmCallsignSpeed(20U), m_fmCallsignFrequency(1000U), m_fmCallsignTime(10U), m_fmCallsignHoldoff(1U), -m_fmCallsignHighLevel(80.0F), -m_fmCallsignLowLevel(40.0F), +m_fmCallsignLevel(40.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), m_fmRFAck("K"), @@ -707,10 +706,8 @@ bool CConf::read() m_fmCallsignTime = (unsigned int)::atoi(value); else if (::strcmp(key, "CallsignHoldoff") == 0) m_fmCallsignHoldoff = (unsigned int)::atoi(value); - else if (::strcmp(key, "CallsignHighLevel") == 0) - m_fmCallsignHighLevel = float(::atof(value)); - else if (::strcmp(key, "CallsignLowLevel") == 0) - m_fmCallsignLowLevel = float(::atof(value)); + else if (::strcmp(key, "CallsignLevel") == 0) + m_fmCallsignLevel = float(::atof(value)); else if (::strcmp(key, "CallsignAtStart") == 0) m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) @@ -1521,14 +1518,9 @@ unsigned int CConf::getFMCallsignHoldoff() const return m_fmCallsignHoldoff; } -float CConf::getFMCallsignHighLevel() const +float CConf::getFMCallsignLevel() const { - return m_fmCallsignHighLevel; -} - -float CConf::getFMCallsignLowLevel() const -{ - return m_fmCallsignLowLevel; + return m_fmCallsignLevel; } bool CConf::getFMCallsignAtStart() const diff --git a/Conf.h b/Conf.h index 87c5fc9..af882a2 100644 --- a/Conf.h +++ b/Conf.h @@ -177,8 +177,7 @@ public: unsigned int getFMCallsignFrequency() const; unsigned int getFMCallsignTime() const; unsigned int getFMCallsignHoldoff() const; - float getFMCallsignHighLevel() const; - float getFMCallsignLowLevel() const; + float getFMCallsignLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; std::string getFMRFAck() const; @@ -439,8 +438,7 @@ private: unsigned int m_fmCallsignFrequency; unsigned int m_fmCallsignTime; unsigned int m_fmCallsignHoldoff; - float m_fmCallsignHighLevel; - float m_fmCallsignLowLevel; + float m_fmCallsignLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; std::string m_fmRFAck; diff --git a/MMDVM.ini b/MMDVM.ini index d64eddd..c8a5403 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -147,12 +147,11 @@ CallsignSpeed=20 CallsignFrequency=1000 CallsignTime=10 CallsignHoldoff=1 -CallsignHighLevel=80 -CallsignLowLevel=40 +CallsignLevel=40 CallsignAtStart=1 CallsignAtEnd=1 RFAck=K -NetAck=N +# NetAck=N AckSpeed=20 AckFrequency=1750 AckMinTime=4 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 73561c5..708fa97 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -612,8 +612,7 @@ int CMMDVMHost::run() 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(); + float callsignLevel = m_conf.getFMCallsignLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); std::string rfAck = m_conf.getFMRFAck(); @@ -637,12 +636,11 @@ int CMMDVMHost::run() LogInfo(" Callsign Frequency: %uHz", callsignFrequency); LogInfo(" Callsign Time: %umins", callsignTime); LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff); - LogInfo(" Callsign High Level: %.1f%%", callsignHighLevel); - LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); + LogInfo(" Callsign Level: %.1f%%", callsignLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); LogInfo(" RF Ack: %s", rfAck.c_str()); - LogInfo(" Net Ack: %s", netAck.c_str()); + // LogInfo(" Net Ack: %s", netAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); LogInfo(" Ack Frequency: %uHz", ackFrequency); LogInfo(" Ack Min Time: %us", ackMinTime); @@ -656,9 +654,9 @@ int CMMDVMHost::run() LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); - m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(netAck, timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); } bool remoteControlEnabled = m_conf.getRemoteControlEnabled(); diff --git a/Modem.cpp b/Modem.cpp index 318e5d2..db47265 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1834,12 +1834,12 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -bool CModem::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 CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd) { assert(m_serial != NULL); unsigned char buffer[80U]; - unsigned char len = 10U + callsign.size(); + unsigned char len = 9U + callsign.size(); buffer[0U] = MMDVM_FRAME_START; buffer[1U] = len; @@ -1850,17 +1850,16 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls buffer[5U] = callsignTime; buffer[6U] = callsignHoldoff; - buffer[7U] = (unsigned char)(callsignHighLevel * 2.55F + 0.5F); - buffer[8U] = (unsigned char)(callsignLowLevel * 2.55F + 0.5F); + buffer[7U] = (unsigned char)(callsignLevel * 2.55F + 0.5F); - buffer[9U] = 0x00U; + buffer[8U] = 0x00U; if (callsignAtStart) - buffer[9U] |= 0x01U; + buffer[8U] |= 0x01U; if (callsignAtEnd) - buffer[9U] |= 0x02U; + buffer[8U] |= 0x02U; for (unsigned int i = 0U; i < callsign.size(); i++) - buffer[10U + i] = callsign.at(i); + buffer[9U + i] = callsign.at(i); // CUtils::dump(1U, "Written", buffer, len); @@ -1945,15 +1944,14 @@ bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns return true; } -bool CModem::setFMMiscParams(const std::string& netAck, unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) +bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime) { assert(m_serial != NULL); unsigned char buffer[20U]; - unsigned char len = 10U + netAck.size(); buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = len; + buffer[1U] = 10U; buffer[2U] = MMDVM_FM_PARAMS3; buffer[3U] = timeout / 5U; @@ -1966,13 +1964,10 @@ bool CModem::setFMMiscParams(const std::string& netAck, unsigned int timeout, fl buffer[8U] = kerchunkTime; buffer[9U] = hangTime; - for (unsigned int i = 0U; i < netAck.size(); i++) - buffer[10U + i] = netAck.at(i); + // CUtils::dump(1U, "Written", buffer, 10U); - // CUtils::dump(1U, "Written", buffer, len); - - int ret = m_serial->write(buffer, len); - if (ret != len) + int ret = m_serial->write(buffer, 10U); + if (ret != 10) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 4571ef5..4a33116 100644 --- a/Modem.h +++ b/Modem.h @@ -45,9 +45,9 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual bool 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); + virtual bool setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd); virtual bool setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int minTime, unsigned int ackDelay, float ackLevel); - virtual bool setFMMiscParams(const std::string& netAck, unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); + virtual bool setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime); virtual bool open(); diff --git a/Version.h b/Version.h index a8bedbc..049e6ea 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200415"; +const char* VERSION = "20200418"; #endif