Add seperate timeouts for RF and network.

This commit is contained in:
Jonathan Naylor
2017-09-22 21:03:44 +01:00
parent c62c5fe061
commit b966fe7167
4 changed files with 38 additions and 9 deletions

View File

@@ -44,7 +44,8 @@ m_rptAddress("127.0.0.1"),
m_rptPort(62032U),
m_localAddress("127.0.0.1"),
m_localPort(62031U),
m_timeout(10U),
m_rfTimeout(10U),
m_netTimeout(10U),
m_ruleTrace(false),
m_debug(false),
m_voiceEnabled(true),
@@ -169,7 +170,11 @@ bool CConf::read()
if (::strcmp(key, "Daemon") == 0)
m_daemon = ::atoi(value) == 1;
else if (::strcmp(key, "Timeout") == 0)
m_timeout = (unsigned int)::atoi(value);
m_rfTimeout = m_netTimeout = (unsigned int)::atoi(value);
else if (::strcmp(key, "RFTimeout") == 0)
m_rfTimeout = (unsigned int)::atoi(value);
else if (::strcmp(key, "NetTimeout") == 0)
m_netTimeout = (unsigned int)::atoi(value);
else if (::strcmp(key, "RptAddress") == 0)
m_rptAddress = value;
else if (::strcmp(key, "RptPort") == 0)
@@ -461,9 +466,14 @@ unsigned int CConf::getLocalPort() const
return m_localPort;
}
unsigned int CConf::getTimeout() const
unsigned int CConf::getRFTimeout() const
{
return m_timeout;
return m_rfTimeout;
}
unsigned int CConf::getNetTimeout() const
{
return m_netTimeout;
}
bool CConf::getRuleTrace() const

6
Conf.h
View File

@@ -63,7 +63,8 @@ public:
// The General section
bool getDaemon() const;
unsigned int getTimeout() const;
unsigned int getRFTimeout() const;
unsigned int getNetTimeout() const;
std::string getRptAddress() const;
unsigned int getRptPort() const;
std::string getLocalAddress() const;
@@ -157,7 +158,8 @@ private:
unsigned int m_rptPort;
std::string m_localAddress;
unsigned int m_localPort;
unsigned int m_timeout;
unsigned int m_rfTimeout;
unsigned int m_netTimeout;
bool m_ruleTrace;
bool m_debug;

View File

@@ -329,7 +329,8 @@ int CDMRGateway::run()
return 1;
}
unsigned int timeout = m_conf.getTimeout();
unsigned int rfTimeout = m_conf.getRFTimeout();
unsigned int netTimeout = m_conf.getNetTimeout();
CVoice* voice1 = NULL;
CVoice* voice2 = NULL;
@@ -362,8 +363,8 @@ int CDMRGateway::run()
}
CTimer* timer[3U];
timer[1U] = new CTimer(1000U, timeout);
timer[2U] = new CTimer(1000U, timeout);
timer[1U] = new CTimer(1000U);
timer[2U] = new CTimer(1000U);
DMRGW_STATUS status[3U];
status[1U] = DMRGWS_NONE;
@@ -489,6 +490,7 @@ int CDMRGateway::run()
m_xlx1Rewrite->process(data, false);
m_xlxNetwork1->write(data);
status[slotNo] = DMRGWS_XLXREFLECTOR1;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
} else if (flco == FLCO_GROUP && slotNo == m_xlx2Slot && dstId == m_xlx2TG) {
if (m_xlx2Reflector != m_xlx2Startup)
@@ -497,6 +499,7 @@ int CDMRGateway::run()
m_xlx2Rewrite->process(data, false);
m_xlxNetwork2->write(data);
status[slotNo] = DMRGWS_XLXREFLECTOR2;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
} else if ((dstId <= (m_xlx1Base + 26U) || dstId == (m_xlx1Base + 1000U)) && flco == FLCO_USER_USER && slotNo == m_xlx1Slot && dstId >= m_xlx1Base) {
dstId += 4000U;
@@ -530,6 +533,7 @@ int CDMRGateway::run()
}
status[slotNo] = DMRGWS_XLXREFLECTOR1;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
if (voice1 != NULL) {
@@ -576,6 +580,7 @@ int CDMRGateway::run()
}
status[slotNo] = DMRGWS_XLXREFLECTOR2;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
if (voice2 != NULL) {
@@ -622,6 +627,7 @@ int CDMRGateway::run()
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK1) {
m_dmrNetwork1->write(data);
status[slotNo] = DMRGWS_DMRNETWORK1;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
}
}
@@ -642,6 +648,7 @@ int CDMRGateway::run()
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK2) {
m_dmrNetwork2->write(data);
status[slotNo] = DMRGWS_DMRNETWORK2;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
}
}
@@ -662,6 +669,7 @@ int CDMRGateway::run()
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK1) {
m_dmrNetwork1->write(data);
status[slotNo] = DMRGWS_DMRNETWORK1;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
}
}
@@ -682,6 +690,7 @@ int CDMRGateway::run()
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK2) {
m_dmrNetwork2->write(data);
status[slotNo] = DMRGWS_DMRNETWORK2;
timer[slotNo]->setTimeout(rfTimeout);
timer[slotNo]->start();
}
}
@@ -701,6 +710,7 @@ int CDMRGateway::run()
if (ret) {
m_repeater->write(data);
status[m_xlx1Slot] = DMRGWS_XLXREFLECTOR1;
timer[m_xlx1Slot]->setTimeout(netTimeout);
timer[m_xlx1Slot]->start();
} else {
unsigned int slotNo = data.getSlotNo();
@@ -720,6 +730,7 @@ int CDMRGateway::run()
if (ret) {
m_repeater->write(data);
status[m_xlx2Slot] = DMRGWS_XLXREFLECTOR2;
timer[m_xlx2Slot]->setTimeout(netTimeout);
timer[m_xlx2Slot]->start();
} else {
unsigned int slotNo = data.getSlotNo();
@@ -765,6 +776,7 @@ int CDMRGateway::run()
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK1) {
m_repeater->write(data);
status[slotNo] = DMRGWS_DMRNETWORK1;
timer[slotNo]->setTimeout(netTimeout);
timer[slotNo]->start();
}
}
@@ -812,6 +824,7 @@ int CDMRGateway::run()
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK2) {
m_repeater->write(data);
status[slotNo] = DMRGWS_DMRNETWORK2;
timer[slotNo]->setTimeout(netTimeout);
timer[slotNo]->start();
}
}
@@ -855,6 +868,7 @@ int CDMRGateway::run()
if (ret) {
m_repeater->write(data);
status[m_xlx1Slot] = DMRGWS_XLXREFLECTOR1;
timer[m_xlx1Slot]->setTimeout(netTimeout);
timer[m_xlx1Slot]->start();
}
}
@@ -864,6 +878,7 @@ int CDMRGateway::run()
if (ret) {
m_repeater->write(data);
status[m_xlx2Slot] = DMRGWS_XLXREFLECTOR2;
timer[m_xlx2Slot]->setTimeout(netTimeout);
timer[m_xlx2Slot]->start();
}
}

View File

@@ -1,5 +1,7 @@
[General]
Timeout=10
# RFTimeout=10
# NetTimeout=7
RptAddress=127.0.0.1
RptPort=62032
LocalAddress=127.0.0.1