From a2d456b98f6d75dde0f9b04eeb6a5a11f15b4241 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 8 Mar 2016 17:26:51 +0000 Subject: [PATCH] Changes for DVMega via the host. --- DMRIPSC.cpp | 26 ++++++++++++++++---------- DMRIPSC.h | 6 +++--- DStarNetwork.cpp | 13 ++++++++++--- DStarNetwork.h | 5 +++-- MMDVMHost.cpp | 4 ++-- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index 0022f2a..70832b4 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -31,14 +31,14 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 53U; -CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug, bool slot1, bool slot2) : +CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2) : m_address(), m_port(port), m_id(NULL), m_password(password), -m_debug(debug), -m_software(software), +m_duplex(duplex), m_version(version), +m_debug(debug), m_socket(), m_enabled(false), m_slot1(slot1), @@ -427,13 +427,19 @@ bool CDMRIPSC::writeAuthorisation() bool CDMRIPSC::writeConfig() { + char* software = "MMDVM"; char slots = '0'; - if (m_slot1 && m_slot2) - slots = '3'; - else if (m_slot1 && !m_slot2) - slots = '1'; - else if (!m_slot1 && m_slot2) - slots = '2'; + if (m_duplex) { + if (m_slot1 && m_slot2) + slots = '3'; + else if (m_slot1 && !m_slot2) + slots = '1'; + else if (!m_slot1 && m_slot2) + slots = '2'; + } else { + software = "MMDVM-DVMega"; + slots = '4'; + } char buffer[400U]; @@ -442,7 +448,7 @@ bool CDMRIPSC::writeConfig() ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%08f%09f%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), m_rxFrequency, m_txFrequency, m_power, m_colorCode, m_latitude, m_longitude, m_height, m_location.c_str(), - m_description.c_str(), slots, m_url.c_str(), m_software, m_version); + m_description.c_str(), slots, m_url.c_str(), m_version, software); return write((unsigned char*)buffer, 302U); } diff --git a/DMRIPSC.h b/DMRIPSC.h index da8a16c..847d568 100644 --- a/DMRIPSC.h +++ b/DMRIPSC.h @@ -30,7 +30,7 @@ class CDMRIPSC { public: - CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug, bool slot1, bool slot2); + CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2); ~CDMRIPSC(); void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url); @@ -54,9 +54,9 @@ private: unsigned int m_port; uint8_t* m_id; std::string m_password; - bool m_debug; - const char* m_software; + bool m_duplex; const char* m_version; + bool m_debug; CUDPSocket m_socket; bool m_enabled; bool m_slot1; diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index 5eb37f3..443fcac 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -29,10 +29,11 @@ const unsigned int BUFFER_LENGTH = 100U; -CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, const std::string& version, bool debug) : +CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug) : m_socket(localPort), m_address(), m_port(gatewayPort), +m_duplex(duplex), m_version(version), m_debug(debug), m_enabled(false), @@ -174,9 +175,15 @@ void CDStarNetwork::clock(unsigned int ms) if (m_pollTimer.hasExpired()) { char text[60U]; #if defined(_WIN32) || defined(_WIN64) - ::sprintf(text, "win_mmdvm-%s", m_version.c_str()); + if (m_duplex) + ::sprintf(text, "win_mmdvm-%s", m_version); + else + ::sprintf(text, "win_mmdvm-dvmega-%s", m_version); #else - ::sprintf(text, "linux_mmdvm-%s", m_version.c_str()); + if (m_duplex) + ::sprintf(text, "linux_mmdvm-%s", m_version); + else + ::sprintf(text, "linux_mmdvm-dvmega-%s", m_version); #endif writePoll(text); m_pollTimer.start(); diff --git a/DStarNetwork.h b/DStarNetwork.h index 6cc03b0..aeebbbf 100644 --- a/DStarNetwork.h +++ b/DStarNetwork.h @@ -29,7 +29,7 @@ class CDStarNetwork { public: - CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, const std::string& version, bool debug); + CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug); ~CDStarNetwork(); bool open(); @@ -53,7 +53,8 @@ private: CUDPSocket m_socket; in_addr m_address; unsigned int m_port; - std::string m_version; + bool m_duplex; + const char* m_version; bool m_debug; bool m_enabled; uint16_t m_outId; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 97d2898..c271478 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -453,7 +453,7 @@ bool CMMDVMHost::createDStarNetwork() LogInfo(" Gateway Port: %u", gatewayPort); LogInfo(" Local Port: %u", localPort); - m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localPort, VERSION, debug); + m_dstarNetwork = new CDStarNetwork(gatewayAddress, gatewayPort, localPort, m_duplex, VERSION, debug); bool ret = m_dstarNetwork->open(); if (!ret) { @@ -483,7 +483,7 @@ bool CMMDVMHost::createDMRNetwork() LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled"); LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); - m_dmrNetwork = new CDMRIPSC(address, port, id, password, VERSION, "MMDVM", debug, slot1, slot2); + m_dmrNetwork = new CDMRIPSC(address, port, id, password, m_duplex, VERSION, debug, slot1, slot2); std::string callsign = m_conf.getCallsign(); unsigned int rxFrequency = m_conf.getRxFrequency();