1
0
Fork 0

Add named FCS rooms to Wires-X.

ycs232-kbc
Jonathan Naylor 7 years ago
parent c4beab718c
commit 0d777da182

@ -77,6 +77,7 @@ m_ysfNetworkParrotPort(0U),
m_ysfNetworkYSF2DMRAddress("127.0.0.1"),
m_ysfNetworkYSF2DMRPort(0U),
m_fcsNetworkEnabled(false),
m_fcsNetworkEntries(),
m_fcsNetworkPort(0U)
{
}
@ -215,7 +216,18 @@ bool CConf::read()
} else if (section == SECTION_FCS_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_fcsNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)
else if (::strcmp(key, "Entries") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
if (::strlen(p) > 0U) {
for (unsigned int i = 0U; p[i] != 0; i++)
p[i] = ::toupper(p[i]);
std::string name = std::string(p);
m_fcsNetworkEntries.push_back(name);
}
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "Port") == 0)
m_fcsNetworkPort = (unsigned int)::atoi(value);
}
}
@ -415,6 +427,11 @@ bool CConf::getFCSNetworkEnabled() const
return m_fcsNetworkEnabled;
}
std::vector<std::string> CConf::getFCSNetworkEntries() const
{
return m_fcsNetworkEntries;
}
unsigned int CConf::getFCSNetworkPort() const
{
return m_fcsNetworkPort;

@ -81,6 +81,7 @@ public:
// The FCS Network section
bool getFCSNetworkEnabled() const;
std::vector<std::string> getFCSNetworkEntries() const;
unsigned int getFCSNetworkPort() const;
private:
@ -129,6 +130,7 @@ private:
unsigned int m_ysfNetworkYSF2DMRPort;
bool m_fcsNetworkEnabled;
std::vector<std::string> m_fcsNetworkEntries;
unsigned int m_fcsNetworkPort;
};

@ -157,6 +157,11 @@ void CWiresX::setYSF2DMR(const std::string& address, unsigned int port)
m_reflectors.setYSF2DMR(address, port);
}
void CWiresX::addFCSRoom(const std::string& name)
{
m_reflectors.addFCSRoom(name);
}
bool CWiresX::start()
{
m_reflectors.reload();
@ -288,7 +293,14 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch
m_status = WXSI_CONNECT;
m_timer.start();
return WXS_CONNECT_YSF;
switch (m_reflector->m_type) {
case YT_YSF:
return WXS_CONNECT_YSF;
case YT_FCS:
return WXS_CONNECT_FCS;
default:
return WXS_NONE;
}
}
void CWiresX::processConnect(CYSFReflector* reflector)

@ -49,6 +49,7 @@ public:
void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency);
void setParrot(const std::string& address, unsigned int port);
void setYSF2DMR(const std::string& address, unsigned int port);
void addFCSRoom(const std::string& name);
bool start();

@ -457,16 +457,18 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
std::string address = m_conf.getYSFNetworkParrotAddress();
unsigned int port = m_conf.getYSFNetworkParrotPort();
if (port > 0U)
m_wiresX->setParrot(address, port);
address = m_conf.getYSFNetworkYSF2DMRAddress();
port = m_conf.getYSFNetworkYSF2DMRPort();
if (port > 0U)
m_wiresX->setYSF2DMR(address, port);
std::vector<std::string> entries = m_conf.getFCSNetworkEntries();
for (std::vector<std::string>::const_iterator it = entries.cbegin(); it != entries.cend(); ++it)
m_wiresX->addFCSRoom(*it);
m_reflectors->load();
m_wiresX->start();
}
@ -498,6 +500,37 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u
m_linkType = LINK_YSF;
}
break;
case WXS_CONNECT_FCS: {
if (m_linkType == LINK_YSF) {
m_ysfNetwork->writeUnlink(3U);
m_ysfNetwork->clearDestination();
}
if (m_linkType == LINK_FCS)
m_fcsNetwork->writeUnlink(3U);
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
CYSFReflector* reflector = m_wiresX->getReflector();
LogMessage("Connect to %s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U);
std::string name = reflector->m_name;
name.resize(8U, '0');
bool ok = m_fcsNetwork->writeLink(name);
if (ok) {
m_current = name;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_FCS;
} else {
LogMessage("Unknown reflector - %s", name.c_str());
}
}
break;
case WXS_DISCONNECT:
if (m_linkType == LINK_YSF) {
LogMessage("Disconnect has been requested by %10.10s", buffer + 14U);

@ -53,4 +53,5 @@ YSF2DMRPort=42013
[FCS Network]
Enable=1
# Entries=FCS00120,FCS00215
Port=42001

@ -30,6 +30,9 @@ CYSFReflectors::CYSFReflectors(const std::string& hostsFile, unsigned int reload
m_hostsFile(hostsFile),
m_parrotAddress(),
m_parrotPort(0U),
m_YSF2DMRAddress(),
m_YSF2DMRPort(0U),
m_fcsRooms(),
m_newReflectors(),
m_currReflectors(),
m_search(),
@ -80,6 +83,11 @@ void CYSFReflectors::setYSF2DMR(const std::string& address, unsigned int port)
m_YSF2DMRPort = port;
}
void CYSFReflectors::addFCSRoom(const std::string& name)
{
m_fcsRooms.push_back(name);
}
bool CYSFReflectors::load()
{
for (std::vector<CYSFReflector*>::iterator it = m_newReflectors.begin(); it != m_newReflectors.end(); ++it)
@ -107,12 +115,13 @@ bool CYSFReflectors::load()
in_addr address = CUDPSocket::lookup(host);
if (address.s_addr != INADDR_NONE) {
CYSFReflector* refl = new CYSFReflector;
refl->m_id = std::string(p1);
refl->m_name = std::string(p2);
refl->m_desc = std::string(p3);
refl->m_id = std::string(p1);
refl->m_name = std::string(p2);
refl->m_desc = std::string(p3);
refl->m_address = address;
refl->m_port = (unsigned int)::atoi(p5);
refl->m_count = std::string(p6);;
refl->m_port = (unsigned int)::atoi(p5);
refl->m_count = std::string(p6);;
refl->m_type = YT_YSF;
refl->m_name.resize(16U, ' ');
refl->m_desc.resize(14U, ' ');
@ -137,7 +146,10 @@ bool CYSFReflectors::load()
refl->m_address = CUDPSocket::lookup(m_parrotAddress);
refl->m_port = m_parrotPort;
refl->m_count = "000";
refl->m_type = YT_YSF;
m_newReflectors.push_back(refl);
LogInfo("Loaded YSF parrot");
}
@ -150,10 +162,36 @@ bool CYSFReflectors::load()
refl->m_address = CUDPSocket::lookup(m_YSF2DMRAddress);
refl->m_port = m_YSF2DMRPort;
refl->m_count = "000";
refl->m_type = YT_YSF;
m_newReflectors.push_back(refl);
LogInfo("Loaded YSF2DMR");
}
unsigned int id = 10U;
for (std::vector<std::string>::const_iterator it = m_fcsRooms.cbegin(); it != m_fcsRooms.cend(); ++it, id++) {
char text[10U];
::sprintf(text, "%05u", id);
std::string name = *it;
CYSFReflector* refl = new CYSFReflector;
refl->m_id = text;
refl->m_name = name;
refl->m_desc = name;
refl->m_port = 0U;
refl->m_count = "000";
refl->m_type = YT_FCS;
refl->m_name.resize(16U, ' ');
refl->m_desc.resize(14U, ' ');
m_newReflectors.push_back(refl);
LogInfo("Loaded %s", name.c_str());
}
size = m_newReflectors.size();
if (size == 0U)
return false;
@ -203,7 +241,7 @@ std::vector<CYSFReflector*>& CYSFReflectors::search(const std::string& name)
trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), trimmed.end());
std::transform(trimmed.begin(), trimmed.end(), trimmed.begin(), ::toupper);
unsigned int len = trimmed.size();
size_t len = trimmed.size();
for (std::vector<CYSFReflector*>::iterator it = m_currReflectors.begin(); it != m_currReflectors.end(); ++it) {
std::string reflector = (*it)->m_name;

@ -25,6 +25,11 @@
#include <vector>
#include <string>
enum YSF_TYPE {
YT_YSF,
YT_FCS
};
class CYSFReflector {
public:
CYSFReflector() :
@ -33,7 +38,8 @@ public:
m_desc(),
m_count("000"),
m_address(),
m_port(0U)
m_port(0U),
m_type(YT_YSF)
{
}
@ -43,6 +49,7 @@ public:
std::string m_count;
in_addr m_address;
unsigned int m_port;
YSF_TYPE m_type;
};
class CYSFReflectors {
@ -52,6 +59,7 @@ public:
void setParrot(const std::string& address, unsigned int port);
void setYSF2DMR(const std::string& address, unsigned int port);
void addFCSRoom(const std::string& name);
bool load();
@ -72,6 +80,7 @@ private:
unsigned int m_parrotPort;
std::string m_YSF2DMRAddress;
unsigned int m_YSF2DMRPort;
std::vector<std::string> m_fcsRooms;
std::vector<CYSFReflector*> m_newReflectors;
std::vector<CYSFReflector*> m_currReflectors;
std::vector<CYSFReflector*> m_search;

Loading…
Cancel
Save