mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-22 06:05:36 +08:00
Add configuration option "Relink" to specify re-link timeout for XLX
This commit is contained in:
16
Conf.cpp
16
Conf.cpp
@@ -92,6 +92,7 @@ m_xlxNetwork1Slot(1U),
|
|||||||
m_xlxNetwork1TG(8U),
|
m_xlxNetwork1TG(8U),
|
||||||
m_xlxNetwork1Base(84000U),
|
m_xlxNetwork1Base(84000U),
|
||||||
m_xlxNetwork1Startup(4000U),
|
m_xlxNetwork1Startup(4000U),
|
||||||
|
m_xlxNetwork1Relink(0U),
|
||||||
m_xlxNetwork1Options(),
|
m_xlxNetwork1Options(),
|
||||||
m_xlxNetwork1Debug(false),
|
m_xlxNetwork1Debug(false),
|
||||||
m_xlxNetwork2Enabled(false),
|
m_xlxNetwork2Enabled(false),
|
||||||
@@ -104,6 +105,7 @@ m_xlxNetwork2Slot(1U),
|
|||||||
m_xlxNetwork2TG(7U),
|
m_xlxNetwork2TG(7U),
|
||||||
m_xlxNetwork2Base(74000U),
|
m_xlxNetwork2Base(74000U),
|
||||||
m_xlxNetwork2Startup(4000U),
|
m_xlxNetwork2Startup(4000U),
|
||||||
|
m_xlxNetwork2Relink(0U),
|
||||||
m_xlxNetwork2Options(),
|
m_xlxNetwork2Options(),
|
||||||
m_xlxNetwork2Debug(false)
|
m_xlxNetwork2Debug(false)
|
||||||
{
|
{
|
||||||
@@ -211,6 +213,8 @@ bool CConf::read()
|
|||||||
m_xlxNetwork1Base = (unsigned int)::atoi(value);
|
m_xlxNetwork1Base = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Startup") == 0)
|
else if (::strcmp(key, "Startup") == 0)
|
||||||
m_xlxNetwork1Startup = (unsigned int)::atoi(value);
|
m_xlxNetwork1Startup = (unsigned int)::atoi(value);
|
||||||
|
else if (::strcmp(key, "Relink") == 0)
|
||||||
|
m_xlxNetwork1Relink = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Options") == 0)
|
else if (::strcmp(key, "Options") == 0)
|
||||||
m_xlxNetwork1Options = value;
|
m_xlxNetwork1Options = value;
|
||||||
else if (::strcmp(key, "Debug") == 0)
|
else if (::strcmp(key, "Debug") == 0)
|
||||||
@@ -236,6 +240,8 @@ bool CConf::read()
|
|||||||
m_xlxNetwork2Base = (unsigned int)::atoi(value);
|
m_xlxNetwork2Base = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Startup") == 0)
|
else if (::strcmp(key, "Startup") == 0)
|
||||||
m_xlxNetwork2Startup = (unsigned int)::atoi(value);
|
m_xlxNetwork2Startup = (unsigned int)::atoi(value);
|
||||||
|
else if (::strcmp(key, "Relink") == 0)
|
||||||
|
m_xlxNetwork2Relink = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Options") == 0)
|
else if (::strcmp(key, "Options") == 0)
|
||||||
m_xlxNetwork2Options = value;
|
m_xlxNetwork2Options = value;
|
||||||
else if (::strcmp(key, "Debug") == 0)
|
else if (::strcmp(key, "Debug") == 0)
|
||||||
@@ -532,6 +538,11 @@ unsigned int CConf::getXLXNetwork1Startup() const
|
|||||||
return m_xlxNetwork1Startup;
|
return m_xlxNetwork1Startup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getXLXNetwork1Relink() const
|
||||||
|
{
|
||||||
|
return m_xlxNetwork1Relink;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CConf::getXLXNetwork1Password() const
|
std::string CConf::getXLXNetwork1Password() const
|
||||||
{
|
{
|
||||||
return m_xlxNetwork1Password;
|
return m_xlxNetwork1Password;
|
||||||
@@ -592,6 +603,11 @@ unsigned int CConf::getXLXNetwork2Startup() const
|
|||||||
return m_xlxNetwork2Startup;
|
return m_xlxNetwork2Startup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getXLXNetwork2Relink() const
|
||||||
|
{
|
||||||
|
return m_xlxNetwork2Relink;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CConf::getXLXNetwork2Password() const
|
std::string CConf::getXLXNetwork2Password() const
|
||||||
{
|
{
|
||||||
return m_xlxNetwork2Password;
|
return m_xlxNetwork2Password;
|
||||||
|
|||||||
4
Conf.h
4
Conf.h
@@ -125,6 +125,7 @@ public:
|
|||||||
unsigned int getXLXNetwork1TG() const;
|
unsigned int getXLXNetwork1TG() const;
|
||||||
unsigned int getXLXNetwork1Base() const;
|
unsigned int getXLXNetwork1Base() const;
|
||||||
unsigned int getXLXNetwork1Startup() const;
|
unsigned int getXLXNetwork1Startup() const;
|
||||||
|
unsigned int getXLXNetwork1Relink() const;
|
||||||
std::string getXLXNetwork1Options() const;
|
std::string getXLXNetwork1Options() const;
|
||||||
bool getXLXNetwork1Debug() const;
|
bool getXLXNetwork1Debug() const;
|
||||||
|
|
||||||
@@ -139,6 +140,7 @@ public:
|
|||||||
unsigned int getXLXNetwork2TG() const;
|
unsigned int getXLXNetwork2TG() const;
|
||||||
unsigned int getXLXNetwork2Base() const;
|
unsigned int getXLXNetwork2Base() const;
|
||||||
unsigned int getXLXNetwork2Startup() const;
|
unsigned int getXLXNetwork2Startup() const;
|
||||||
|
unsigned int getXLXNetwork2Relink() const;
|
||||||
std::string getXLXNetwork2Options() const;
|
std::string getXLXNetwork2Options() const;
|
||||||
bool getXLXNetwork2Debug() const;
|
bool getXLXNetwork2Debug() const;
|
||||||
|
|
||||||
@@ -202,6 +204,7 @@ private:
|
|||||||
unsigned int m_xlxNetwork1TG;
|
unsigned int m_xlxNetwork1TG;
|
||||||
unsigned int m_xlxNetwork1Base;
|
unsigned int m_xlxNetwork1Base;
|
||||||
unsigned int m_xlxNetwork1Startup;
|
unsigned int m_xlxNetwork1Startup;
|
||||||
|
unsigned int m_xlxNetwork1Relink;
|
||||||
std::string m_xlxNetwork1Options;
|
std::string m_xlxNetwork1Options;
|
||||||
bool m_xlxNetwork1Debug;
|
bool m_xlxNetwork1Debug;
|
||||||
|
|
||||||
@@ -215,6 +218,7 @@ private:
|
|||||||
unsigned int m_xlxNetwork2TG;
|
unsigned int m_xlxNetwork2TG;
|
||||||
unsigned int m_xlxNetwork2Base;
|
unsigned int m_xlxNetwork2Base;
|
||||||
unsigned int m_xlxNetwork2Startup;
|
unsigned int m_xlxNetwork2Startup;
|
||||||
|
unsigned int m_xlxNetwork2Relink;
|
||||||
std::string m_xlxNetwork2Options;
|
std::string m_xlxNetwork2Options;
|
||||||
bool m_xlxNetwork2Debug;
|
bool m_xlxNetwork2Debug;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(_WIN64)
|
#if !defined(_WIN32) && !defined(_WIN64)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -142,6 +144,7 @@ m_xlx1Slot(0U),
|
|||||||
m_xlx1TG(0U),
|
m_xlx1TG(0U),
|
||||||
m_xlx1Base(0U),
|
m_xlx1Base(0U),
|
||||||
m_xlx1Startup(4000U),
|
m_xlx1Startup(4000U),
|
||||||
|
m_xlx1Relink(0U),
|
||||||
m_xlx1Connected(false),
|
m_xlx1Connected(false),
|
||||||
m_rpt1Rewrite(NULL),
|
m_rpt1Rewrite(NULL),
|
||||||
m_xlx1Rewrite(NULL),
|
m_xlx1Rewrite(NULL),
|
||||||
@@ -151,6 +154,7 @@ m_xlx2Slot(0U),
|
|||||||
m_xlx2TG(0U),
|
m_xlx2TG(0U),
|
||||||
m_xlx2Base(0U),
|
m_xlx2Base(0U),
|
||||||
m_xlx2Startup(4000U),
|
m_xlx2Startup(4000U),
|
||||||
|
m_xlx2Relink(0U),
|
||||||
m_xlx2Connected(false),
|
m_xlx2Connected(false),
|
||||||
m_rpt2Rewrite(NULL),
|
m_rpt2Rewrite(NULL),
|
||||||
m_xlx2Rewrite(NULL),
|
m_xlx2Rewrite(NULL),
|
||||||
@@ -376,9 +380,9 @@ int CDMRGateway::run()
|
|||||||
unsigned int dmr2DstId[3U];
|
unsigned int dmr2DstId[3U];
|
||||||
dmr2SrcId[1U] = dmr2SrcId[2U] = dmr2DstId[1U] = dmr2DstId[2U] = 0U;
|
dmr2SrcId[1U] = dmr2SrcId[2U] = dmr2DstId[1U] = dmr2DstId[2U] = 0U;
|
||||||
|
|
||||||
//XLX timeouts
|
//Last seen RF transmissions on XLX, to implement relinking.
|
||||||
unsigned int xlx1LastSeenTime[0U];
|
std::time_t xlx1LastSeenTime = 0;
|
||||||
unsigned int xlx2LastSeenTime[0U];
|
std::time_t xlx2LastSeenTime = 0;
|
||||||
|
|
||||||
CStopWatch stopWatch;
|
CStopWatch stopWatch;
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
@@ -409,9 +413,17 @@ int CDMRGateway::run()
|
|||||||
|
|
||||||
m_xlx1Reflector = 4000U;
|
m_xlx1Reflector = 4000U;
|
||||||
m_xlx1Connected = false;
|
m_xlx1Connected = false;
|
||||||
} else if (xlx1LastSeenTime - time(NULL) > 600U) {
|
} else if (xlx1LastSeenTime && (unsigned(time(NULL)) - unsigned(xlx1LastSeenTime)) > (m_xlx1Relink*60) && m_xlx1Reflector != m_xlx1Startup) {
|
||||||
writeXLXLink(m_xlx1Id,m_xlx1Startup,m_xlxNetwork1);
|
writeXLXLink(m_xlx1Id,m_xlx1Startup,m_xlxNetwork1);
|
||||||
LogMessage("XLX-1, Re-linking to startup reflector %u due to inactivity timeout", m_xlx1Startup);
|
LogMessage("XLX-1, Re-linking to startup reflector %u due to RF inactivity timeout (%u minutes)", m_xlx1Startup, m_xlx1Relink);
|
||||||
|
m_xlx1Reflector = m_xlx1Startup;
|
||||||
|
if (voice1 != NULL) {
|
||||||
|
if (m_xlx1Reflector == 4000U) {
|
||||||
|
voice1->unlinked();
|
||||||
|
} else {
|
||||||
|
voice1->linkedTo(m_xlx1Startup);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,9 +448,18 @@ int CDMRGateway::run()
|
|||||||
|
|
||||||
m_xlx2Reflector = 4000U;
|
m_xlx2Reflector = 4000U;
|
||||||
m_xlx2Connected = false;
|
m_xlx2Connected = false;
|
||||||
} else if (xlx2LastSeenTime - time(NULL) > 600U) {
|
} else if (xlx2LastSeenTime && (unsigned(time(NULL)) - unsigned(xlx2LastSeenTime)) > (m_xlx2Relink*60) && m_xlx2Reflector != m_xlx2Startup) {
|
||||||
writeXLXLink(m_xlx2Id,m_xlx1Startup,m_xlxNetwork2);
|
writeXLXLink(m_xlx2Id,m_xlx2Startup,m_xlxNetwork2);
|
||||||
LogMessage("XLX-2, Re-linking to startup reflector %u due to inactivity timeout", m_xlx2Startup);
|
LogMessage("XLX-2, Re-linking to startup reflector %u due to RF inactivity timeout (%u minutes)", m_xlx2Startup, m_xlx2Relink);
|
||||||
|
m_xlx2Reflector = m_xlx2Startup;
|
||||||
|
if (voice1 != NULL) {
|
||||||
|
if (m_xlx1Reflector == 4000U) {
|
||||||
|
voice1->unlinked();
|
||||||
|
} else {
|
||||||
|
voice1->linkedTo(m_xlx2Startup);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,6 +512,7 @@ int CDMRGateway::run()
|
|||||||
if (dstId != 5000U ) {
|
if (dstId != 5000U ) {
|
||||||
writeXLXLink(srcId, dstId, m_xlxNetwork1);
|
writeXLXLink(srcId, dstId, m_xlxNetwork1);
|
||||||
m_xlx1Reflector = dstId;
|
m_xlx1Reflector = dstId;
|
||||||
|
xlx1LastSeenTime = time(NULL);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -532,6 +554,7 @@ int CDMRGateway::run()
|
|||||||
if (dstId != 5000U ) {
|
if (dstId != 5000U ) {
|
||||||
writeXLXLink(srcId, dstId, m_xlxNetwork2);
|
writeXLXLink(srcId, dstId, m_xlxNetwork2);
|
||||||
m_xlx2Reflector = dstId;
|
m_xlx2Reflector = dstId;
|
||||||
|
xlx2LastSeenTime = time(NULL);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1180,12 +1203,15 @@ bool CDMRGateway::createXLXNetwork1()
|
|||||||
m_xlx1TG = m_conf.getXLXNetwork1TG();
|
m_xlx1TG = m_conf.getXLXNetwork1TG();
|
||||||
m_xlx1Base = m_conf.getXLXNetwork1Base();
|
m_xlx1Base = m_conf.getXLXNetwork1Base();
|
||||||
m_xlx1Startup = m_conf.getXLXNetwork1Startup();
|
m_xlx1Startup = m_conf.getXLXNetwork1Startup();
|
||||||
|
m_xlx1Relink = m_conf.getXLXNetwork1Relink();
|
||||||
|
|
||||||
LogInfo(" Slot: %u", m_xlx1Slot);
|
LogInfo(" Slot: %u", m_xlx1Slot);
|
||||||
LogInfo(" TG: %u", m_xlx1TG);
|
LogInfo(" TG: %u", m_xlx1TG);
|
||||||
LogInfo(" Base: %u", m_xlx1Base);
|
LogInfo(" Base: %u", m_xlx1Base);
|
||||||
if (m_xlx1Startup != 4000U)
|
if (m_xlx1Startup != 4000U)
|
||||||
LogInfo(" Startup: %u", m_xlx1Startup);
|
LogInfo(" Startup: %u", m_xlx1Startup);
|
||||||
|
if (m_xlx1Relink)
|
||||||
|
LogInfo(" Relink: %u minutes", m_xlx1Relink);
|
||||||
|
|
||||||
m_rpt1Rewrite = new CRewriteTG("XLX-1", XLX_SLOT, XLX_TG, m_xlx1Slot, m_xlx1TG, 1U);
|
m_rpt1Rewrite = new CRewriteTG("XLX-1", XLX_SLOT, XLX_TG, m_xlx1Slot, m_xlx1TG, 1U);
|
||||||
m_xlx1Rewrite = new CRewriteTG("XLX-1", m_xlx1Slot, m_xlx1TG, XLX_SLOT, XLX_TG, 1U);
|
m_xlx1Rewrite = new CRewriteTG("XLX-1", m_xlx1Slot, m_xlx1TG, XLX_SLOT, XLX_TG, 1U);
|
||||||
@@ -1238,12 +1264,15 @@ bool CDMRGateway::createXLXNetwork2()
|
|||||||
m_xlx2TG = m_conf.getXLXNetwork2TG();
|
m_xlx2TG = m_conf.getXLXNetwork2TG();
|
||||||
m_xlx2Base = m_conf.getXLXNetwork2Base();
|
m_xlx2Base = m_conf.getXLXNetwork2Base();
|
||||||
m_xlx2Startup = m_conf.getXLXNetwork2Startup();
|
m_xlx2Startup = m_conf.getXLXNetwork2Startup();
|
||||||
|
m_xlx2Relink = m_conf.getXLXNetwork2Relink();
|
||||||
|
|
||||||
LogInfo(" Slot: %u", m_xlx2Slot);
|
LogInfo(" Slot: %u", m_xlx2Slot);
|
||||||
LogInfo(" TG: %u", m_xlx2TG);
|
LogInfo(" TG: %u", m_xlx2TG);
|
||||||
LogInfo(" Base: %u", m_xlx2Base);
|
LogInfo(" Base: %u", m_xlx2Base);
|
||||||
if (m_xlx2Startup != 4000U)
|
if (m_xlx2Startup != 4000U)
|
||||||
LogInfo(" Startup: %u", m_xlx2Startup);
|
LogInfo(" Startup: %u", m_xlx2Startup);
|
||||||
|
if (m_xlx2Relink)
|
||||||
|
LogInfo(" Relink: %u minutes", m_xlx2Relink);
|
||||||
|
|
||||||
m_rpt2Rewrite = new CRewriteTG("XLX-2", XLX_SLOT, XLX_TG, m_xlx2Slot, m_xlx2TG, 1U);
|
m_rpt2Rewrite = new CRewriteTG("XLX-2", XLX_SLOT, XLX_TG, m_xlx2Slot, m_xlx2TG, 1U);
|
||||||
m_xlx2Rewrite = new CRewriteTG("XLX-2", m_xlx2Slot, m_xlx2TG, XLX_SLOT, XLX_TG, 1U);
|
m_xlx2Rewrite = new CRewriteTG("XLX-2", m_xlx2Slot, m_xlx2TG, XLX_SLOT, XLX_TG, 1U);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ private:
|
|||||||
unsigned int m_xlx1TG;
|
unsigned int m_xlx1TG;
|
||||||
unsigned int m_xlx1Base;
|
unsigned int m_xlx1Base;
|
||||||
unsigned int m_xlx1Startup;
|
unsigned int m_xlx1Startup;
|
||||||
|
unsigned int m_xlx1Relink;
|
||||||
bool m_xlx1Connected;
|
bool m_xlx1Connected;
|
||||||
CRewriteTG* m_rpt1Rewrite;
|
CRewriteTG* m_rpt1Rewrite;
|
||||||
CRewriteTG* m_xlx1Rewrite;
|
CRewriteTG* m_xlx1Rewrite;
|
||||||
@@ -58,6 +59,7 @@ private:
|
|||||||
unsigned int m_xlx2TG;
|
unsigned int m_xlx2TG;
|
||||||
unsigned int m_xlx2Base;
|
unsigned int m_xlx2Base;
|
||||||
unsigned int m_xlx2Startup;
|
unsigned int m_xlx2Startup;
|
||||||
|
unsigned int m_xlx2Relink;
|
||||||
bool m_xlx2Connected;
|
bool m_xlx2Connected;
|
||||||
CRewriteTG* m_rpt2Rewrite;
|
CRewriteTG* m_rpt2Rewrite;
|
||||||
CRewriteTG* m_xlx2Rewrite;
|
CRewriteTG* m_xlx2Rewrite;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ Slot=1
|
|||||||
TG=6
|
TG=6
|
||||||
Base=64000
|
Base=64000
|
||||||
Startup=4005
|
Startup=4005
|
||||||
|
Relink=10
|
||||||
Password=passw0rd
|
Password=passw0rd
|
||||||
Debug=0
|
Debug=0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user