Add the CW Id.

This commit is contained in:
Jonathan Naylor
2016-05-09 21:55:44 +01:00
parent bd5946ccd2
commit 68d58a3de6
7 changed files with 93 additions and 16 deletions

View File

@@ -32,6 +32,7 @@ enum SECTION {
SECTION_GENERAL,
SECTION_INFO,
SECTION_LOG,
SECTION_CWID,
SECTION_MODEM,
SECTION_DSTAR,
SECTION_DMR,
@@ -65,6 +66,8 @@ m_logDisplayLevel(0U),
m_logFileLevel(0U),
m_logFilePath(),
m_logFileRoot(),
m_cwIdEnabled(false),
m_cwIdTime(10U),
m_modemPort(),
m_modemRXInvert(false),
m_modemTXInvert(false),
@@ -148,6 +151,8 @@ bool CConf::read()
section = SECTION_INFO;
else if (::strncmp(buffer, "[Log]", 5U) == 0)
section = SECTION_LOG;
else if (::strncmp(buffer, "[CW Id]", 7U) == 0)
section = SECTION_CWID;
else if (::strncmp(buffer, "[Modem]", 7U) == 0)
section = SECTION_MODEM;
else if (::strncmp(buffer, "[D-Star]", 8U) == 0)
@@ -223,6 +228,11 @@ bool CConf::read()
m_logFileLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "DisplayLevel") == 0)
m_logDisplayLevel = (unsigned int)::atoi(value);
} else if (section == SECTION_CWID) {
if (::strcmp(key, "Enable") == 0)
m_cwIdEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Time") == 0)
m_cwIdTime = (unsigned int)::atoi(value);
} else if (section == SECTION_MODEM) {
if (::strcmp(key, "Port") == 0)
m_modemPort = value;
@@ -476,6 +486,16 @@ std::string CConf::getLogFileRoot() const
return m_logFileRoot;
}
bool CConf::getCWIdEnabled() const
{
return m_cwIdEnabled;
}
unsigned int CConf::getCWIdTime() const
{
return m_cwIdTime;
}
std::string CConf::getModemPort() const
{
return m_modemPort;

7
Conf.h
View File

@@ -55,6 +55,10 @@ public:
std::string getLogFilePath() const;
std::string getLogFileRoot() const;
// The CW ID section
bool getCWIdEnabled() const;
unsigned int getCWIdTime() const;
// The Modem section
std::string getModemPort() const;
bool getModemRXInvert() const;
@@ -153,6 +157,9 @@ private:
std::string m_logFilePath;
std::string m_logFileRoot;
bool m_cwIdEnabled;
unsigned int m_cwIdTime;
std::string m_modemPort;
bool m_modemRXInvert;
bool m_modemTXInvert;

View File

@@ -24,6 +24,10 @@ FileLevel=1
FilePath=.
FileRoot=MMDVM
[CW Id]
Enable=1
Time=10
[Modem]
# Port=/dev/ttyACM0
Port=\\.\COM3

View File

@@ -107,10 +107,12 @@ m_display(NULL),
m_mode(MODE_IDLE),
m_modeTimer(1000U),
m_dmrTXTimer(1000U),
m_cwIdTimer(1000U),
m_duplex(false),
m_dstarEnabled(false),
m_dmrEnabled(false),
m_ysfEnabled(false)
m_ysfEnabled(false),
m_callsign()
{
}
@@ -223,6 +225,15 @@ int CMMDVMHost::run()
return 1;
}
if (m_conf.getCWIdEnabled()) {
unsigned int time = m_conf.getCWIdTime();
LogInfo("CW Id Parameters");
LogInfo(" Time: %u mins", time);
m_cwIdTimer.setTimeout(time * 60U);
}
CTimer dmrBeaconTimer(1000U, 4U);
bool dmrBeaconsEnabled = m_dmrEnabled && m_conf.getDMRBeacons();
@@ -231,21 +242,20 @@ int CMMDVMHost::run()
CDStarControl* dstar = NULL;
if (m_dstarEnabled) {
std::string callsign = m_conf.getCallsign();
std::string module = m_conf.getDStarModule();
bool selfOnly = m_conf.getDStarSelfOnly();
unsigned int timeout = m_conf.getTimeout();
std::vector<std::string> blackList = m_conf.getDStarBlackList();
LogInfo("D-Star Parameters");
LogInfo(" Callsign: %s", callsign.c_str());
LogInfo(" Callsign: %s", m_callsign.c_str());
LogInfo(" Module: %s", module.c_str());
LogInfo(" Self Only: %s", selfOnly ? "yes" : "no");
if (blackList.size() > 0U)
LogInfo(" Black List: %u", blackList.size());
LogInfo(" Timeout: %us", timeout);
dstar = new CDStarControl(callsign, module, selfOnly, blackList, m_dstarNetwork, m_display, timeout, m_duplex);
dstar = new CDStarControl(m_callsign, module, selfOnly, blackList, m_dstarNetwork, m_display, timeout, m_duplex);
}
CDMRControl* dmr = NULL;
@@ -277,16 +287,15 @@ int CMMDVMHost::run()
CYSFControl* ysf = NULL;
if (m_ysfEnabled) {
std::string callsign = m_conf.getCallsign();
unsigned int timeout = m_conf.getTimeout();
bool parrot = m_conf.getFusionParrotEnabled();
LogInfo("System Fusion Parameters");
LogInfo(" Callsign: %s", callsign.c_str());
LogInfo(" Callsign: %s", m_callsign.c_str());
LogInfo(" Timeout: %us", timeout);
LogInfo(" Parrot: %s", parrot ? "enabled" : "disabled");
ysf = new CYSFControl(callsign, m_display, timeout, m_duplex, parrot);
ysf = new CYSFControl(m_callsign, m_display, timeout, m_duplex, parrot);
}
m_modeTimer.setTimeout(m_conf.getModeHang());
@@ -511,6 +520,12 @@ int CMMDVMHost::run()
if (m_dmrNetwork != NULL)
m_dmrNetwork->clock(ms);
m_cwIdTimer.clock(ms);
if (m_cwIdTimer.isRunning() && m_cwIdTimer.hasExpired()) {
m_modem->sendCWId(m_callsign);
m_cwIdTimer.start();
}
dmrBeaconTimer.clock(ms);
if (dmrBeaconTimer.isRunning() && dmrBeaconTimer.hasExpired()) {
setMode(MODE_IDLE, false);
@@ -652,7 +667,6 @@ bool CMMDVMHost::createDMRNetwork()
m_dmrNetwork = new CDMRIPSC(address, port, local, id, password, m_duplex, VERSION, debug, slot1, slot2);
std::string callsign = m_conf.getCallsign();
unsigned int rxFrequency = m_conf.getRxFrequency();
unsigned int txFrequency = m_conf.getTxFrequency();
unsigned int power = m_conf.getPower();
@@ -665,7 +679,7 @@ bool CMMDVMHost::createDMRNetwork()
std::string url = m_conf.getURL();
LogInfo("Info Parameters");
LogInfo(" Callsign: %s", callsign.c_str());
LogInfo(" Callsign: %s", m_callsign.c_str());
LogInfo(" RX Frequency: %uHz", rxFrequency);
LogInfo(" TX Frequency: %uHz", txFrequency);
LogInfo(" Power: %uW", power);
@@ -676,7 +690,7 @@ bool CMMDVMHost::createDMRNetwork()
LogInfo(" Description: \"%s\"", description.c_str());
LogInfo(" URL: \"%s\"", url.c_str());
m_dmrNetwork->setConfig(callsign, rxFrequency, txFrequency, power, colorCode, latitude, longitude, height, location, description, url);
m_dmrNetwork->setConfig(m_callsign, rxFrequency, txFrequency, power, colorCode, latitude, longitude, height, location, description, url);
bool ret = m_dmrNetwork->open();
if (!ret) {
@@ -696,13 +710,13 @@ void CMMDVMHost::readParams()
m_dmrEnabled = m_conf.getDMREnabled();
m_ysfEnabled = m_conf.getFusionEnabled();
m_duplex = m_conf.getDuplex();
m_callsign = m_conf.getCallsign();
}
void CMMDVMHost::createDisplay()
{
std::string type = m_conf.getDisplay();
std::string callsign = m_conf.getCallsign();
unsigned int dmrid = m_conf.getDMRId();
std::string type = m_conf.getDisplay();
unsigned int dmrid = m_conf.getDMRId();
LogInfo("Display Parameters");
LogInfo(" Type: %s", type.c_str());
@@ -714,7 +728,7 @@ void CMMDVMHost::createDisplay()
LogInfo(" Port: %s", port.c_str());
LogInfo(" Brightness: %u", brightness);
m_display = new CTFTSerial(callsign, dmrid, port, brightness);
m_display = new CTFTSerial(m_callsign, dmrid, port, brightness);
} else if (type == "Nextion") {
std::string size = m_conf.getNextionSize();
std::string port = m_conf.getNextionPort();
@@ -724,7 +738,7 @@ void CMMDVMHost::createDisplay()
LogInfo(" Port: %s", port.c_str());
LogInfo(" Brightness: %u", brightness);
m_display = new CNextion(callsign, dmrid, size, port, brightness);
m_display = new CNextion(m_callsign, dmrid, size, port, brightness);
#if defined(HD44780)
} else if (type == "HD44780") {
unsigned int rows = m_conf.getHD44780Rows();
@@ -747,7 +761,7 @@ void CMMDVMHost::createDisplay()
LogInfo(" PWM Dim: %u", pwmDim);
}
m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, m_duplex);
m_display = new CHD44780(rows, columns, m_callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, m_duplex);
}
#endif
} else {
@@ -775,6 +789,7 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
m_modem->setMode(MODE_DSTAR);
m_mode = MODE_DSTAR;
m_modeTimer.start();
m_cwIdTimer.stop();
break;
case MODE_DMR:
@@ -789,6 +804,7 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
}
m_mode = MODE_DMR;
m_modeTimer.start();
m_cwIdTimer.stop();
break;
case MODE_YSF:
@@ -801,6 +817,7 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
m_modem->setMode(MODE_YSF);
m_mode = MODE_YSF;
m_modeTimer.start();
m_cwIdTimer.stop();
break;
case MODE_LOCKOUT:
@@ -818,6 +835,7 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
m_display->setLockout();
m_mode = MODE_LOCKOUT;
m_modeTimer.stop();
m_cwIdTimer.stop();
break;
case MODE_ERROR:
@@ -834,6 +852,7 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
m_display->setError("MODEM");
m_mode = MODE_ERROR;
m_modeTimer.stop();
m_cwIdTimer.stop();
break;
default:
@@ -851,6 +870,7 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
m_display->setIdle();
m_mode = MODE_IDLE;
m_modeTimer.stop();
m_cwIdTimer.start();
break;
}
}

View File

@@ -45,10 +45,12 @@ private:
unsigned char m_mode;
CTimer m_modeTimer;
CTimer m_dmrTXTimer;
CTimer m_cwIdTimer;
bool m_duplex;
bool m_dstarEnabled;
bool m_dmrEnabled;
bool m_ysfEnabled;
std::string m_callsign;
void readParams();
bool createModem();

View File

@@ -43,6 +43,8 @@ const unsigned char MMDVM_SET_CONFIG = 0x02U;
const unsigned char MMDVM_SET_MODE = 0x03U;
const unsigned char MMDVM_SET_FREQ = 0x04U;
const unsigned char MMDVM_SEND_CWID = 0x0AU;
const unsigned char MMDVM_DSTAR_HEADER = 0x10U;
const unsigned char MMDVM_DSTAR_DATA = 0x11U;
const unsigned char MMDVM_DSTAR_LOST = 0x12U;
@@ -1013,6 +1015,26 @@ bool CModem::setMode(unsigned char mode)
return m_serial.write(buffer, 4U) == 4;
}
bool CModem::sendCWId(const std::string& callsign)
{
unsigned int length = callsign.length();
if (length > 200U)
length = 200U;
unsigned char buffer[205U];
buffer[0U] = MMDVM_FRAME_START;
buffer[1U] = length + 3U;
buffer[2U] = MMDVM_SEND_CWID;
for (unsigned int i = 0U; i < length; i++)
buffer[i + 3U] = callsign.at(i);
// CUtils::dump(1U, "Written", buffer, length + 3U);
return m_serial.write(buffer, length + 3U) == (length + 3U);
}
bool CModem::writeDMRStart(bool tx)
{
if (tx && m_tx)

View File

@@ -67,6 +67,8 @@ public:
bool setMode(unsigned char mode);
bool sendCWId(const std::string& callsign);
void clock(unsigned int ms);
void close();