mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-27 01:06:12 +08:00
Allow for a second XLX reflector.
This commit is contained in:
188
Conf.cpp
188
Conf.cpp
@@ -33,7 +33,8 @@ enum SECTION {
|
||||
SECTION_VOICE,
|
||||
SECTION_DMR_NETWORK_1,
|
||||
SECTION_DMR_NETWORK_2,
|
||||
SECTION_XLX_NETWORK
|
||||
SECTION_XLX_NETWORK_1,
|
||||
SECTION_XLX_NETWORK_2
|
||||
};
|
||||
|
||||
CConf::CConf(const std::string& file) :
|
||||
@@ -76,17 +77,28 @@ m_dmrNetwork2TGRewrites(),
|
||||
m_dmrNetwork2PCRewrites(),
|
||||
m_dmrNetwork2TypeRewrites(),
|
||||
m_dmrNetwork2SrcRewrites(),
|
||||
m_xlxNetworkEnabled(false),
|
||||
m_xlxNetworkId(0U),
|
||||
m_xlxNetworkAddress(),
|
||||
m_xlxNetworkPort(0U),
|
||||
m_xlxNetworkLocal(0U),
|
||||
m_xlxNetworkPassword(),
|
||||
m_xlxNetworkSlot(2U),
|
||||
m_xlxNetworkTG(9U),
|
||||
m_xlxNetworkBase(4000U),
|
||||
m_xlxNetworkOptions(),
|
||||
m_xlxNetworkDebug(false)
|
||||
m_xlxNetwork1Enabled(false),
|
||||
m_xlxNetwork1Id(0U),
|
||||
m_xlxNetwork1Address(),
|
||||
m_xlxNetwork1Port(0U),
|
||||
m_xlxNetwork1Local(0U),
|
||||
m_xlxNetwork1Password(),
|
||||
m_xlxNetwork1Slot(1U),
|
||||
m_xlxNetwork1TG(8U),
|
||||
m_xlxNetwork1Base(84000U),
|
||||
m_xlxNetwork1Options(),
|
||||
m_xlxNetwork1Debug(false),
|
||||
m_xlxNetwork2Enabled(false),
|
||||
m_xlxNetwork2Id(0U),
|
||||
m_xlxNetwork2Address(),
|
||||
m_xlxNetwork2Port(0U),
|
||||
m_xlxNetwork2Local(0U),
|
||||
m_xlxNetwork2Password(),
|
||||
m_xlxNetwork2Slot(1U),
|
||||
m_xlxNetwork2TG(7U),
|
||||
m_xlxNetwork2Base(74000U),
|
||||
m_xlxNetwork2Options(),
|
||||
m_xlxNetwork2Debug(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -116,8 +128,10 @@ bool CConf::read()
|
||||
section = SECTION_LOG;
|
||||
else if (::strncmp(buffer, "[Voice]", 7U) == 0)
|
||||
section = SECTION_VOICE;
|
||||
else if (::strncmp(buffer, "[XLX Network]", 13U) == 0)
|
||||
section = SECTION_XLX_NETWORK;
|
||||
else if (::strncmp(buffer, "[XLX Network 1]", 15U) == 0)
|
||||
section = SECTION_XLX_NETWORK_1;
|
||||
else if (::strncmp(buffer, "[XLX Network 2]", 15U) == 0)
|
||||
section = SECTION_XLX_NETWORK_2;
|
||||
else if (::strncmp(buffer, "[DMR Network 1]", 15U) == 0)
|
||||
section = SECTION_DMR_NETWORK_1;
|
||||
else if (::strncmp(buffer, "[DMR Network 2]", 15U) == 0)
|
||||
@@ -167,29 +181,52 @@ bool CConf::read()
|
||||
m_voiceLanguage = value;
|
||||
else if (::strcmp(key, "Directory") == 0)
|
||||
m_voiceDirectory = value;
|
||||
} else if (section == SECTION_XLX_NETWORK) {
|
||||
} else if (section == SECTION_XLX_NETWORK_1) {
|
||||
if (::strcmp(key, "Enabled") == 0)
|
||||
m_xlxNetworkEnabled = ::atoi(value) == 1;
|
||||
m_xlxNetwork1Enabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Id") == 0)
|
||||
m_xlxNetworkId = (unsigned int)::atoi(value);
|
||||
m_xlxNetwork1Id = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Address") == 0)
|
||||
m_xlxNetworkAddress = value;
|
||||
m_xlxNetwork1Address = value;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_xlxNetworkPort = (unsigned int)::atoi(value);
|
||||
m_xlxNetwork1Port = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Local") == 0)
|
||||
m_xlxNetworkLocal = (unsigned int)::atoi(value);
|
||||
m_xlxNetwork1Local = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Password") == 0)
|
||||
m_xlxNetworkPassword = value;
|
||||
m_xlxNetwork1Password = value;
|
||||
else if (::strcmp(key, "Slot") == 0)
|
||||
m_xlxNetworkSlot = (unsigned int)::atoi(value);
|
||||
m_xlxNetwork1Slot = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "TG") == 0)
|
||||
m_xlxNetworkTG = (unsigned int)::atoi(value);
|
||||
m_xlxNetwork1TG = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Base") == 0)
|
||||
m_xlxNetworkBase = (unsigned int)::atoi(value);
|
||||
m_xlxNetwork1Base = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Options") == 0)
|
||||
m_xlxNetworkOptions = value;
|
||||
m_xlxNetwork1Options = value;
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_xlxNetworkDebug = ::atoi(value) == 1;
|
||||
m_xlxNetwork1Debug = ::atoi(value) == 1;
|
||||
} else if (section == SECTION_XLX_NETWORK_2) {
|
||||
if (::strcmp(key, "Enabled") == 0)
|
||||
m_xlxNetwork2Enabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Id") == 0)
|
||||
m_xlxNetwork2Id = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Address") == 0)
|
||||
m_xlxNetwork2Address = value;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_xlxNetwork2Port = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Local") == 0)
|
||||
m_xlxNetwork2Local = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Password") == 0)
|
||||
m_xlxNetwork2Password = value;
|
||||
else if (::strcmp(key, "Slot") == 0)
|
||||
m_xlxNetwork2Slot = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "TG") == 0)
|
||||
m_xlxNetwork2TG = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Base") == 0)
|
||||
m_xlxNetwork2Base = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Options") == 0)
|
||||
m_xlxNetwork2Options = value;
|
||||
else if (::strcmp(key, "Debug") == 0)
|
||||
m_xlxNetwork2Debug = ::atoi(value) == 1;
|
||||
} else if (section == SECTION_DMR_NETWORK_1) {
|
||||
if (::strcmp(key, "Enabled") == 0)
|
||||
m_dmrNetwork1Enabled = ::atoi(value) == 1;
|
||||
@@ -420,59 +457,114 @@ std::string CConf::getVoiceDirectory() const
|
||||
return m_voiceDirectory;
|
||||
}
|
||||
|
||||
bool CConf::getXLXNetworkEnabled() const
|
||||
bool CConf::getXLXNetwork1Enabled() const
|
||||
{
|
||||
return m_xlxNetworkEnabled;
|
||||
return m_xlxNetwork1Enabled;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetworkId() const
|
||||
unsigned int CConf::getXLXNetwork1Id() const
|
||||
{
|
||||
return m_xlxNetworkId;
|
||||
return m_xlxNetwork1Id;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetworkAddress() const
|
||||
std::string CConf::getXLXNetwork1Address() const
|
||||
{
|
||||
return m_xlxNetworkAddress;
|
||||
return m_xlxNetwork1Address;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetworkPort() const
|
||||
unsigned int CConf::getXLXNetwork1Port() const
|
||||
{
|
||||
return m_xlxNetworkPort;
|
||||
return m_xlxNetwork1Port;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetworkLocal() const
|
||||
unsigned int CConf::getXLXNetwork1Local() const
|
||||
{
|
||||
return m_xlxNetworkLocal;
|
||||
return m_xlxNetwork1Local;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetworkSlot() const
|
||||
unsigned int CConf::getXLXNetwork1Slot() const
|
||||
{
|
||||
return m_xlxNetworkSlot;
|
||||
return m_xlxNetwork1Slot;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetworkTG() const
|
||||
unsigned int CConf::getXLXNetwork1TG() const
|
||||
{
|
||||
return m_xlxNetworkTG;
|
||||
return m_xlxNetwork1TG;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetworkBase() const
|
||||
unsigned int CConf::getXLXNetwork1Base() const
|
||||
{
|
||||
return m_xlxNetworkBase;
|
||||
return m_xlxNetwork1Base;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetworkPassword() const
|
||||
std::string CConf::getXLXNetwork1Password() const
|
||||
{
|
||||
return m_xlxNetworkPassword;
|
||||
return m_xlxNetwork1Password;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetworkOptions() const
|
||||
std::string CConf::getXLXNetwork1Options() const
|
||||
{
|
||||
return m_xlxNetworkOptions;
|
||||
return m_xlxNetwork1Options;
|
||||
}
|
||||
|
||||
bool CConf::getXLXNetworkDebug() const
|
||||
bool CConf::getXLXNetwork1Debug() const
|
||||
{
|
||||
return m_xlxNetworkDebug;
|
||||
return m_xlxNetwork1Debug;
|
||||
}
|
||||
|
||||
bool CConf::getXLXNetwork2Enabled() const
|
||||
{
|
||||
return m_xlxNetwork2Enabled;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2Id() const
|
||||
{
|
||||
return m_xlxNetwork2Id;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetwork2Address() const
|
||||
{
|
||||
return m_xlxNetwork2Address;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2Port() const
|
||||
{
|
||||
return m_xlxNetwork2Port;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2Local() const
|
||||
{
|
||||
return m_xlxNetwork2Local;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2Slot() const
|
||||
{
|
||||
return m_xlxNetwork2Slot;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2TG() const
|
||||
{
|
||||
return m_xlxNetwork2TG;
|
||||
}
|
||||
|
||||
unsigned int CConf::getXLXNetwork2Base() const
|
||||
{
|
||||
return m_xlxNetwork2Base;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetwork2Password() const
|
||||
{
|
||||
return m_xlxNetwork2Password;
|
||||
}
|
||||
|
||||
std::string CConf::getXLXNetwork2Options() const
|
||||
{
|
||||
return m_xlxNetwork2Options;
|
||||
}
|
||||
|
||||
bool CConf::getXLXNetwork2Debug() const
|
||||
{
|
||||
return m_xlxNetwork2Debug;
|
||||
}
|
||||
|
||||
bool CConf::getDMRNetwork1Enabled() const
|
||||
|
||||
71
Conf.h
71
Conf.h
@@ -109,18 +109,31 @@ public:
|
||||
std::vector<CTypeRewriteStruct> getDMRNetwork2TypeRewrites() const;
|
||||
std::vector<CSrcRewriteStruct> getDMRNetwork2SrcRewrites() const;
|
||||
|
||||
// The XLX Network section
|
||||
bool getXLXNetworkEnabled() const;
|
||||
unsigned int getXLXNetworkId() const;
|
||||
std::string getXLXNetworkAddress() const;
|
||||
unsigned int getXLXNetworkPort() const;
|
||||
unsigned int getXLXNetworkLocal() const;
|
||||
std::string getXLXNetworkPassword() const;
|
||||
unsigned int getXLXNetworkSlot() const;
|
||||
unsigned int getXLXNetworkTG() const;
|
||||
unsigned int getXLXNetworkBase() const;
|
||||
std::string getXLXNetworkOptions() const;
|
||||
bool getXLXNetworkDebug() const;
|
||||
// The XLX Network 1 section
|
||||
bool getXLXNetwork1Enabled() const;
|
||||
unsigned int getXLXNetwork1Id() const;
|
||||
std::string getXLXNetwork1Address() const;
|
||||
unsigned int getXLXNetwork1Port() const;
|
||||
unsigned int getXLXNetwork1Local() const;
|
||||
std::string getXLXNetwork1Password() const;
|
||||
unsigned int getXLXNetwork1Slot() const;
|
||||
unsigned int getXLXNetwork1TG() const;
|
||||
unsigned int getXLXNetwork1Base() const;
|
||||
std::string getXLXNetwork1Options() const;
|
||||
bool getXLXNetwork1Debug() const;
|
||||
|
||||
// The XLX Network 2 section
|
||||
bool getXLXNetwork2Enabled() const;
|
||||
unsigned int getXLXNetwork2Id() const;
|
||||
std::string getXLXNetwork2Address() const;
|
||||
unsigned int getXLXNetwork2Port() const;
|
||||
unsigned int getXLXNetwork2Local() const;
|
||||
std::string getXLXNetwork2Password() const;
|
||||
unsigned int getXLXNetwork2Slot() const;
|
||||
unsigned int getXLXNetwork2TG() const;
|
||||
unsigned int getXLXNetwork2Base() const;
|
||||
std::string getXLXNetwork2Options() const;
|
||||
bool getXLXNetwork2Debug() const;
|
||||
|
||||
private:
|
||||
std::string m_file;
|
||||
@@ -167,17 +180,29 @@ private:
|
||||
std::vector<CTypeRewriteStruct> m_dmrNetwork2TypeRewrites;
|
||||
std::vector<CSrcRewriteStruct> m_dmrNetwork2SrcRewrites;
|
||||
|
||||
bool m_xlxNetworkEnabled;
|
||||
unsigned int m_xlxNetworkId;
|
||||
std::string m_xlxNetworkAddress;
|
||||
unsigned int m_xlxNetworkPort;
|
||||
unsigned int m_xlxNetworkLocal;
|
||||
std::string m_xlxNetworkPassword;
|
||||
unsigned int m_xlxNetworkSlot;
|
||||
unsigned int m_xlxNetworkTG;
|
||||
unsigned int m_xlxNetworkBase;
|
||||
std::string m_xlxNetworkOptions;
|
||||
bool m_xlxNetworkDebug;
|
||||
bool m_xlxNetwork1Enabled;
|
||||
unsigned int m_xlxNetwork1Id;
|
||||
std::string m_xlxNetwork1Address;
|
||||
unsigned int m_xlxNetwork1Port;
|
||||
unsigned int m_xlxNetwork1Local;
|
||||
std::string m_xlxNetwork1Password;
|
||||
unsigned int m_xlxNetwork1Slot;
|
||||
unsigned int m_xlxNetwork1TG;
|
||||
unsigned int m_xlxNetwork1Base;
|
||||
std::string m_xlxNetwork1Options;
|
||||
bool m_xlxNetwork1Debug;
|
||||
|
||||
bool m_xlxNetwork2Enabled;
|
||||
unsigned int m_xlxNetwork2Id;
|
||||
std::string m_xlxNetwork2Address;
|
||||
unsigned int m_xlxNetwork2Port;
|
||||
unsigned int m_xlxNetwork2Local;
|
||||
std::string m_xlxNetwork2Password;
|
||||
unsigned int m_xlxNetwork2Slot;
|
||||
unsigned int m_xlxNetwork2TG;
|
||||
unsigned int m_xlxNetwork2Base;
|
||||
std::string m_xlxNetwork2Options;
|
||||
bool m_xlxNetwork2Debug;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
359
DMRGateway.cpp
359
DMRGateway.cpp
@@ -60,9 +60,10 @@ static void sigHandler(int signum)
|
||||
|
||||
enum DMRGW_STATUS {
|
||||
DMRGWS_NONE,
|
||||
DMRGWS_NETWORK1,
|
||||
DMRGWS_NETWORK2,
|
||||
DMRGWS_REFLECTOR
|
||||
DMRGWS_DMRNETWORK1,
|
||||
DMRGWS_DMRNETWORK2,
|
||||
DMRGWS_XLXREFLECTOR1,
|
||||
DMRGWS_XLXREFLECTOR2
|
||||
};
|
||||
|
||||
const char* HEADER1 = "This software is for use on amateur radio networks only,";
|
||||
@@ -121,13 +122,20 @@ m_conf(confFile),
|
||||
m_repeater(NULL),
|
||||
m_dmrNetwork1(NULL),
|
||||
m_dmrNetwork2(NULL),
|
||||
m_xlxNetwork(NULL),
|
||||
m_reflector(4000U),
|
||||
m_xlxSlot(0U),
|
||||
m_xlxTG(0U),
|
||||
m_xlxBase(0U),
|
||||
m_rptRewrite(NULL),
|
||||
m_xlxRewrite(NULL),
|
||||
m_xlxNetwork1(NULL),
|
||||
m_xlxNetwork2(NULL),
|
||||
m_xlx1Reflector(4000U),
|
||||
m_xlx1Slot(0U),
|
||||
m_xlx1TG(0U),
|
||||
m_xlx1Base(0U),
|
||||
m_rpt1Rewrite(NULL),
|
||||
m_xlx1Rewrite(NULL),
|
||||
m_xlx2Reflector(4000U),
|
||||
m_xlx2Slot(0U),
|
||||
m_xlx2TG(0U),
|
||||
m_xlx2Base(0U),
|
||||
m_rpt2Rewrite(NULL),
|
||||
m_xlx2Rewrite(NULL),
|
||||
m_dmr1NetRewrites(),
|
||||
m_dmr1RFRewrites(),
|
||||
m_dmr2NetRewrites(),
|
||||
@@ -149,8 +157,10 @@ CDMRGateway::~CDMRGateway()
|
||||
for (std::vector<IRewrite*>::iterator it = m_dmr2RFRewrites.begin(); it != m_dmr2RFRewrites.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
delete m_rptRewrite;
|
||||
delete m_xlxRewrite;
|
||||
delete m_rpt1Rewrite;
|
||||
delete m_xlx1Rewrite;
|
||||
delete m_rpt2Rewrite;
|
||||
delete m_xlx2Rewrite;
|
||||
}
|
||||
|
||||
int CDMRGateway::run()
|
||||
@@ -267,16 +277,23 @@ int CDMRGateway::run()
|
||||
}
|
||||
|
||||
|
||||
if (m_conf.getXLXNetworkEnabled()) {
|
||||
ret = createXLXNetwork();
|
||||
if (m_conf.getXLXNetwork1Enabled()) {
|
||||
ret = createXLXNetwork1();
|
||||
if (!ret)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m_conf.getXLXNetwork2Enabled()) {
|
||||
ret = createXLXNetwork2();
|
||||
if (!ret)
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int timeout = m_conf.getTimeout();
|
||||
|
||||
CVoice* voice = NULL;
|
||||
if (m_conf.getVoiceEnabled() && m_xlxNetwork != NULL) {
|
||||
CVoice* voice1 = NULL;
|
||||
CVoice* voice2 = NULL;
|
||||
if (m_conf.getVoiceEnabled() && (m_xlxNetwork1 != NULL || m_xlxNetwork2 != NULL)) {
|
||||
std::string language = m_conf.getVoiceLanguage();
|
||||
std::string directory = m_conf.getVoiceDirectory();
|
||||
|
||||
@@ -285,12 +302,22 @@ int CDMRGateway::run()
|
||||
LogInfo(" Language: %s", language.c_str());
|
||||
LogInfo(" Directory: %s", directory.c_str());
|
||||
|
||||
voice = new CVoice(directory, language, m_repeater->getId(), m_xlxSlot, m_xlxTG);
|
||||
if (m_xlxNetwork1 != NULL) {
|
||||
voice1 = new CVoice(directory, language, m_repeater->getId(), m_xlx1Slot, m_xlx1TG);
|
||||
bool ret = voice1->open();
|
||||
if (!ret) {
|
||||
delete voice1;
|
||||
voice1 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = voice->open();
|
||||
if (!ret) {
|
||||
delete voice;
|
||||
voice = NULL;
|
||||
if (m_xlxNetwork2 != NULL) {
|
||||
voice2 = new CVoice(directory, language, m_repeater->getId(), m_xlx2Slot, m_xlx2TG);
|
||||
bool ret = voice2->open();
|
||||
if (!ret) {
|
||||
delete voice2;
|
||||
voice2 = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,38 +345,74 @@ int CDMRGateway::run()
|
||||
unsigned int dstId = data.getDstId();
|
||||
FLCO flco = data.getFLCO();
|
||||
|
||||
if (flco == FLCO_GROUP && slotNo == m_xlxSlot && dstId == m_xlxTG) {
|
||||
m_xlxRewrite->process(data);
|
||||
m_xlxNetwork->write(data);
|
||||
status[slotNo] = DMRGWS_REFLECTOR;
|
||||
if (flco == FLCO_GROUP && slotNo == m_xlx1Slot && dstId == m_xlx1TG) {
|
||||
m_xlx1Rewrite->process(data);
|
||||
m_xlxNetwork1->write(data);
|
||||
status[slotNo] = DMRGWS_XLXREFLECTOR1;
|
||||
timer[slotNo]->start();
|
||||
} else if (flco == FLCO_USER_USER && slotNo == m_xlxSlot && dstId >= m_xlxBase && dstId <= (m_xlxBase + 26U)) {
|
||||
} else if (flco == FLCO_GROUP && slotNo == m_xlx2Slot && dstId == m_xlx2TG) {
|
||||
m_xlx2Rewrite->process(data);
|
||||
m_xlxNetwork2->write(data);
|
||||
status[slotNo] = DMRGWS_XLXREFLECTOR2;
|
||||
timer[slotNo]->start();
|
||||
} else if (flco == FLCO_USER_USER && slotNo == m_xlx1Slot && dstId >= m_xlx1Base && dstId <= (m_xlx1Base + 26U)) {
|
||||
dstId += 4000U;
|
||||
dstId -= m_xlxBase;
|
||||
dstId -= m_xlx1Base;
|
||||
|
||||
if (dstId != m_reflector) {
|
||||
if (dstId != m_xlx1Reflector) {
|
||||
if (dstId == 4000U)
|
||||
LogMessage("Unlinking");
|
||||
LogMessage("XLX-1, Unlinking");
|
||||
else
|
||||
LogMessage("Linking to reflector %u", dstId);
|
||||
LogMessage("XLX-1, Linking to reflector %u", dstId);
|
||||
|
||||
m_reflector = dstId;
|
||||
m_xlx1Reflector = dstId;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
data.setSlotNo(XLX_SLOT);
|
||||
m_xlxNetwork->write(data);
|
||||
status[slotNo] = DMRGWS_REFLECTOR;
|
||||
m_xlxNetwork1->write(data);
|
||||
status[slotNo] = DMRGWS_XLXREFLECTOR1;
|
||||
timer[slotNo]->start();
|
||||
|
||||
if (voice != NULL) {
|
||||
if (voice1 != NULL) {
|
||||
unsigned char type = data.getDataType();
|
||||
if (type == DT_TERMINATOR_WITH_LC) {
|
||||
if (changed) {
|
||||
if (m_reflector == 4000U)
|
||||
voice->unlinked();
|
||||
if (m_xlx1Reflector == 4000U)
|
||||
voice1->unlinked();
|
||||
else
|
||||
voice->linkedTo(m_reflector);
|
||||
voice1->linkedTo(m_xlx1Reflector);
|
||||
changed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (flco == FLCO_USER_USER && slotNo == m_xlx2Slot && dstId >= m_xlx2Base && dstId <= (m_xlx2Base + 26U)) {
|
||||
dstId += 4000U;
|
||||
dstId -= m_xlx2Base;
|
||||
|
||||
if (dstId != m_xlx1Reflector) {
|
||||
if (dstId == 4000U)
|
||||
LogMessage("XLX-2, Unlinking");
|
||||
else
|
||||
LogMessage("XLX-2, Linking to reflector %u", dstId);
|
||||
|
||||
m_xlx2Reflector = dstId;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
data.setSlotNo(XLX_SLOT);
|
||||
m_xlxNetwork2->write(data);
|
||||
status[slotNo] = DMRGWS_XLXREFLECTOR2;
|
||||
timer[slotNo]->start();
|
||||
|
||||
if (voice2 != NULL) {
|
||||
unsigned char type = data.getDataType();
|
||||
if (type == DT_TERMINATOR_WITH_LC) {
|
||||
if (changed) {
|
||||
if (m_xlx2Reflector == 4000U)
|
||||
voice2->unlinked();
|
||||
else
|
||||
voice2->linkedTo(m_xlx2Reflector);
|
||||
changed = false;
|
||||
}
|
||||
}
|
||||
@@ -369,9 +432,9 @@ int CDMRGateway::run()
|
||||
|
||||
if (rewritten) {
|
||||
unsigned int slotNo = data.getSlotNo();
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_NETWORK1) {
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK1) {
|
||||
m_dmrNetwork1->write(data);
|
||||
status[slotNo] = DMRGWS_NETWORK1;
|
||||
status[slotNo] = DMRGWS_DMRNETWORK1;
|
||||
timer[slotNo]->start();
|
||||
}
|
||||
}
|
||||
@@ -390,9 +453,9 @@ int CDMRGateway::run()
|
||||
|
||||
if (rewritten) {
|
||||
unsigned int slotNo = data.getSlotNo();
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_NETWORK2) {
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK2) {
|
||||
m_dmrNetwork2->write(data);
|
||||
status[slotNo] = DMRGWS_NETWORK2;
|
||||
status[slotNo] = DMRGWS_DMRNETWORK2;
|
||||
timer[slotNo]->start();
|
||||
}
|
||||
}
|
||||
@@ -401,20 +464,40 @@ int CDMRGateway::run()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_xlxNetwork != NULL) {
|
||||
ret = m_xlxNetwork->read(data);
|
||||
if (m_xlxNetwork1 != NULL) {
|
||||
ret = m_xlxNetwork1->read(data);
|
||||
if (ret) {
|
||||
if (status[m_xlxSlot] == DMRGWS_NONE || status[m_xlxSlot] == DMRGWS_REFLECTOR) {
|
||||
bool ret = m_rptRewrite->process(data);
|
||||
if (status[m_xlx1Slot] == DMRGWS_NONE || status[m_xlx1Slot] == DMRGWS_XLXREFLECTOR1) {
|
||||
bool ret = m_rpt1Rewrite->process(data);
|
||||
if (ret) {
|
||||
m_repeater->write(data);
|
||||
status[m_xlxSlot] = DMRGWS_REFLECTOR;
|
||||
timer[m_xlxSlot]->start();
|
||||
status[m_xlx1Slot] = DMRGWS_XLXREFLECTOR1;
|
||||
timer[m_xlx1Slot]->start();
|
||||
} else {
|
||||
unsigned int slotNo = data.getSlotNo();
|
||||
unsigned int dstId = data.getDstId();
|
||||
FLCO flco = data.getFLCO();
|
||||
LogWarning("XLX, Unexpected data from slot %u %s%u", slotNo, flco == FLCO_GROUP ? "TG" : "", dstId);
|
||||
LogWarning("XLX-1, Unexpected data from slot %u %s%u", slotNo, flco == FLCO_GROUP ? "TG" : "", dstId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_xlxNetwork2 != NULL) {
|
||||
ret = m_xlxNetwork2->read(data);
|
||||
if (ret) {
|
||||
if (status[m_xlx2Slot] == DMRGWS_NONE || status[m_xlx2Slot] == DMRGWS_XLXREFLECTOR2) {
|
||||
bool ret = m_rpt2Rewrite->process(data);
|
||||
if (ret) {
|
||||
m_repeater->write(data);
|
||||
status[m_xlx2Slot] = DMRGWS_XLXREFLECTOR2;
|
||||
timer[m_xlx2Slot]->start();
|
||||
}
|
||||
else {
|
||||
unsigned int slotNo = data.getSlotNo();
|
||||
unsigned int dstId = data.getDstId();
|
||||
FLCO flco = data.getFLCO();
|
||||
LogWarning("XLX-2, Unexpected data from slot %u %s%u", slotNo, flco == FLCO_GROUP ? "TG" : "", dstId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,13 +521,10 @@ int CDMRGateway::run()
|
||||
unsigned int dstId = data.getDstId();
|
||||
FLCO flco = data.getFLCO();
|
||||
|
||||
// Stop the DMR network from using the same TG and slot as XLX after rewriting
|
||||
if (flco != FLCO_GROUP || slotNo != m_xlxSlot || dstId != m_xlxTG) {
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_NETWORK1) {
|
||||
m_repeater->write(data);
|
||||
status[slotNo] = DMRGWS_NETWORK1;
|
||||
timer[slotNo]->start();
|
||||
}
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK1) {
|
||||
m_repeater->write(data);
|
||||
status[slotNo] = DMRGWS_DMRNETWORK1;
|
||||
timer[slotNo]->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,13 +548,10 @@ int CDMRGateway::run()
|
||||
unsigned int dstId = data.getDstId();
|
||||
FLCO flco = data.getFLCO();
|
||||
|
||||
// Stop the DMR network from using the same TG and slot as XLX after rewriting
|
||||
if (flco != FLCO_GROUP || slotNo != m_xlxSlot || dstId != m_xlxTG) {
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_NETWORK2) {
|
||||
m_repeater->write(data);
|
||||
status[slotNo] = DMRGWS_NETWORK2;
|
||||
timer[slotNo]->start();
|
||||
}
|
||||
if (status[slotNo] == DMRGWS_NONE || status[slotNo] == DMRGWS_DMRNETWORK2) {
|
||||
m_repeater->write(data);
|
||||
status[slotNo] = DMRGWS_DMRNETWORK2;
|
||||
timer[slotNo]->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,8 +561,10 @@ int CDMRGateway::run()
|
||||
unsigned int length;
|
||||
ret = m_repeater->readPosition(buffer, length);
|
||||
if (ret) {
|
||||
if (m_xlxNetwork != NULL)
|
||||
m_xlxNetwork->writePosition(buffer, length);
|
||||
if (m_xlxNetwork1 != NULL)
|
||||
m_xlxNetwork1->writePosition(buffer, length);
|
||||
if (m_xlxNetwork2 != NULL)
|
||||
m_xlxNetwork2->writePosition(buffer, length);
|
||||
if (m_dmrNetwork1 != NULL)
|
||||
m_dmrNetwork1->writePosition(buffer, length);
|
||||
if (m_dmrNetwork2 != NULL)
|
||||
@@ -493,20 +572,31 @@ int CDMRGateway::run()
|
||||
}
|
||||
ret = m_repeater->readTalkerAlias(buffer, length);
|
||||
if (ret) {
|
||||
if (m_xlxNetwork != NULL)
|
||||
m_xlxNetwork->writeTalkerAlias(buffer, length);
|
||||
if (m_xlxNetwork1 != NULL)
|
||||
m_xlxNetwork1->writeTalkerAlias(buffer, length);
|
||||
if (m_xlxNetwork2 != NULL)
|
||||
m_xlxNetwork2->writeTalkerAlias(buffer, length);
|
||||
if (m_dmrNetwork1 != NULL)
|
||||
m_dmrNetwork1->writeTalkerAlias(buffer, length);
|
||||
if (m_dmrNetwork2 != NULL)
|
||||
m_dmrNetwork2->writeTalkerAlias(buffer, length);
|
||||
}
|
||||
|
||||
if (voice != NULL) {
|
||||
ret = voice->read(data);
|
||||
if (voice1 != NULL) {
|
||||
ret = voice1->read(data);
|
||||
if (ret) {
|
||||
m_repeater->write(data);
|
||||
status[m_xlxSlot] = DMRGWS_REFLECTOR;
|
||||
timer[m_xlxSlot]->start();
|
||||
status[m_xlx1Slot] = DMRGWS_XLXREFLECTOR1;
|
||||
timer[m_xlx1Slot]->start();
|
||||
}
|
||||
}
|
||||
|
||||
if (voice2 != NULL) {
|
||||
ret = voice2->read(data);
|
||||
if (ret) {
|
||||
m_repeater->write(data);
|
||||
status[m_xlx2Slot] = DMRGWS_XLXREFLECTOR2;
|
||||
timer[m_xlx2Slot]->start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,11 +611,17 @@ int CDMRGateway::run()
|
||||
if (m_dmrNetwork2 != NULL)
|
||||
m_dmrNetwork2->clock(ms);
|
||||
|
||||
if (m_xlxNetwork != NULL)
|
||||
m_xlxNetwork->clock(ms);
|
||||
if (m_xlxNetwork1 != NULL)
|
||||
m_xlxNetwork1->clock(ms);
|
||||
|
||||
if (voice != NULL)
|
||||
voice->clock(ms);
|
||||
if (m_xlxNetwork2 != NULL)
|
||||
m_xlxNetwork2->clock(ms);
|
||||
|
||||
if (voice1 != NULL)
|
||||
voice1->clock(ms);
|
||||
|
||||
if (voice2 != NULL)
|
||||
voice2->clock(ms);
|
||||
|
||||
for (unsigned int i = 1U; i < 3U; i++) {
|
||||
timer[i]->clock(ms);
|
||||
@@ -541,7 +637,8 @@ int CDMRGateway::run()
|
||||
|
||||
LogMessage("DMRGateway-%s is exiting on receipt of SIGHUP1", VERSION);
|
||||
|
||||
delete voice;
|
||||
delete voice1;
|
||||
delete voice2;
|
||||
|
||||
m_repeater->close();
|
||||
delete m_repeater;
|
||||
@@ -556,9 +653,14 @@ int CDMRGateway::run()
|
||||
delete m_dmrNetwork2;
|
||||
}
|
||||
|
||||
if (m_xlxNetwork != NULL) {
|
||||
m_xlxNetwork->close();
|
||||
delete m_xlxNetwork;
|
||||
if (m_xlxNetwork1 != NULL) {
|
||||
m_xlxNetwork1->close();
|
||||
delete m_xlxNetwork1;
|
||||
}
|
||||
|
||||
if (m_xlxNetwork2 != NULL) {
|
||||
m_xlxNetwork2->close();
|
||||
delete m_xlxNetwork2;
|
||||
}
|
||||
|
||||
delete timer[1U];
|
||||
@@ -765,19 +867,19 @@ bool CDMRGateway::createDMRNetwork2()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDMRGateway::createXLXNetwork()
|
||||
bool CDMRGateway::createXLXNetwork1()
|
||||
{
|
||||
std::string address = m_conf.getXLXNetworkAddress();
|
||||
unsigned int port = m_conf.getXLXNetworkPort();
|
||||
unsigned int local = m_conf.getXLXNetworkLocal();
|
||||
unsigned int id = m_conf.getXLXNetworkId();
|
||||
std::string password = m_conf.getXLXNetworkPassword();
|
||||
bool debug = m_conf.getXLXNetworkDebug();
|
||||
std::string address = m_conf.getXLXNetwork1Address();
|
||||
unsigned int port = m_conf.getXLXNetwork1Port();
|
||||
unsigned int local = m_conf.getXLXNetwork1Local();
|
||||
unsigned int id = m_conf.getXLXNetwork1Id();
|
||||
std::string password = m_conf.getXLXNetwork1Password();
|
||||
bool debug = m_conf.getXLXNetwork1Debug();
|
||||
|
||||
if (id == 0U)
|
||||
id = m_repeater->getId();
|
||||
|
||||
LogInfo("XLX Network Parameters");
|
||||
LogInfo("XLX Network 1 Parameters");
|
||||
LogInfo(" Id: %u", id);
|
||||
LogInfo(" Address: %s", address.c_str());
|
||||
LogInfo(" Port: %u", port);
|
||||
@@ -786,36 +888,91 @@ bool CDMRGateway::createXLXNetwork()
|
||||
else
|
||||
LogInfo(" Local: random");
|
||||
|
||||
m_xlxNetwork = new CDMRNetwork(address, port, local, id, password, "XLX", debug);
|
||||
m_xlxNetwork1 = new CDMRNetwork(address, port, local, id, password, "XLX-1", debug);
|
||||
|
||||
std::string options = m_conf.getXLXNetworkOptions();
|
||||
std::string options = m_conf.getXLXNetwork1Options();
|
||||
if (!options.empty()) {
|
||||
LogInfo(" Options: %s", options.c_str());
|
||||
m_xlxNetwork->setOptions(options);
|
||||
m_xlxNetwork1->setOptions(options);
|
||||
}
|
||||
|
||||
unsigned char config[400U];
|
||||
unsigned int len = m_repeater->getConfig(config);
|
||||
|
||||
m_xlxNetwork->setConfig(config, len);
|
||||
m_xlxNetwork1->setConfig(config, len);
|
||||
|
||||
bool ret = m_xlxNetwork->open();
|
||||
bool ret = m_xlxNetwork1->open();
|
||||
if (!ret) {
|
||||
delete m_xlxNetwork;
|
||||
m_xlxNetwork = NULL;
|
||||
delete m_xlxNetwork1;
|
||||
m_xlxNetwork1 = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_xlxSlot = m_conf.getXLXNetworkSlot();
|
||||
m_xlxTG = m_conf.getXLXNetworkTG();
|
||||
m_xlxBase = m_conf.getXLXNetworkBase();
|
||||
m_xlx1Slot = m_conf.getXLXNetwork1Slot();
|
||||
m_xlx1TG = m_conf.getXLXNetwork1TG();
|
||||
m_xlx1Base = m_conf.getXLXNetwork1Base();
|
||||
|
||||
LogInfo(" Slot: %u", m_xlxSlot);
|
||||
LogInfo(" TG: %u", m_xlxTG);
|
||||
LogInfo(" Base: %u", m_xlxBase);
|
||||
LogInfo(" Slot: %u", m_xlx1Slot);
|
||||
LogInfo(" TG: %u", m_xlx1TG);
|
||||
LogInfo(" Base: %u", m_xlx1Base);
|
||||
|
||||
m_rptRewrite = new CRewriteTG("XLX", XLX_SLOT, XLX_TG, m_xlxSlot, m_xlxTG, 1U);
|
||||
m_xlxRewrite = new CRewriteTG("XLX", m_xlxSlot, m_xlxTG, XLX_SLOT, XLX_TG, 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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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();
|
||||
std::string password = m_conf.getXLXNetwork2Password();
|
||||
bool debug = m_conf.getXLXNetwork2Debug();
|
||||
|
||||
if (id == 0U)
|
||||
id = m_repeater->getId();
|
||||
|
||||
LogInfo("XLX Network 2 Parameters");
|
||||
LogInfo(" Id: %u", id);
|
||||
LogInfo(" Address: %s", address.c_str());
|
||||
LogInfo(" Port: %u", port);
|
||||
if (local > 0U)
|
||||
LogInfo(" Local: %u", local);
|
||||
else
|
||||
LogInfo(" Local: random");
|
||||
|
||||
m_xlxNetwork2 = new CDMRNetwork(address, port, local, id, password, "XLX-2", debug);
|
||||
|
||||
std::string options = m_conf.getXLXNetwork2Options();
|
||||
if (!options.empty()) {
|
||||
LogInfo(" Options: %s", options.c_str());
|
||||
m_xlxNetwork2->setOptions(options);
|
||||
}
|
||||
|
||||
unsigned char config[400U];
|
||||
unsigned int len = m_repeater->getConfig(config);
|
||||
|
||||
m_xlxNetwork2->setConfig(config, len);
|
||||
|
||||
bool ret = m_xlxNetwork2->open();
|
||||
if (!ret) {
|
||||
delete m_xlxNetwork2;
|
||||
m_xlxNetwork2 = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_xlx2Slot = m_conf.getXLXNetwork2Slot();
|
||||
m_xlx2TG = m_conf.getXLXNetwork2TG();
|
||||
m_xlx2Base = m_conf.getXLXNetwork2Base();
|
||||
|
||||
LogInfo(" Slot: %u", m_xlx2Slot);
|
||||
LogInfo(" TG: %u", m_xlx2TG);
|
||||
LogInfo(" Base: %u", m_xlx2Base);
|
||||
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
24
DMRGateway.h
24
DMRGateway.h
@@ -41,13 +41,20 @@ private:
|
||||
IRepeaterProtocol* m_repeater;
|
||||
CDMRNetwork* m_dmrNetwork1;
|
||||
CDMRNetwork* m_dmrNetwork2;
|
||||
CDMRNetwork* m_xlxNetwork;
|
||||
unsigned int m_reflector;
|
||||
unsigned int m_xlxSlot;
|
||||
unsigned int m_xlxTG;
|
||||
unsigned int m_xlxBase;
|
||||
CRewriteTG* m_rptRewrite;
|
||||
CRewriteTG* m_xlxRewrite;
|
||||
CDMRNetwork* m_xlxNetwork1;
|
||||
CDMRNetwork* m_xlxNetwork2;
|
||||
unsigned int m_xlx1Reflector;
|
||||
unsigned int m_xlx1Slot;
|
||||
unsigned int m_xlx1TG;
|
||||
unsigned int m_xlx1Base;
|
||||
CRewriteTG* m_rpt1Rewrite;
|
||||
CRewriteTG* m_xlx1Rewrite;
|
||||
unsigned int m_xlx2Reflector;
|
||||
unsigned int m_xlx2Slot;
|
||||
unsigned int m_xlx2TG;
|
||||
unsigned int m_xlx2Base;
|
||||
CRewriteTG* m_rpt2Rewrite;
|
||||
CRewriteTG* m_xlx2Rewrite;
|
||||
std::vector<IRewrite*> m_dmr1NetRewrites;
|
||||
std::vector<IRewrite*> m_dmr1RFRewrites;
|
||||
std::vector<IRewrite*> m_dmr2NetRewrites;
|
||||
@@ -56,7 +63,8 @@ private:
|
||||
bool createMMDVM();
|
||||
bool createDMRNetwork1();
|
||||
bool createDMRNetwork2();
|
||||
bool createXLXNetwork();
|
||||
bool createXLXNetwork1();
|
||||
bool createXLXNetwork2();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,7 @@ Enabled=1
|
||||
Language=en_GB
|
||||
Directory=./Audio
|
||||
|
||||
[XLX Network]
|
||||
[XLX Network 1]
|
||||
Enabled=1
|
||||
Address=xlx950.epf.lu
|
||||
Port=62030
|
||||
@@ -27,13 +27,25 @@ Port=62030
|
||||
# Options=
|
||||
Slot=1
|
||||
TG=8
|
||||
Base=4000
|
||||
Base=84000
|
||||
Password=passw0rd
|
||||
Debug=0
|
||||
|
||||
[XLX Network 2]
|
||||
Enabled=0
|
||||
Address=44.131.4.1
|
||||
Port=62030
|
||||
# Local=3351
|
||||
# Options=
|
||||
Slot=1
|
||||
TG=7
|
||||
Base=74000
|
||||
Password=passw0rd
|
||||
Debug=0
|
||||
|
||||
# BrandMeister
|
||||
[DMR Network 1]
|
||||
Enabled=1
|
||||
Enabled=0
|
||||
Address=44.131.4.1
|
||||
Port=62031
|
||||
# Local=3352
|
||||
|
||||
Reference in New Issue
Block a user