diff --git a/YSFGateway/Conf.cpp b/YSFGateway/Conf.cpp index 7cb71ca..fa4378e 100644 --- a/YSFGateway/Conf.cpp +++ b/YSFGateway/Conf.cpp @@ -48,6 +48,7 @@ m_rptPort(0U), m_myAddress(), m_myPort(0U), m_wiresXMakeUpper(true), +m_wiresXCommandPassthrough(false), m_daemon(false), m_rxFrequency(0U), m_txFrequency(0U), @@ -162,6 +163,8 @@ bool CConf::read() m_myPort = (unsigned int)::atoi(value); else if (::strcmp(key, "WiresXMakeUpper") == 0) m_wiresXMakeUpper = ::atoi(value) == 1; + else if (::strcmp(key, "WiresXCommandPassthrough") == 0) + m_wiresXCommandPassthrough = ::atoi(value) == 1; else if (::strcmp(key, "Daemon") == 0) m_daemon = ::atoi(value) == 1; } else if (section == SECTION_INFO) { @@ -299,6 +302,11 @@ bool CConf::getWiresXMakeUpper() const return m_wiresXMakeUpper; } +bool CConf::getWiresXCommandPassthrough() const +{ + return m_wiresXCommandPassthrough; +} + bool CConf::getDaemon() const { return m_daemon; diff --git a/YSFGateway/Conf.h b/YSFGateway/Conf.h index 7ab7ea6..3a588ab 100644 --- a/YSFGateway/Conf.h +++ b/YSFGateway/Conf.h @@ -38,6 +38,7 @@ public: std::string getMyAddress() const; unsigned int getMyPort() const; bool getWiresXMakeUpper() const; + bool getWiresXCommandPassthrough() const; bool getDaemon() const; // The Info section @@ -104,6 +105,7 @@ private: std::string m_myAddress; unsigned int m_myPort; bool m_wiresXMakeUpper; + bool m_wiresXCommandPassthrough; bool m_daemon; unsigned int m_rxFrequency; diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index e16fd5d..12aacbc 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -180,7 +180,7 @@ bool CWiresX::start() return true; } -WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft) +WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough) { assert(data != NULL); assert(source != NULL); @@ -227,23 +227,44 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc if (!valid) return WXS_NONE; - if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) { - processDX(source); - return WXS_NONE; - } else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) { - processAll(source, m_command + 5U); - return WXS_NONE; - } else if (::memcmp(m_command + 1U, CONN_REQ, 3U) == 0) { - return processConnect(source, m_command + 5U); - } else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) { - processDisconnect(source); - return WXS_DISCONNECT; - } else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) { - processCategory(source, m_command + 5U); - return WXS_NONE; - } else { - CUtils::dump("Unknown Wires-X command", m_command, cmd_len); - return WXS_NONE; + // If we are using WiresX Passthrough (we already know we are on a YSF2xxx room from YSFGateway + if (wiresXCommandPassthrough == true) { + if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) { + return WXS_NONE; + } else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) { + return WXS_NONE; + } else if (::memcmp(m_command + 1U, CONN_REQ, 3U) == 0) { + return WXS_NONE; + } else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) { + processDisconnect(source); + return WXS_DISCONNECT; + } else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) { + return WXS_NONE; + } else { + CUtils::dump("Unknown Wires-X command", m_command, cmd_len); + return WXS_NONE; + } + } + // Origional Code Here + else { + if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) { + processDX(source); + return WXS_NONE; + } else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) { + processAll(source, m_command + 5U); + return WXS_NONE; + } else if (::memcmp(m_command + 1U, CONN_REQ, 3U) == 0) { + return processConnect(source, m_command + 5U); + } else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) { + processDisconnect(source); + return WXS_DISCONNECT; + } else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) { + processCategory(source, m_command + 5U); + return WXS_NONE; + } else { + CUtils::dump("Unknown Wires-X command", m_command, cmd_len); + return WXS_NONE; + } } } diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index 0116762..ca490e5 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -56,7 +56,7 @@ public: bool start(); - WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); + WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough); CYSFReflector* getReflector() const; void setReflector(CYSFReflector* reflector); @@ -87,6 +87,7 @@ private: unsigned int m_start; std::string m_search; std::vector m_category; + bool m_wiresXCommandPassthrough; WX_STATUS processConnect(const unsigned char* source, const unsigned char* data); void processDX(const unsigned char* source); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index fe50af0..3290f21 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -244,6 +244,7 @@ int CYSFGateway::run() m_startup = m_conf.getNetworkStartup(); bool revert = m_conf.getNetworkRevert(); + bool wiresXCommandPassthrough = m_conf.getWiresXCommandPassthrough(); startupLinking(); @@ -266,12 +267,18 @@ int CYSFGateway::run() unsigned char fn = fich.getFN(); unsigned char ft = fich.getFT(); - // Don't send out control data - m_exclude = (dt == YSF_DT_DATA_FR_MODE); - - processWiresX(buffer, fi, dt, fn, ft); - - processDTMF(buffer, dt); + CYSFReflector* reflector = m_wiresX->getReflector(); + if ( (wiresXCommandPassthrough == true) && (m_linkType == LINK_YSF) && (reflector->m_name.rfind("YSF2DMR", 0) == 0 || reflector->m_name.rfind("YSF2P25", 0) == 0 || reflector->m_name.rfind("YSF2NXDN", 0) == 0) ) { + // Allow WiresX to Pass Through + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, true); + } + else { + // Don't Pass Control Commands + m_exclude = (dt == YSF_DT_DATA_FR_MODE); + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, false); + } if (m_gps != NULL) m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft); @@ -507,11 +514,11 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork) m_wiresX->start(); } -void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft) +void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough) { assert(buffer != NULL); - WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft); + WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft, wiresXCommandPassthrough); switch (status) { case WXS_CONNECT_YSF: { if (m_linkType == LINK_YSF) diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index e25b3e6..545f7b7 100644 --- a/YSFGateway/YSFGateway.h +++ b/YSFGateway/YSFGateway.h @@ -66,7 +66,7 @@ private: void startupLinking(); std::string calculateLocator(); - void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft); + void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough); void processDTMF(unsigned char* buffer, unsigned char dt); void createWiresX(CYSFNetwork* rptNetwork); void createGPS(); diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index e83a3bb..ec88a5b 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -8,6 +8,7 @@ RptPort=3200 LocalAddress=127.0.0.1 LocalPort=4200 WiresXMakeUpper=1 +WiresXCommandPassthrough=1 Daemon=0 [Info]