mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-20 21:25:37 +08:00
Allow for a startup XLX reflector.
This commit is contained in:
16
Conf.cpp
16
Conf.cpp
@@ -90,6 +90,7 @@ m_xlxNetwork1Password(),
|
||||
m_xlxNetwork1Slot(1U),
|
||||
m_xlxNetwork1TG(8U),
|
||||
m_xlxNetwork1Base(84000U),
|
||||
m_xlxNetwork1Startup(4000U),
|
||||
m_xlxNetwork1Options(),
|
||||
m_xlxNetwork1Debug(false),
|
||||
m_xlxNetwork2Enabled(false),
|
||||
@@ -101,6 +102,7 @@ m_xlxNetwork2Password(),
|
||||
m_xlxNetwork2Slot(1U),
|
||||
m_xlxNetwork2TG(7U),
|
||||
m_xlxNetwork2Base(74000U),
|
||||
m_xlxNetwork2Startup(4000U),
|
||||
m_xlxNetwork2Options(),
|
||||
m_xlxNetwork2Debug(false)
|
||||
{
|
||||
@@ -204,6 +206,8 @@ bool CConf::read()
|
||||
m_xlxNetwork1TG = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Base") == 0)
|
||||
m_xlxNetwork1Base = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Startup") == 0)
|
||||
m_xlxNetwork1Startup = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Options") == 0)
|
||||
m_xlxNetwork1Options = value;
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
@@ -227,6 +231,8 @@ bool CConf::read()
|
||||
m_xlxNetwork2TG = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Base") == 0)
|
||||
m_xlxNetwork2Base = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Startup") == 0)
|
||||
m_xlxNetwork2Startup = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Options") == 0)
|
||||
m_xlxNetwork2Options = value;
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
@@ -513,6 +519,11 @@ unsigned int CConf::getXLXNetwork1Base() const
|
||||
return m_xlxNetwork1Base;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork1Startup() const
|
||||
{
|
||||
return m_xlxNetwork1Startup;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetwork1Password() const
|
||||
{
|
||||
return m_xlxNetwork1Password;
|
||||
@@ -568,6 +579,11 @@ unsigned int CConf::getXLXNetwork2Base() const
|
||||
return m_xlxNetwork2Base;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2Startup() const
|
||||
{
|
||||
return m_xlxNetwork2Startup;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetwork2Password() const
|
||||
{
|
||||
return m_xlxNetwork2Password;
|
||||
|
||||
4
Conf.h
4
Conf.h
@@ -123,6 +123,7 @@ public:
|
||||
unsigned int getXLXNetwork1Slot() const;
|
||||
unsigned int getXLXNetwork1TG() const;
|
||||
unsigned int getXLXNetwork1Base() const;
|
||||
unsigned int getXLXNetwork1Startup() const;
|
||||
std::string getXLXNetwork1Options() const;
|
||||
bool getXLXNetwork1Debug() const;
|
||||
|
||||
@@ -136,6 +137,7 @@ public:
|
||||
unsigned int getXLXNetwork2Slot() const;
|
||||
unsigned int getXLXNetwork2TG() const;
|
||||
unsigned int getXLXNetwork2Base() const;
|
||||
unsigned int getXLXNetwork2Startup() const;
|
||||
std::string getXLXNetwork2Options() const;
|
||||
bool getXLXNetwork2Debug() const;
|
||||
|
||||
@@ -197,6 +199,7 @@ private:
|
||||
unsigned int m_xlxNetwork1Slot;
|
||||
unsigned int m_xlxNetwork1TG;
|
||||
unsigned int m_xlxNetwork1Base;
|
||||
unsigned int m_xlxNetwork1Startup;
|
||||
std::string m_xlxNetwork1Options;
|
||||
bool m_xlxNetwork1Debug;
|
||||
|
||||
@@ -209,6 +212,7 @@ private:
|
||||
unsigned int m_xlxNetwork2Slot;
|
||||
unsigned int m_xlxNetwork2TG;
|
||||
unsigned int m_xlxNetwork2Base;
|
||||
unsigned int m_xlxNetwork2Startup;
|
||||
std::string m_xlxNetwork2Options;
|
||||
bool m_xlxNetwork2Debug;
|
||||
};
|
||||
|
||||
@@ -132,16 +132,22 @@ m_dmrNetwork1(NULL),
|
||||
m_dmrNetwork2(NULL),
|
||||
m_xlxNetwork1(NULL),
|
||||
m_xlxNetwork2(NULL),
|
||||
m_xlx1Id(0U),
|
||||
m_xlx1Reflector(4000U),
|
||||
m_xlx1Slot(0U),
|
||||
m_xlx1TG(0U),
|
||||
m_xlx1Base(0U),
|
||||
m_xlx1Startup(4000U),
|
||||
m_xlx1Connected(false),
|
||||
m_rpt1Rewrite(NULL),
|
||||
m_xlx1Rewrite(NULL),
|
||||
m_xlx2Id(0U),
|
||||
m_xlx2Reflector(4000U),
|
||||
m_xlx2Slot(0U),
|
||||
m_xlx2TG(0U),
|
||||
m_xlx2Base(0U),
|
||||
m_xlx2Startup(4000U),
|
||||
m_xlx2Connected(false),
|
||||
m_rpt2Rewrite(NULL),
|
||||
m_xlx2Rewrite(NULL),
|
||||
m_dmr1NetRewrites(),
|
||||
@@ -352,6 +358,46 @@ int CDMRGateway::run()
|
||||
bool changed = false;
|
||||
|
||||
while (!m_killed) {
|
||||
if (m_xlxNetwork1 != NULL) {
|
||||
bool connected = m_xlxNetwork1->isConnected();
|
||||
if (connected && !m_xlx1Connected) {
|
||||
if (m_xlx1Startup != 4000U) {
|
||||
writeXLXLink(m_xlx1Id, m_xlx1Startup, m_xlxNetwork1);
|
||||
if (voice1 != NULL)
|
||||
voice1->linkedTo(m_xlx1Startup);
|
||||
}
|
||||
|
||||
m_xlx1Reflector = m_xlx1Startup;
|
||||
m_xlx1Connected = true;
|
||||
} else if (!connected && m_xlx1Connected) {
|
||||
if (m_xlx1Reflector != 4000U && voice1 != NULL)
|
||||
voice1->unlinked();
|
||||
|
||||
m_xlx1Reflector = 4000U;
|
||||
m_xlx1Connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_xlxNetwork2 != NULL) {
|
||||
bool connected = m_xlxNetwork2->isConnected();
|
||||
if (connected && !m_xlx2Connected) {
|
||||
if (m_xlx2Startup != 4000U) {
|
||||
writeXLXLink(m_xlx2Id, m_xlx2Startup, m_xlxNetwork2);
|
||||
if (voice2 != NULL)
|
||||
voice2->linkedTo(m_xlx2Startup);
|
||||
}
|
||||
|
||||
m_xlx2Reflector = m_xlx2Startup;
|
||||
m_xlx2Connected = true;
|
||||
} else if (!connected && m_xlx2Connected) {
|
||||
if (m_xlx2Reflector != 4000U && voice2 != NULL)
|
||||
voice2->unlinked();
|
||||
|
||||
m_xlx2Reflector = 4000U;
|
||||
m_xlx2Connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
CDMRData data;
|
||||
|
||||
bool ret = m_repeater->read(data);
|
||||
@@ -932,15 +978,15 @@ bool CDMRGateway::createXLXNetwork1()
|
||||
std::string address = m_conf.getXLXNetwork1Address();
|
||||
unsigned int port = m_conf.getXLXNetwork1Port();
|
||||
unsigned int local = m_conf.getXLXNetwork1Local();
|
||||
unsigned int id = m_conf.getXLXNetwork1Id();
|
||||
m_xlx1Id = m_conf.getXLXNetwork1Id();
|
||||
std::string password = m_conf.getXLXNetwork1Password();
|
||||
bool debug = m_conf.getXLXNetwork1Debug();
|
||||
|
||||
if (id == 0U)
|
||||
id = m_repeater->getId();
|
||||
if (m_xlx1Id == 0U)
|
||||
m_xlx1Id = m_repeater->getId();
|
||||
|
||||
LogInfo("XLX Network 1 Parameters");
|
||||
LogInfo(" Id: %u", id);
|
||||
LogInfo(" Id: %u", m_xlx1Id);
|
||||
LogInfo(" Address: %s", address.c_str());
|
||||
LogInfo(" Port: %u", port);
|
||||
if (local > 0U)
|
||||
@@ -948,7 +994,7 @@ bool CDMRGateway::createXLXNetwork1()
|
||||
else
|
||||
LogInfo(" Local: random");
|
||||
|
||||
m_xlxNetwork1 = new CDMRNetwork(address, port, local, id, password, "XLX-1", debug);
|
||||
m_xlxNetwork1 = new CDMRNetwork(address, port, local, m_xlx1Id, password, "XLX-1", debug);
|
||||
|
||||
std::string options = m_conf.getXLXNetwork1Options();
|
||||
if (!options.empty()) {
|
||||
@@ -968,13 +1014,16 @@ bool CDMRGateway::createXLXNetwork1()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_xlx1Slot = m_conf.getXLXNetwork1Slot();
|
||||
m_xlx1TG = m_conf.getXLXNetwork1TG();
|
||||
m_xlx1Base = m_conf.getXLXNetwork1Base();
|
||||
m_xlx1Slot = m_conf.getXLXNetwork1Slot();
|
||||
m_xlx1TG = m_conf.getXLXNetwork1TG();
|
||||
m_xlx1Base = m_conf.getXLXNetwork1Base();
|
||||
m_xlx1Startup = m_conf.getXLXNetwork1Startup();
|
||||
|
||||
LogInfo(" Slot: %u", m_xlx1Slot);
|
||||
LogInfo(" TG: %u", m_xlx1TG);
|
||||
LogInfo(" Base: %u", m_xlx1Base);
|
||||
if (m_xlx1Startup != 4000U)
|
||||
LogInfo(" Startup: %u", m_xlx1Startup);
|
||||
|
||||
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);
|
||||
@@ -987,15 +1036,15 @@ bool CDMRGateway::createXLXNetwork2()
|
||||
std::string address = m_conf.getXLXNetwork2Address();
|
||||
unsigned int port = m_conf.getXLXNetwork2Port();
|
||||
unsigned int local = m_conf.getXLXNetwork2Local();
|
||||
unsigned int id = m_conf.getXLXNetwork2Id();
|
||||
m_xlx2Id = m_conf.getXLXNetwork2Id();
|
||||
std::string password = m_conf.getXLXNetwork2Password();
|
||||
bool debug = m_conf.getXLXNetwork2Debug();
|
||||
|
||||
if (id == 0U)
|
||||
id = m_repeater->getId();
|
||||
if (m_xlx2Id == 0U)
|
||||
m_xlx2Id = m_repeater->getId();
|
||||
|
||||
LogInfo("XLX Network 2 Parameters");
|
||||
LogInfo(" Id: %u", id);
|
||||
LogInfo(" Id: %u", m_xlx2Id);
|
||||
LogInfo(" Address: %s", address.c_str());
|
||||
LogInfo(" Port: %u", port);
|
||||
if (local > 0U)
|
||||
@@ -1003,7 +1052,7 @@ bool CDMRGateway::createXLXNetwork2()
|
||||
else
|
||||
LogInfo(" Local: random");
|
||||
|
||||
m_xlxNetwork2 = new CDMRNetwork(address, port, local, id, password, "XLX-2", debug);
|
||||
m_xlxNetwork2 = new CDMRNetwork(address, port, local, m_xlx2Id, password, "XLX-2", debug);
|
||||
|
||||
std::string options = m_conf.getXLXNetwork2Options();
|
||||
if (!options.empty()) {
|
||||
@@ -1023,13 +1072,16 @@ bool CDMRGateway::createXLXNetwork2()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_xlx2Slot = m_conf.getXLXNetwork2Slot();
|
||||
m_xlx2TG = m_conf.getXLXNetwork2TG();
|
||||
m_xlx2Base = m_conf.getXLXNetwork2Base();
|
||||
m_xlx2Slot = m_conf.getXLXNetwork2Slot();
|
||||
m_xlx2TG = m_conf.getXLXNetwork2TG();
|
||||
m_xlx2Base = m_conf.getXLXNetwork2Base();
|
||||
m_xlx2Startup = m_conf.getXLXNetwork2Startup();
|
||||
|
||||
LogInfo(" Slot: %u", m_xlx2Slot);
|
||||
LogInfo(" TG: %u", m_xlx2TG);
|
||||
LogInfo(" Base: %u", m_xlx2Base);
|
||||
if (m_xlx2Startup != 4000U)
|
||||
LogInfo(" Startup: %u", m_xlx2Startup);
|
||||
|
||||
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);
|
||||
|
||||
@@ -43,16 +43,22 @@ private:
|
||||
CDMRNetwork* m_dmrNetwork2;
|
||||
CDMRNetwork* m_xlxNetwork1;
|
||||
CDMRNetwork* m_xlxNetwork2;
|
||||
unsigned int m_xlx1Id;
|
||||
unsigned int m_xlx1Reflector;
|
||||
unsigned int m_xlx1Slot;
|
||||
unsigned int m_xlx1TG;
|
||||
unsigned int m_xlx1Base;
|
||||
unsigned int m_xlx1Startup;
|
||||
bool m_xlx1Connected;
|
||||
CRewriteTG* m_rpt1Rewrite;
|
||||
CRewriteTG* m_xlx1Rewrite;
|
||||
unsigned int m_xlx2Id;
|
||||
unsigned int m_xlx2Reflector;
|
||||
unsigned int m_xlx2Slot;
|
||||
unsigned int m_xlx2TG;
|
||||
unsigned int m_xlx2Base;
|
||||
unsigned int m_xlx2Startup;
|
||||
bool m_xlx2Connected;
|
||||
CRewriteTG* m_rpt2Rewrite;
|
||||
CRewriteTG* m_xlx2Rewrite;
|
||||
std::vector<IRewrite*> m_dmr1NetRewrites;
|
||||
|
||||
@@ -28,6 +28,7 @@ Port=62030
|
||||
Slot=1
|
||||
TG=6
|
||||
Base=64000
|
||||
Startup=4005
|
||||
Password=passw0rd
|
||||
Debug=0
|
||||
|
||||
|
||||
@@ -258,6 +258,11 @@ bool CDMRNetwork::writeTalkerAlias(const unsigned char* data, unsigned int lengt
|
||||
return write(buffer, length);
|
||||
}
|
||||
|
||||
bool CDMRNetwork::isConnected() const
|
||||
{
|
||||
return m_status == RUNNING;
|
||||
}
|
||||
|
||||
void CDMRNetwork::close()
|
||||
{
|
||||
LogMessage("%s, Closing DMR Network", m_name);
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
|
||||
void clock(unsigned int ms);
|
||||
|
||||
bool isConnected() const;
|
||||
|
||||
void close();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user