diff --git a/Conf.cpp b/Conf.cpp index 7491717d7..d2a460fc9 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -125,6 +125,7 @@ m_umpPort(), m_dstarEnabled(false), m_dstarModule("C"), m_dstarSelfOnly(false), +m_dstarRadioMode(false), m_dstarBlackList(), m_dstarAckReply(true), m_dstarAckTime(750U), @@ -555,6 +556,8 @@ bool CConf::read() m_dstarModule = value; } else if (::strcmp(key, "SelfOnly") == 0) m_dstarSelfOnly = ::atoi(value) == 1; + else if (::strcmp(key, "RadioMode") == 0) + m_dstarRadioMode = ::atoi(value) == 1; else if (::strcmp(key, "BlackList") == 0) { char* p = ::strtok(value, ",\r\n"); while (p != NULL) { @@ -1289,6 +1292,11 @@ bool CConf::getDStarSelfOnly() const return m_dstarSelfOnly; } +bool CConf::getDStarRadioMode() const +{ + return m_dstarRadioMode; +} + std::vector CConf::getDStarBlackList() const { return m_dstarBlackList; diff --git a/Conf.h b/Conf.h index 335d46150..5be341807 100644 --- a/Conf.h +++ b/Conf.h @@ -111,6 +111,7 @@ class CConf bool getDStarEnabled() const; std::string getDStarModule() const; bool getDStarSelfOnly() const; + bool getDStarRadioMode() const; std::vector getDStarBlackList() const; bool getDStarAckReply() const; unsigned int getDStarAckTime() const; @@ -387,6 +388,7 @@ class CConf bool m_dstarEnabled; std::string m_dstarModule; bool m_dstarSelfOnly; + bool m_dstarRadioMode; std::vector m_dstarBlackList; bool m_dstarAckReply; unsigned int m_dstarAckTime; diff --git a/DStarControl.cpp b/DStarControl.cpp index 9e089149f..052602a14 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -36,10 +36,11 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my) // #define DUMP_DSTAR -CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : +CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool dstarRadioMode, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : m_callsign(NULL), m_gateway(NULL), m_selfOnly(selfOnly), +m_dstarRadioMode(dstarRadioMode), m_ackReply(ackReply), m_ackMessage(ackMessage), m_errorReply(errorReply), @@ -214,8 +215,8 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH]; header.getMyCall1(my1); - // Is this a transmission destined for a repeater? - if (!header.isRepeater()) { + // Is this a transmission destined for a repeater? If we are in radio mode we want it anyway + if (!header.isRepeater() && !m_dstarRadioMode) { LogMessage("D-Star, non repeater RF header received from %8.8s", my1); m_rfState = RS_RF_INVALID; return false; @@ -224,8 +225,8 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) unsigned char callsign[DSTAR_LONG_CALLSIGN_LENGTH]; header.getRPTCall1(callsign); - // Is it for us? - if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) { + // Is it for us? If we are in radio mode, then its all for us! + if ((::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) && !m_dstarRadioMode) { LogMessage("D-Star, received RF header for wrong repeater (%8.8s) from %8.8s", callsign, my1); m_rfState = RS_RF_INVALID; return false; @@ -252,7 +253,13 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH]; header.getYourCall(your); - m_net = ::memcmp(gateway, m_gateway, DSTAR_LONG_CALLSIGN_LENGTH) == 0; + if((::memcmp(gateway, m_gateway, DSTAR_LONG_CALLSIGN_LENGTH) == 0) || m_dstarRadioMode){ + m_net = true; + } + else{ + m_net = false; + } + //m_net = ::memcmp(gateway, m_gateway, DSTAR_LONG_CALLSIGN_LENGTH) == 0; // Only start the timeout if not already running if (!m_rfTimeoutTimer.isRunning()) @@ -675,6 +682,11 @@ void CDStarControl::writeNetwork() m_netBits = 1U; m_netErrs = 0U; + if (m_dstarRadioMode) { + header.setRepeater(true); + header.get(data + 1U); + } + if (m_remoteGateway) { header.setRepeater(true); header.setRPTCall1(m_callsign); diff --git a/DStarControl.h b/DStarControl.h index 1598df249..8251c765f 100644 --- a/DStarControl.h +++ b/DStarControl.h @@ -37,7 +37,7 @@ class CDStarControl { public: - CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper); + CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool dstarRadioMode, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper); ~CDStarControl(); bool writeModem(unsigned char* data, unsigned int len); @@ -54,6 +54,7 @@ class CDStarControl { unsigned char* m_callsign; unsigned char* m_gateway; bool m_selfOnly; + bool m_dstarRadioMode; bool m_ackReply; bool m_ackMessage; bool m_errorReply; diff --git a/MMDVM.ini b/MMDVM.ini index ccc561b33..b42454bb2 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -87,6 +87,7 @@ Port=/dev/ttyACM1 Enable=1 Module=C SelfOnly=0 +RadioMode=0 AckReply=1 AckTime=750 AckMessage=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index f174b8350..c127072fd 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -409,6 +409,7 @@ int CMMDVMHost::run() if (m_dstarEnabled) { std::string module = m_conf.getDStarModule(); bool selfOnly = m_conf.getDStarSelfOnly(); + bool dstarRadioMode = m_conf.getDStarRadioMode(); std::vector blackList = m_conf.getDStarBlackList(); bool ackReply = m_conf.getDStarAckReply(); unsigned int ackTime = m_conf.getDStarAckTime(); @@ -430,7 +431,7 @@ int CMMDVMHost::run() if (blackList.size() > 0U) LogInfo(" Black List: %u", blackList.size()); - m_dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi); + m_dstar = new CDStarControl(m_callsign, module, selfOnly, dstarRadioMode, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi); } DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF;