From 5a940857ba4f7f3ff14c7278a427727aa720fa83 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Jan 2019 15:51:31 +0000 Subject: [PATCH 01/18] Experimental WiresX Selective Passthrough --- YSFGateway/Conf.cpp | 8 ++++++ YSFGateway/Conf.h | 2 ++ YSFGateway/WiresX.cpp | 57 ++++++++++++++++++++++++++------------- YSFGateway/WiresX.h | 3 ++- YSFGateway/YSFGateway.cpp | 23 ++++++++++------ YSFGateway/YSFGateway.h | 2 +- YSFGateway/YSFGateway.ini | 1 + 7 files changed, 68 insertions(+), 28 deletions(-) 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] From e57cadc679c003653ee3a608bf0fef4728b8dabc Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 27 Jan 2019 01:18:31 +0000 Subject: [PATCH 02/18] Update YSFGateway.cpp --- YSFGateway/YSFGateway.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 3290f21..575dfdf 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -574,6 +574,10 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u case WXS_DISCONNECT: if (m_linkType == LINK_YSF) { LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + if ( (wiresXCommandPassthrough) && (::memcmp(buffer + 0U, "YSFD", 4U) == 0) ) { + m_ysfNetwork->write(buffer); + m_wiresX->sendDisconnectReply(); + } m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); From aaee56011967103c2ed251a0449cdfdfdf81a718 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 27 Jan 2019 01:22:15 +0000 Subject: [PATCH 03/18] Revert "Update YSFGateway.cpp" This reverts commit e57cadc679c003653ee3a608bf0fef4728b8dabc. --- YSFGateway/YSFGateway.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 575dfdf..3290f21 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -574,10 +574,6 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u case WXS_DISCONNECT: if (m_linkType == LINK_YSF) { LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); - if ( (wiresXCommandPassthrough) && (::memcmp(buffer + 0U, "YSFD", 4U) == 0) ) { - m_ysfNetwork->write(buffer); - m_wiresX->sendDisconnectReply(); - } m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); From 2013dd91b5fd745d824f45e9e4c30c2ba0194090 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 27 Jan 2019 01:24:49 +0000 Subject: [PATCH 04/18] Update YSFGateway.cpp Send the disconnect to the YSF2xxx gateway too --- YSFGateway/YSFGateway.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 3290f21..01e8fc1 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -574,6 +574,10 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u case WXS_DISCONNECT: if (m_linkType == LINK_YSF) { LogMessage("Disconnect has been requested by %10.10s", buffer + 14U); + if ( (wiresXCommandPassthrough) && (::memcmp(buffer + 0U, "YSFD", 4U) == 0) ) { + // Send the disconnect to the YSF2xxx gateway too + m_ysfNetwork->write(buffer); + } m_ysfNetwork->writeUnlink(3U); m_ysfNetwork->clearDestination(); From 36970ce021d6eaabe1ebd0914615e596e70d7dd3 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 28 Jan 2019 13:56:14 +0000 Subject: [PATCH 05/18] Update YSFGateway.cpp --- YSFGateway/YSFGateway.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 01e8fc1..4e1490d 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -268,7 +268,7 @@ int CYSFGateway::run() unsigned char ft = fich.getFT(); 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) ) { + if ( (wiresXCommandPassthrough) && (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); From a477f3333abe24ebdb2e9bbe0d09aeb18315d15e Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 28 Jan 2019 13:56:43 +0000 Subject: [PATCH 06/18] Update WiresX.cpp --- YSFGateway/WiresX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index 12aacbc..fcf2859 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -228,7 +228,7 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc return WXS_NONE; // If we are using WiresX Passthrough (we already know we are on a YSF2xxx room from YSFGateway - if (wiresXCommandPassthrough == true) { + if (wiresXCommandPassthrough) { if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) { return WXS_NONE; } else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) { From f261b88d7f6b9510a5949f7d24eaf425428bafaf Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 11:34:44 +0000 Subject: [PATCH 07/18] Update YSFGateway.ini Defaulted the command passthrough to off --- YSFGateway/YSFGateway.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFGateway/YSFGateway.ini b/YSFGateway/YSFGateway.ini index ec88a5b..5352edd 100644 --- a/YSFGateway/YSFGateway.ini +++ b/YSFGateway/YSFGateway.ini @@ -8,7 +8,7 @@ RptPort=3200 LocalAddress=127.0.0.1 LocalPort=4200 WiresXMakeUpper=1 -WiresXCommandPassthrough=1 +WiresXCommandPassthrough=0 Daemon=0 [Info] From baed7d67e2370eca25641a74da34026546aa86ff Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 29 Jan 2019 12:34:28 +0000 Subject: [PATCH 08/18] Tag YSF2xxx reflectors as being Wires-X capable. --- YSFGateway/YSFReflectors.cpp | 18 ++++++++++++------ YSFGateway/YSFReflectors.h | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/YSFGateway/YSFReflectors.cpp b/YSFGateway/YSFReflectors.cpp index cbfd54b..893307c 100644 --- a/YSFGateway/YSFReflectors.cpp +++ b/YSFGateway/YSFReflectors.cpp @@ -139,6 +139,7 @@ bool CYSFReflectors::load() refl->m_port = (unsigned int)::atoi(p5); refl->m_count = std::string(p6); refl->m_type = YT_YSF; + refl->m_wiresX = false; refl->m_name.resize(16U, ' '); refl->m_desc.resize(14U, ' '); @@ -164,6 +165,7 @@ bool CYSFReflectors::load() refl->m_port = m_parrotPort; refl->m_count = "000"; refl->m_type = YT_YSF; + refl->m_wiresX = false; m_newReflectors.push_back(refl); @@ -180,6 +182,7 @@ bool CYSFReflectors::load() refl->m_port = m_YSF2DMRPort; refl->m_count = "000"; refl->m_type = YT_YSF; + refl->m_wiresX = true; m_newReflectors.push_back(refl); @@ -196,6 +199,7 @@ bool CYSFReflectors::load() refl->m_port = m_YSF2NXDNPort; refl->m_count = "000"; refl->m_type = YT_YSF; + refl->m_wiresX = true; m_newReflectors.push_back(refl); @@ -212,6 +216,7 @@ bool CYSFReflectors::load() refl->m_port = m_YSF2P25Port; refl->m_count = "000"; refl->m_type = YT_YSF; + refl->m_wiresX = true; m_newReflectors.push_back(refl); @@ -227,12 +232,13 @@ bool CYSFReflectors::load() std::string desc = it->second; CYSFReflector* refl = new CYSFReflector; - refl->m_id = text; - refl->m_name = name; - refl->m_desc = desc; - refl->m_port = 0U; - refl->m_count = "000"; - refl->m_type = YT_FCS; + refl->m_id = text; + refl->m_name = name; + refl->m_desc = desc; + refl->m_port = 0U; + refl->m_count = "000"; + refl->m_type = YT_FCS; + refl->m_wiresX = false; refl->m_name.resize(16U, ' '); refl->m_desc.resize(14U, ' '); diff --git a/YSFGateway/YSFReflectors.h b/YSFGateway/YSFReflectors.h index b52092b..1bc5c05 100644 --- a/YSFGateway/YSFReflectors.h +++ b/YSFGateway/YSFReflectors.h @@ -39,7 +39,8 @@ public: m_count("000"), m_address(), m_port(0U), - m_type(YT_YSF) + m_type(YT_YSF), + m_wiresX(false) { } @@ -50,6 +51,7 @@ public: in_addr m_address; unsigned int m_port; YSF_TYPE m_type; + bool m_wiresX; }; class CYSFReflectors { From bee173f9e38b32b19f31d9af0e0985da41131073 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 29 Jan 2019 14:02:56 +0000 Subject: [PATCH 09/18] Add Wires-X DX Request to any network. --- YSFGateway/WiresX.cpp | 33 +++++++++++++++++++++++++++++---- YSFGateway/WiresX.h | 4 +++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index edde3a9..6a91b1c 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -429,11 +429,15 @@ void CWiresX::clock(unsigned int ms) } } -void CWiresX::createReply(const unsigned char* data, unsigned int length) +void CWiresX::createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network) { assert(data != NULL); assert(length > 0U); + // If we don't explicitly pass a network, use the default one. + if (network == NULL) + network = m_network; + unsigned char bt = 0U; if (length > 260U) { @@ -475,7 +479,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length) buffer[34U] = seqNo; seqNo += 2U; - m_network->write(buffer); + network->write(buffer); fich.setFI(YSF_FI_COMMUNICATIONS); @@ -522,7 +526,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length) buffer[34U] = seqNo; seqNo += 2U; - m_network->write(buffer); + network->write(buffer); fn++; if (fn >= 8U) { @@ -542,7 +546,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length) buffer[34U] = seqNo | 0x01U; - m_network->write(buffer); + network->write(buffer); } unsigned char CWiresX::calculateFT(unsigned int length, unsigned int offset) const @@ -637,6 +641,27 @@ void CWiresX::sendDXReply() m_seqNo++; } +void CWiresX::sendConnect(CYSFNetwork* network) +{ + unsigned char data[20U]; + ::memset(data, 0x00U, 20U); + ::memset(data, ' ', 16U); + + data[0U] = m_seqNo; + + for (unsigned int i = 0U; i < 3U; i++) + data[i + 1U] = DX_REQ[i]; + + data[15U] = 0x03U; // End of data marker + data[16U] = CCRC::addCRC(data, 16U); + + CUtils::dump(1U, "CONNECT", data, 20U); + + createReply(data, 20U, network); + + m_seqNo++; +} + void CWiresX::sendConnectReply() { assert(m_reflector != NULL); diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index ca490e5..201b197 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -64,6 +64,8 @@ public: void processConnect(CYSFReflector* reflector); void processDisconnect(const unsigned char* source = NULL); + void sendConnect(CYSFNetwork* network); + void clock(unsigned int ms); private: @@ -102,7 +104,7 @@ private: void sendSearchNotFoundReply(); void sendCategoryReply(); - void createReply(const unsigned char* data, unsigned int length); + void createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network = NULL); unsigned char calculateFT(unsigned int length, unsigned int offset) const; }; From 3cfa1a8d35722e13463226bea438f7437f147a77 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 15:41:09 +0000 Subject: [PATCH 10/18] Update YSFGateway.cpp Adds the WiresX link forward on connect to sub-ordinate gateway, this was the last piece.... --- YSFGateway/YSFGateway.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 4e1490d..9859411 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -539,6 +539,11 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_inactivityTimer.start(); m_lostTimer.start(); m_linkType = LINK_YSF; + + // If we are linking to a YSF2xxx mode, send the YSF2xxx gateway the link command too + if (reflector->m_name.rfind("YSF2DMR", 0) == 0 || reflector->m_name.rfind("YSF2P25", 0) == 0 || reflector->m_name.rfind("YSF2NXDN", 0) == 0) { + m_wiresX->sendConnect(m_ysfNetwork); + } } break; case WXS_CONNECT_FCS: { From 9d86e0711768178f8ce5f7f42b273568f4b78f98 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 16:02:43 +0000 Subject: [PATCH 11/18] Update YSFGateway.cpp Cleaned up the string compares, they are now so fast that I need to experiment with the timing - I can see why you detest the string compare :) --- YSFGateway/YSFGateway.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 9859411..c107c91 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -268,7 +268,7 @@ int CYSFGateway::run() unsigned char ft = fich.getFT(); CYSFReflector* reflector = m_wiresX->getReflector(); - if ( (wiresXCommandPassthrough) && (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) ) { + if ( (wiresXCommandPassthrough) && (reflector->reflector->m_wiresX) ) { // Allow WiresX to Pass Through processDTMF(buffer, dt); processWiresX(buffer, fi, dt, fn, ft, true); @@ -541,7 +541,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_linkType = LINK_YSF; // If we are linking to a YSF2xxx mode, send the YSF2xxx gateway the link command too - if (reflector->m_name.rfind("YSF2DMR", 0) == 0 || reflector->m_name.rfind("YSF2P25", 0) == 0 || reflector->m_name.rfind("YSF2NXDN", 0) == 0) { + if (reflector->m_wiresX) { m_wiresX->sendConnect(m_ysfNetwork); } } From 070cfb9ea2633c9f0a3d3b379025bfa46550c8e8 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 16:21:19 +0000 Subject: [PATCH 12/18] Update YSFGateway.cpp Remove typo --- YSFGateway/YSFGateway.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index c107c91..295ec9a 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -268,7 +268,7 @@ int CYSFGateway::run() unsigned char ft = fich.getFT(); CYSFReflector* reflector = m_wiresX->getReflector(); - if ( (wiresXCommandPassthrough) && (reflector->reflector->m_wiresX) ) { + if ( (wiresXCommandPassthrough) && (reflector->m_wiresX) ) { // Allow WiresX to Pass Through processDTMF(buffer, dt); processWiresX(buffer, fi, dt, fn, ft, true); From 8288d648485082f80c5e291bf5df93d875f361be Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 17:05:46 +0000 Subject: [PATCH 13/18] Update YSFGateway.cpp This is not exactly elegant, its not a state issue exactly, just cant read reflector->m_wiresX when there is no reflector... --- YSFGateway/YSFGateway.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 295ec9a..8da5b49 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -268,13 +268,22 @@ int CYSFGateway::run() unsigned char ft = fich.getFT(); CYSFReflector* reflector = m_wiresX->getReflector(); - if ( (wiresXCommandPassthrough) && (reflector->m_wiresX) ) { - // Allow WiresX to Pass Through - processDTMF(buffer, dt); - processWiresX(buffer, fi, dt, fn, ft, true); + if ( (wiresXCommandPassthrough) && (reflector) ) { + // Connected to a reflector, figure out what kind it is + if (reflector->m_wiresX) { + // Pass Control Commands (WiresX capable reflector) + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, true); + } + else { + // Don't Pass Control Commands (Not a WiresX capable reflector) + m_exclude = (dt == YSF_DT_DATA_FR_MODE); + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, false); + } } else { - // Don't Pass Control Commands + // Don't Pass Control Commands (Not connected to a reflector) m_exclude = (dt == YSF_DT_DATA_FR_MODE); processDTMF(buffer, dt); processWiresX(buffer, fi, dt, fn, ft, false); From 4327b23c918b22fb21a8118c1b388f2413f4e3dc Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 17:34:58 +0000 Subject: [PATCH 14/18] Update YSFGateway.cpp replace my code with yours... this seems to work well enough for testing, with one caveat, I need to remove YSF2xxx modes from the Pi-Star host files and modify the dashboard to cope without them in there, not a problem. --- YSFGateway/YSFGateway.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 8da5b49..b820cb6 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -268,9 +268,9 @@ int CYSFGateway::run() unsigned char ft = fich.getFT(); CYSFReflector* reflector = m_wiresX->getReflector(); - if ( (wiresXCommandPassthrough) && (reflector) ) { - // Connected to a reflector, figure out what kind it is - if (reflector->m_wiresX) { + if (m_ysfNetwork != NULL && m_linkType == LINK_YSF) { + // Connected to a YSF reflector, figure out what kind it is + if ( (wiresXCommandPassthrough) && (reflector->m_wiresX) ) { // Pass Control Commands (WiresX capable reflector) processDTMF(buffer, dt); processWiresX(buffer, fi, dt, fn, ft, true); From d3fe1515b3300a0443c10a2dbbd2cae8201e1f0e Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 18:49:08 +0000 Subject: [PATCH 15/18] Update YSFGateway.cpp Removed this in error while I was cleaning up the match code. This is clean enough and stable enough to merge it to the master branch, its functional, there are some edge cases left to clean up, but I cant yet tell if those are in YSFGateway or in the YSF2xxx modes. Either way, having more eyes on it would be a good thing. --- YSFGateway/YSFGateway.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index b820cb6..fc470dc 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -550,7 +550,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_linkType = LINK_YSF; // If we are linking to a YSF2xxx mode, send the YSF2xxx gateway the link command too - if (reflector->m_wiresX) { + if ( (wiresXCommandPassthrough) && (reflector->m_wiresX) ) { m_wiresX->sendConnect(m_ysfNetwork); } } From a848ccb216efc04885b44bed846574b14140d09b Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Tue, 29 Jan 2019 20:32:28 +0000 Subject: [PATCH 16/18] Alternate Disconnect Clicking the connected reflector on the Yaesu FT2D screen issues a command that WiresX.cpp could not cope with; M: 2019-01-29 20:27:58.615 0000: 2B 5D 63 5F 28 30 30 30 30 34 38 36 32 32 36 03 *+]c_(0000486226.* M: 2019-01-29 20:27:58.615 0010: 71 00 00 00 After a little trial and error, the radio appears to expect that to disconnect the connected reflector. This PR adds in this functionality. --- YSFGateway/WiresX.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index 6a91b1c..14e1c97 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -31,6 +31,7 @@ const unsigned char DX_REQ[] = {0x5DU, 0x71U, 0x5FU}; const unsigned char CONN_REQ[] = {0x5DU, 0x23U, 0x5FU}; const unsigned char DISC_REQ[] = {0x5DU, 0x2AU, 0x5FU}; +const unsigned char DISC_REQ2[] = {0x5DU, 0x63U, 0x5FU}; const unsigned char ALL_REQ[] = {0x5DU, 0x66U, 0x5FU}; const unsigned char CAT_REQ[] = {0x5DU, 0x67U, 0x5FU}; @@ -238,6 +239,9 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc } else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) { processDisconnect(source); return WXS_DISCONNECT; + } else if (::memcmp(m_command + 1U, DISC_REQ2, 3U) == 0) { + processDisconnect(source); + return WXS_DISCONNECT; } else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) { return WXS_NONE; } else { @@ -258,6 +262,9 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc } else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) { processDisconnect(source); return WXS_DISCONNECT; + } else if (::memcmp(m_command + 1U, DISC_REQ2, 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; From 76211e05bea3de1f4803b0172a57f47ff2ddfc61 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Wed, 30 Jan 2019 17:40:20 +0000 Subject: [PATCH 17/18] Update YSFGateway.cpp Added an extra field to the logic for sorting out when WiresX is processed locally and when it's not. This is done to make sure that the correct state is always matched, and that WiresX can only ever make it to a YSF2xxx subordinate, and that WiresX connect is ONLY generated when WiresX Passthrough is on. Added Logging to show when WiresX Command is sent to WiresX enabled subordinate YSF2xxx Gateway --- YSFGateway/YSFGateway.cpp | 47 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index fc470dc..4cd6eee 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -268,26 +268,24 @@ int CYSFGateway::run() unsigned char ft = fich.getFT(); CYSFReflector* reflector = m_wiresX->getReflector(); - if (m_ysfNetwork != NULL && m_linkType == LINK_YSF) { - // Connected to a YSF reflector, figure out what kind it is - if ( (wiresXCommandPassthrough) && (reflector->m_wiresX) ) { - // Pass Control Commands (WiresX capable reflector) - processDTMF(buffer, dt); - processWiresX(buffer, fi, dt, fn, ft, true); - } - else { - // Don't Pass Control Commands (Not a WiresX capable reflector) - m_exclude = (dt == YSF_DT_DATA_FR_MODE); - processDTMF(buffer, dt); - processWiresX(buffer, fi, dt, fn, ft, false); - } + if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough) { + if (reflector->m_wiresX) { + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, true, wiresXCommandPassthrough); + } else { + m_exclude = (dt == YSF_DT_DATA_FR_MODE); + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, false, wiresXCommandPassthrough); + } + } else if (wiresXCommandPassthrough) { + m_exclude = (dt == YSF_DT_DATA_FR_MODE); + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, false, wiresXCommandPassthrough); + } else { + m_exclude = (dt == YSF_DT_DATA_FR_MODE); + processDTMF(buffer, dt); + processWiresX(buffer, fi, dt, fn, ft, false, wiresXCommandPassthrough); } - else { - // Don't Pass Control Commands (Not connected to a reflector) - 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); @@ -523,11 +521,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, bool wiresXCommandPassthrough) +void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough) { assert(buffer != NULL); - WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft, wiresXCommandPassthrough); + WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft, dontProcessWiresXLocal); switch (status) { case WXS_CONNECT_YSF: { if (m_linkType == LINK_YSF) @@ -550,9 +548,10 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u m_linkType = LINK_YSF; // If we are linking to a YSF2xxx mode, send the YSF2xxx gateway the link command too - if ( (wiresXCommandPassthrough) && (reflector->m_wiresX) ) { - m_wiresX->sendConnect(m_ysfNetwork); - } + if (reflector->m_wiresX && wiresXCommandPassthrough) { + LogMessage("Forward WiresX Connect to \"%s\"", reflector->m_name.c_str()); + m_wiresX->sendConnect(m_ysfNetwork); + } } break; case WXS_CONNECT_FCS: { From 1e45d1addffa804fbc4e9342911a2216a19ea064 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Wed, 30 Jan 2019 17:41:43 +0000 Subject: [PATCH 18/18] Update YSFGateway.h Adding the extra variable --- YSFGateway/YSFGateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFGateway/YSFGateway.h b/YSFGateway/YSFGateway.h index 545f7b7..aad13b9 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, bool wiresXCommandPassthrough); + void processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough); void processDTMF(unsigned char* buffer, unsigned char dt); void createWiresX(CYSFNetwork* rptNetwork); void createGPS();