From 548edc37686a03af1c126345a8ddb386a8252353 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 2 Feb 2019 00:24:39 -0300 Subject: [PATCH] Fix Wires-X connection reply when reflector is busy --- YSFGateway/WiresX.cpp | 21 ++++++++++++++++++++- YSFGateway/WiresX.h | 4 +++- YSFGateway/YSFGateway.cpp | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/YSFGateway/WiresX.cpp b/YSFGateway/WiresX.cpp index 14e1c97..d4503f2 100644 --- a/YSFGateway/WiresX.cpp +++ b/YSFGateway/WiresX.cpp @@ -63,7 +63,9 @@ m_csd2(NULL), m_csd3(NULL), m_status(WXSI_NONE), m_start(0U), -m_search() +m_search(), +m_busy(false), +m_busyTimer(3000U, 1U) { assert(network != NULL); @@ -362,6 +364,9 @@ void CWiresX::processAll(const unsigned char* source, const unsigned char* data) WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned char* data) { + m_busy = true; + m_busyTimer.start(); + ::LogDebug("Received Connect to %5.5s from %10.10s", data, source); std::string id = std::string((char*)data, 5U); @@ -385,6 +390,9 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch void CWiresX::processConnect(CYSFReflector* reflector) { + m_busy = true; + m_busyTimer.start(); + m_reflector = reflector; m_status = WXSI_CONNECT; @@ -434,6 +442,12 @@ void CWiresX::clock(unsigned int ms) m_status = WXSI_NONE; m_timer.stop(); } + + m_busyTimer.clock(ms); + if (m_busyTimer.isRunning() && m_busyTimer.hasExpired()) { + m_busy = false; + m_busyTimer.stop(); + } } void CWiresX::createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network) @@ -1026,3 +1040,8 @@ void CWiresX::sendCategoryReply() m_seqNo++; } +bool CWiresX::isBusy() +{ + return m_busy; +} + diff --git a/YSFGateway/WiresX.h b/YSFGateway/WiresX.h index 201b197..0a21e39 100644 --- a/YSFGateway/WiresX.h +++ b/YSFGateway/WiresX.h @@ -55,6 +55,7 @@ public: void addFCSRoom(const std::string& id, const std::string& name); bool start(); + bool isBusy(); 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); @@ -89,7 +90,8 @@ private: unsigned int m_start; std::string m_search; std::vector m_category; - bool m_wiresXCommandPassthrough; + bool m_busy; + CTimer m_busyTimer; 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 21ae874..5ca3fe2 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -317,7 +317,7 @@ int CYSFGateway::run() while (m_ysfNetwork->read(buffer) > 0U) { if (m_linkType == LINK_YSF) { // Only pass through YSF data packets - if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0 && !m_wiresX->isBusy()) rptNetwork.write(buffer); m_lostTimer.start(); @@ -329,7 +329,7 @@ int CYSFGateway::run() while (m_fcsNetwork->read(buffer) > 0U) { if (m_linkType == LINK_FCS) { // Only pass through YSF data packets - if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) + if (::memcmp(buffer + 0U, "YSFD", 4U) == 0 && !m_wiresX->isBusy()) rptNetwork.write(buffer); m_lostTimer.start();