From afe593d7b53f5792029c855b1b0f3240aba3f577 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 4 Jun 2018 21:56:10 +0100 Subject: [PATCH] Add identification of the DMR Gateway to connected networks. --- DMRGateway.cpp | 8 ++++---- DMRNetwork.cpp | 12 ++++++++++-- DMRNetwork.h | 5 +++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/DMRGateway.cpp b/DMRGateway.cpp index c0712a7..ff331b2 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -997,7 +997,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, debug); + m_dmrNetwork1 = new CDMRNetwork(address, port, local, id, password, m_dmr1Name, VERSION, debug); std::string options = m_conf.getDMRNetwork1Options(); if (options.empty()) @@ -1124,7 +1124,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, debug); + m_dmrNetwork2 = new CDMRNetwork(address, port, local, id, password, m_dmr2Name, VERSION, debug); std::string options = m_conf.getDMRNetwork2Options(); if (options.empty()) @@ -1251,7 +1251,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, debug); + m_dmrNetwork3 = new CDMRNetwork(address, port, local, id, password, m_dmr3Name, VERSION, debug); std::string options = m_conf.getDMRNetwork3Options(); if (options.empty()) @@ -1427,7 +1427,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", m_xlxDebug); + m_xlxNetwork = new CDMRNetwork(reflector->m_address, m_xlxPort, m_xlxLocal, m_xlxId, m_xlxPassword, "XLX", VERSION, m_xlxDebug); unsigned char config[400U]; unsigned int len = getConfig("XLX", config); diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 72c0940..cac3e7e 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,12 +31,13 @@ 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, 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, const char* version, bool debug) : m_address(), m_port(port), m_id(NULL), m_password(password), m_name(name), +m_version(version), m_debug(debug), m_socket(local), m_status(WAITING_CONNECT), @@ -54,6 +55,7 @@ m_beacon(false) assert(port > 0U); assert(id > 1000U); assert(!password.empty()); + assert(version != NULL); m_address = CUDPSocket::lookup(address); @@ -473,6 +475,12 @@ 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)); + return write((unsigned char*)buffer, m_configLen + 8U); } diff --git a/DMRNetwork.h b/DMRNetwork.h index 2e40e76..d37a9f9 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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, bool debug); + 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 debug); ~CDMRNetwork(); void setOptions(const std::string& options); @@ -61,6 +61,7 @@ private: uint8_t* m_id; std::string m_password; std::string m_name; + const char* m_version; bool m_debug; CUDPSocket m_socket;