Regularise the FM configuration.

This commit is contained in:
Jonathan Naylor 2020-04-18 14:59:19 +01:00
parent 11cd5679a7
commit c359d874b5
3 changed files with 192 additions and 85 deletions

View file

@ -606,59 +606,6 @@ int CMMDVMHost::run()
pocsagTimer.start();
}
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 callsignLevel = m_conf.getFMCallsignLevel();
bool callsignAtStart = m_conf.getFMCallsignAtStart();
bool callsignAtEnd = m_conf.getFMCallsignAtEnd();
std::string rfAck = m_conf.getFMRFAck();
std::string netAck = m_conf.getFMNetAck();
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();
float ctcssThreshold = m_conf.getFMCTCSSThreshold();
float ctcssLevel = m_conf.getFMCTCSSLevel();
unsigned int kerchunkTime = m_conf.getFMKerchunkTime();
unsigned int hangTime = m_conf.getFMHangTime();
LogInfo("FM RF Parameters");
LogInfo(" Callsign: %s", callsign.c_str());
LogInfo(" Callsign Speed: %uWPM", callsignSpeed);
LogInfo(" Callsign Frequency: %uHz", callsignFrequency);
LogInfo(" Callsign Time: %umins", callsignTime);
LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff);
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(" Ack Speed: %uWPM", ackSpeed);
LogInfo(" Ack Frequency: %uHz", ackFrequency);
LogInfo(" Ack Min Time: %us", ackMinTime);
LogInfo(" Ack Delay: %ums", ackDelay);
LogInfo(" Ack Level: %.1f%%", ackLevel);
LogInfo(" Timeout: %us", timeout);
LogInfo(" Timeout Level: %.1f%%", timeoutLevel);
LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency);
LogInfo(" CTCSS Threshold: %.1f%%", ctcssThreshold);
LogInfo(" CTCSS Level: %.1f%%", ctcssLevel);
LogInfo(" Kerchunk Time: %us", kerchunkTime);
LogInfo(" Hang Time: %us", hangTime);
m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd);
m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel);
m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime);
}
bool remoteControlEnabled = m_conf.getRemoteControlEnabled();
if (remoteControlEnabled) {
unsigned int port = m_conf.getRemoteControlPort();
@ -1252,6 +1199,59 @@ bool CMMDVMHost::createModem()
LogInfo(" FM RX Level: %.1f%%", fmRXLevel);
LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset);
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 callsignLevel = m_conf.getFMCallsignLevel();
bool callsignAtStart = m_conf.getFMCallsignAtStart();
bool callsignAtEnd = m_conf.getFMCallsignAtEnd();
std::string rfAck = m_conf.getFMRFAck();
std::string netAck = m_conf.getFMNetAck();
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();
float ctcssThreshold = m_conf.getFMCTCSSThreshold();
float ctcssLevel = m_conf.getFMCTCSSLevel();
unsigned int kerchunkTime = m_conf.getFMKerchunkTime();
unsigned int hangTime = m_conf.getFMHangTime();
LogInfo("FM Parameters");
LogInfo(" Callsign: %s", callsign.c_str());
LogInfo(" Callsign Speed: %uWPM", callsignSpeed);
LogInfo(" Callsign Frequency: %uHz", callsignFrequency);
LogInfo(" Callsign Time: %umins", callsignTime);
LogInfo(" Callsign Holdoff: 1/%u", callsignHoldoff);
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(" Ack Speed: %uWPM", ackSpeed);
LogInfo(" Ack Frequency: %uHz", ackFrequency);
LogInfo(" Ack Min Time: %us", ackMinTime);
LogInfo(" Ack Delay: %ums", ackDelay);
LogInfo(" Ack Level: %.1f%%", ackLevel);
LogInfo(" Timeout: %us", timeout);
LogInfo(" Timeout Level: %.1f%%", timeoutLevel);
LogInfo(" CTCSS Frequency: %.1fHz", ctcssFrequency);
LogInfo(" CTCSS Threshold: %.1f%%", ctcssThreshold);
LogInfo(" CTCSS Level: %.1f%%", ctcssLevel);
LogInfo(" Kerchunk Time: %us", kerchunkTime);
LogInfo(" Hang Time: %us", hangTime);
m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignLevel, callsignAtStart, callsignAtEnd);
m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel);
m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime);
}
m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug);
m_modem->setSerialParams(protocol,address);
m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled);

140
Modem.cpp
View file

@ -169,7 +169,28 @@ m_cd(false),
m_lockout(false),
m_error(false),
m_mode(MODE_IDLE),
m_hwType(HWT_UNKNOWN)
m_hwType(HWT_UNKNOWN),
m_fmCallsign(),
m_fmCallsignSpeed(20U),
m_fmCallsignFrequency(1000U),
m_fmCallsignTime(600U),
m_fmCallsignHoldoff(0U),
m_fmCallsignLevel(40.0F),
m_fmCallsignAtStart(true),
m_fmCallsignAtEnd(true),
m_fmRfAck("K"),
m_fmAckSpeed(20U),
m_fmAckFrequency(1750U),
m_fmAckMinTime(4U),
m_fmAckDelay(1000U),
m_fmAckLevel(80.0F),
m_fmTimeout(120U),
m_fmTimeoutLevel(80.0F),
m_fmCtcssFrequency(88.4F),
m_fmCtcssThreshold(10.0F),
m_fmCtcssLevel(10.0F),
m_fmKerchunkTime(0U),
m_fmHangTime(5U)
{
m_buffer = new unsigned char[BUFFER_LENGTH];
@ -280,6 +301,32 @@ bool CModem::open()
return false;
}
if (m_fmEnabled) {
ret = setFMCallsignParams();
if (!ret) {
m_serial->close();
delete m_serial;
m_serial = NULL;
return false;
}
ret = setFMAckParams();
if (!ret) {
m_serial->close();
delete m_serial;
m_serial = NULL;
return false;
}
ret = setFMMiscParams();
if (!ret) {
m_serial->close();
delete m_serial;
m_serial = NULL;
return false;
}
}
m_statusTimer.start();
m_error = false;
@ -1834,32 +1881,67 @@ 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 callsignLevel, bool callsignAtStart, bool callsignAtEnd)
void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd)
{
m_fmCallsign = callsign;
m_fmCallsignSpeed = callsignSpeed;
m_fmCallsignFrequency = callsignFrequency;
m_fmCallsignTime = callsignTime;
m_fmCallsignHoldoff = callsignHoldoff;
m_fmCallsignLevel = callsignLevel;
m_fmCallsignAtStart = callsignAtStart;
m_fmCallsignAtEnd = callsignAtEnd;
}
void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel)
{
m_fmRfAck = rfAck;
m_fmAckSpeed = ackSpeed;
m_fmAckFrequency = ackFrequency;
m_fmAckMinTime = ackMinTime;
m_fmAckDelay = ackDelay;
m_fmAckLevel = ackLevel;
}
void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime)
{
m_fmTimeout = timeout;
m_fmTimeoutLevel = timeoutLevel;
m_fmCtcssFrequency = ctcssFrequency;
m_fmCtcssThreshold = ctcssThreshold;
m_fmCtcssLevel = ctcssLevel;
m_fmKerchunkTime = kerchunkTime;
m_fmHangTime = hangTime;
}
bool CModem::setFMCallsignParams()
{
assert(m_serial != NULL);
unsigned char buffer[80U];
unsigned char len = 9U + callsign.size();
unsigned char len = 9U + m_fmCallsign.size();
buffer[0U] = MMDVM_FRAME_START;
buffer[1U] = len;
buffer[2U] = MMDVM_FM_PARAMS1;
buffer[3U] = callsignSpeed;
buffer[4U] = callsignFrequency / 10U;
buffer[5U] = callsignTime;
buffer[6U] = callsignHoldoff;
buffer[3U] = m_fmCallsignSpeed;
buffer[4U] = m_fmCallsignFrequency / 10U;
buffer[5U] = m_fmCallsignTime;
buffer[6U] = m_fmCallsignHoldoff;
buffer[7U] = (unsigned char)(callsignLevel * 2.55F + 0.5F);
buffer[7U] = (unsigned char)(m_fmCallsignLevel * 2.55F + 0.5F);
buffer[8U] = 0x00U;
if (callsignAtStart)
if (m_fmCallsignAtStart)
buffer[8U] |= 0x01U;
if (callsignAtEnd)
if (m_fmCallsignAtEnd)
buffer[8U] |= 0x02U;
for (unsigned int i = 0U; i < callsign.size(); i++)
buffer[9U + i] = callsign.at(i);
for (unsigned int i = 0U; i < m_fmCallsign.size(); i++)
buffer[9U + i] = m_fmCallsign.at(i);
// CUtils::dump(1U, "Written", buffer, len);
@ -1892,26 +1974,26 @@ bool CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls
return true;
}
bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel)
bool CModem::setFMAckParams()
{
assert(m_serial != NULL);
unsigned char buffer[80U];
unsigned char len = 8U + rfAck.size();
unsigned char len = 8U + m_fmRfAck.size();
buffer[0U] = MMDVM_FRAME_START;
buffer[1U] = len;
buffer[2U] = MMDVM_FM_PARAMS2;
buffer[3U] = ackSpeed;
buffer[4U] = ackFrequency / 10U;
buffer[5U] = ackMinTime;
buffer[6U] = ackDelay / 10U;
buffer[3U] = m_fmAckSpeed;
buffer[4U] = m_fmAckFrequency / 10U;
buffer[5U] = m_fmAckMinTime;
buffer[6U] = m_fmAckDelay / 10U;
buffer[7U] = (unsigned char)(ackLevel * 2.55F + 0.5F);
buffer[7U] = (unsigned char)(m_fmAckLevel * 2.55F + 0.5F);
for (unsigned int i = 0U; i < rfAck.size(); i++)
buffer[8U + i] = rfAck.at(i);
for (unsigned int i = 0U; i < m_fmRfAck.size(); i++)
buffer[8U + i] = m_fmRfAck.at(i);
// CUtils::dump(1U, "Written", buffer, len);
@ -1944,7 +2026,7 @@ bool CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns
return true;
}
bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime)
bool CModem::setFMMiscParams()
{
assert(m_serial != NULL);
@ -1954,15 +2036,15 @@ bool CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc
buffer[1U] = 10U;
buffer[2U] = MMDVM_FM_PARAMS3;
buffer[3U] = timeout / 5U;
buffer[4U] = (unsigned char)(timeoutLevel * 2.55F + 0.5F);
buffer[3U] = m_fmTimeout / 5U;
buffer[4U] = (unsigned char)(m_fmTimeoutLevel * 2.55F + 0.5F);
buffer[5U] = (unsigned char)ctcssFrequency;
buffer[6U] = (unsigned char)(ctcssThreshold * 2.55F + 0.5F);
buffer[7U] = (unsigned char)(ctcssLevel * 2.55F + 0.5F);
buffer[5U] = (unsigned char)m_fmCtcssFrequency;
buffer[6U] = (unsigned char)(m_fmCtcssThreshold * 2.55F + 0.5F);
buffer[7U] = (unsigned char)(m_fmCtcssLevel * 2.55F + 0.5F);
buffer[8U] = kerchunkTime;
buffer[9U] = hangTime;
buffer[8U] = m_fmKerchunkTime;
buffer[9U] = m_fmHangTime;
// CUtils::dump(1U, "Written", buffer, 10U);

31
Modem.h
View file

@ -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 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(unsigned int timeout, float timeoutLevel, float ctcssFrequency, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime);
virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignLevel, bool callsignAtStart, bool callsignAtEnd);
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, float ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime);
virtual bool open();
@ -185,10 +185,35 @@ private:
unsigned char m_mode;
HW_TYPE m_hwType;
std::string m_fmCallsign;
unsigned int m_fmCallsignSpeed;
unsigned int m_fmCallsignFrequency;
unsigned int m_fmCallsignTime;
unsigned int m_fmCallsignHoldoff;
float m_fmCallsignLevel;
bool m_fmCallsignAtStart;
bool m_fmCallsignAtEnd;
std::string m_fmRfAck;
unsigned int m_fmAckSpeed;
unsigned int m_fmAckFrequency;
unsigned int m_fmAckMinTime;
unsigned int m_fmAckDelay;
float m_fmAckLevel;
unsigned int m_fmTimeout;
float m_fmTimeoutLevel;
float m_fmCtcssFrequency;
float m_fmCtcssThreshold;
float m_fmCtcssLevel;
unsigned int m_fmKerchunkTime;
unsigned int m_fmHangTime;
bool readVersion();
bool readStatus();
bool setConfig();
bool setFrequency();
bool setFMCallsignParams();
bool setFMAckParams();
bool setFMMiscParams();
void printDebug();