From 1606c4e644ce4dfee33d08dbd58cdc5b23108528 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 27 Aug 2020 10:37:26 +0100 Subject: [PATCH] Move the location to the DMR Gateway from the Host. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ DMRGateway.cpp | 8 +++++--- DMRGateway.ini | 1 + DMRNetwork.cpp | 4 ++-- MMDVMNetwork.cpp | 8 +++++--- Version.h | 2 +- 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 32d1478..6768326 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -63,6 +63,7 @@ m_logFileRoot(), m_infoLatitude(0.0F), m_infoLongitude(0.0F), m_infoHeight(0), +m_infoLocation(), m_infoDescription(), m_infoURL(), m_dmrNetwork1Enabled(false), @@ -287,6 +288,8 @@ bool CConf::read() m_infoLongitude = float(::atof(value)); else if (::strcmp(key, "Height") == 0) m_infoHeight = ::atoi(value); + else if (::strcmp(key, "Location") == 0) + m_infoLocation = value; else if (::strcmp(key, "Description") == 0) m_infoDescription = value; else if (::strcmp(key, "URL") == 0) @@ -1047,6 +1050,11 @@ int CConf::getInfoHeight() const return m_infoHeight; } +std::string CConf::getInfoLocation() const +{ + return m_infoLocation; +} + std::string CConf::getInfoDescription() const { return m_infoDescription; diff --git a/Conf.h b/Conf.h index 7fc7482..1a337b8 100644 --- a/Conf.h +++ b/Conf.h @@ -103,6 +103,7 @@ public: float getInfoLatitude() const; float getInfoLongitude() const; int getInfoHeight() const; + std::string getInfoLocation() const; std::string getInfoDescription() const; std::string getInfoURL() const; @@ -256,6 +257,7 @@ private: float m_infoLatitude; float m_infoLongitude; int m_infoHeight; + std::string m_infoLocation; std::string m_infoDescription; std::string m_infoURL; diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 464c6af..a688cf6 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -2360,12 +2360,14 @@ unsigned int CDMRGateway::getConfig(const std::string& name, unsigned char* buff if (height > 999) height = 999; + std::string location = m_conf.getInfoLocation(); std::string description = m_conf.getInfoDescription(); std::string url = m_conf.getInfoURL(); - ::sprintf((char*)buffer, "%30.30s%9.9s%9.9s%03d%-20.20s%-19.19s%c%-124.124s%80.80s", - m_config + 0U, latitude, longitude, height, m_config + 30U, - description.c_str(), m_config[50U], url.c_str(), m_config + 51U); + ::sprintf((char*)buffer, "%8.8s%9.9s%9.9s%2.2s%2.2s%9.9s%9.9s%03d%-20.20s%-19.19s%c%-124.124s%40.40s%40.40s", + m_config + 0U, m_config + 8U, m_config + 17U, m_config + 26U, m_config + 28U, + latitude, longitude, height, location.c_str(), + description.c_str(), m_config[30U], url.c_str(), m_config + 31U, m_config + 71U); LogInfo("%s: configuration message: %s", name.c_str(), buffer); diff --git a/DMRGateway.ini b/DMRGateway.ini index 4771d57..67a8d4c 100644 --- a/DMRGateway.ini +++ b/DMRGateway.ini @@ -26,6 +26,7 @@ Directory=./Audio Latitude=0.0 Longitude=0.0 Height=0 +Location=Nowhere Description=Multi-Mode Repeater URL=www.google.co.uk diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index b3c1a4b..d2b1cb4 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -534,8 +534,8 @@ bool CDMRNetwork::write(const unsigned char* data, unsigned int length) assert(data != NULL); assert(length > 0U); - // if (m_debug) - // CUtils::dump(1U, "Network Transmitted", data, length); + if (m_debug) + CUtils::dump(1U, "Network Transmitted", data, length); bool ret = m_socket.write(data, length, m_address, m_port); if (!ret) { diff --git a/MMDVMNetwork.cpp b/MMDVMNetwork.cpp index 571d935..3c73172 100644 --- a/MMDVMNetwork.cpp +++ b/MMDVMNetwork.cpp @@ -278,9 +278,11 @@ void CMMDVMNetwork::clock(unsigned int ms) } else if (::memcmp(m_buffer, "DMRC", 4U) == 0) { m_id = (m_buffer[4U] << 24) | (m_buffer[5U] << 16) | (m_buffer[6U] << 8) | (m_buffer[7U] << 0); - m_configLen = length - 8U; - m_configData = new unsigned char[m_configLen]; - ::memcpy(m_configData, m_buffer + 8U, m_configLen); + if (m_configData == NULL) { + m_configLen = length - 8U; + m_configData = new unsigned char[m_configLen]; + ::memcpy(m_configData, m_buffer + 8U, m_configLen); + } m_socket.write((unsigned char*)"DMRP", 4U, m_rptAddress, m_rptPort); } else { diff --git a/Version.h b/Version.h index 426bd2a..a4a9c51 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200826"; +const char* VERSION = "20200827"; #endif