From 83fbcaaf0ad740b1f45679542c51592fe98ad446 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 30 Aug 2020 14:42:40 +0100 Subject: [PATCH] Some cleanups. --- DMRGateway.cpp | 15 ++++++--------- DMRNetwork.cpp | 16 +--------------- DMRNetwork.h | 3 +-- Version.h | 2 +- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/DMRGateway.cpp b/DMRGateway.cpp index bb40ec8..3e94830 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -1344,7 +1344,7 @@ bool CDMRGateway::createDMRNetwork1() LogInfo(" Local: random"); LogInfo(" Location Data: %s", location ? "yes" : "no"); - m_dmrNetwork1 = new CDMRNetwork(address, port, local, id, password, m_dmr1Name, VERSION, location, debug); + m_dmrNetwork1 = new CDMRNetwork(address, port, local, id, password, m_dmr1Name, location, debug); std::string options = m_conf.getDMRNetwork1Options(); @@ -1511,7 +1511,7 @@ bool CDMRGateway::createDMRNetwork2() LogInfo(" Local: random"); LogInfo(" Location Data: %s", location ? "yes" : "no"); - m_dmrNetwork2 = new CDMRNetwork(address, port, local, id, password, m_dmr2Name, VERSION, location, debug); + m_dmrNetwork2 = new CDMRNetwork(address, port, local, id, password, m_dmr2Name, location, debug); std::string options = m_conf.getDMRNetwork2Options(); @@ -1678,7 +1678,7 @@ bool CDMRGateway::createDMRNetwork3() LogInfo(" Local: random"); LogInfo(" Location Data: %s", location ? "yes" : "no"); - m_dmrNetwork3 = new CDMRNetwork(address, port, local, id, password, m_dmr3Name, VERSION, location, debug); + m_dmrNetwork3 = new CDMRNetwork(address, port, local, id, password, m_dmr3Name, location, debug); std::string options = m_conf.getDMRNetwork3Options(); @@ -1845,7 +1845,7 @@ bool CDMRGateway::createDMRNetwork4() LogInfo(" Local: random"); LogInfo(" Location Data: %s", location ? "yes" : "no"); - m_dmrNetwork4 = new CDMRNetwork(address, port, local, id, password, m_dmr4Name, VERSION, location, debug); + m_dmrNetwork4 = new CDMRNetwork(address, port, local, id, password, m_dmr4Name, location, debug); std::string options = m_conf.getDMRNetwork4Options(); @@ -2012,7 +2012,7 @@ bool CDMRGateway::createDMRNetwork5() LogInfo(" Local: random"); LogInfo(" Location Data: %s", location ? "yes" : "no"); - m_dmrNetwork5 = new CDMRNetwork(address, port, local, id, password, m_dmr5Name, VERSION, location, debug); + m_dmrNetwork5 = new CDMRNetwork(address, port, local, id, password, m_dmr5Name, location, debug); std::string options = m_conf.getDMRNetwork5Options(); @@ -2255,7 +2255,7 @@ bool CDMRGateway::linkXLX(unsigned int number) m_xlxConnected = false; m_xlxRelink.stop(); - m_xlxNetwork = new CDMRNetwork(reflector->m_address, m_xlxPort, m_xlxLocal, m_xlxId, m_xlxPassword, "XLX", VERSION, false, m_xlxDebug); + m_xlxNetwork = new CDMRNetwork(reflector->m_address, m_xlxPort, m_xlxLocal, m_xlxId, m_xlxPassword, "XLX", false, m_xlxDebug); unsigned char config[400U]; unsigned int len = getConfig("XLX", config); @@ -2432,9 +2432,6 @@ void CDMRGateway::processTalkerAlias() if (!ret) return; - if (m_xlxNetwork != NULL && (m_status[1U] == DMRGWS_XLXREFLECTOR || m_status[2U] == DMRGWS_XLXREFLECTOR)) - m_xlxNetwork->writeTalkerAlias(buffer, length); - if (m_dmrNetwork1 != NULL && (m_status[1U] == DMRGWS_DMRNETWORK1 || m_status[2U] == DMRGWS_DMRNETWORK1)) m_dmrNetwork1->writeTalkerAlias(buffer, length); diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 832e2a4..eeb9142 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -31,13 +31,12 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; -CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, const char* version, bool location, bool debug) : +CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, bool location, bool debug) : m_address(), m_port(port), m_id(NULL), m_password(password), m_name(name), -m_version(version), m_location(location), m_debug(debug), m_socket(local), @@ -56,7 +55,6 @@ m_beacon(false) assert(port > 0U); assert(id > 1000U); assert(!password.empty()); - assert(version != NULL); m_address = CUDPSocket::lookup(address); @@ -221,9 +219,6 @@ bool CDMRNetwork::write(const CDMRData& data) buffer[54U] = data.getRSSI(); - if (m_debug) - CUtils::dump(1U, "Network Transmitted", buffer, HOMEBREW_DATA_PACKET_LENGTH); - write(buffer, HOMEBREW_DATA_PACKET_LENGTH); return true; @@ -336,9 +331,6 @@ void CDMRNetwork::clock(unsigned int ms) return; } - // if (m_debug && length > 0) - // CUtils::dump(1U, "Network Received", m_buffer, length); - if (length > 0 && m_address.s_addr == address.s_addr && m_port == port) { if (::memcmp(m_buffer, "DMRD", 4U) == 0) { if (m_debug) @@ -498,12 +490,6 @@ bool CDMRNetwork::writeConfig() ::memcpy(buffer + 4U, m_id, 4U); ::memcpy(buffer + 8U, m_configData, m_configLen); - char software[40U]; - ::sprintf(software, "DMRGateway-%s", m_version); - - ::memset(buffer + 222U, ' ', 40U); - ::memcpy(buffer + 222U, software, ::strlen(software)); - if (!m_location) ::memcpy(buffer + 38U, "0.00000000.000000", 17U); diff --git a/DMRNetwork.h b/DMRNetwork.h index 4448b71..a5e97b1 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -30,7 +30,7 @@ class CDMRNetwork { public: - CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, const char* version, bool location, bool debug); + CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, const std::string& name, bool location, bool debug); ~CDMRNetwork(); void setOptions(const std::string& options); @@ -63,7 +63,6 @@ private: uint8_t* m_id; std::string m_password; std::string m_name; - const char* m_version; bool m_location; bool m_debug; CUDPSocket m_socket; diff --git a/Version.h b/Version.h index 82fae7c..23ae81e 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200828"; +const char* VERSION = "20200830"; #endif