diff --git a/Conf.cpp b/Conf.cpp index 2d3f5ff..bc2d6a5 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -71,6 +71,12 @@ m_daemon(false), m_rxFrequency(0U), m_txFrequency(0U), m_power(0U), +m_latitude(0.0F), +m_longitude(0.0F), +m_height(0), +m_location(), +m_description(), +m_url(), m_logDisplayLevel(0U), m_logFileLevel(0U), m_logFilePath(), @@ -424,6 +430,18 @@ bool CConf::read() m_rxFrequency = (unsigned int)::atoi(value); else if (::strcmp(key, "Power") == 0) m_power = (unsigned int)::atoi(value); + else if (::strcmp(key, "Latitude") == 0) + m_latitude = float(::atof(value)); + else if (::strcmp(key, "Longitude") == 0) + m_longitude = float(::atof(value)); + else if (::strcmp(key, "Height") == 0) + m_height = ::atoi(value); + else if (::strcmp(key, "Location") == 0) + m_location = value; + else if (::strcmp(key, "Description") == 0) + m_description = value; + else if (::strcmp(key, "URL") == 0) + m_url = value; } else if (section == SECTION_LOG) { if (::strcmp(key, "FilePath") == 0) m_logFilePath = value; @@ -1015,6 +1033,36 @@ unsigned int CConf::getPower() const return m_power; } +float CConf::getLatitude() const +{ + return m_latitude; +} + +float CConf::getLongitude() const +{ + return m_longitude; +} + +int CConf::getHeight() const +{ + return m_height; +} + +std::string CConf::getLocation() const +{ + return m_location; +} + +std::string CConf::getDescription() const +{ + return m_description; +} + +std::string CConf::getURL() const +{ + return m_url; +} + unsigned int CConf::getLogDisplayLevel() const { return m_logDisplayLevel; diff --git a/Conf.h b/Conf.h index 11cb4de..da2f78e 100644 --- a/Conf.h +++ b/Conf.h @@ -42,6 +42,12 @@ public: unsigned int getRXFrequency() const; unsigned int getTXFrequency() const; unsigned int getPower() const; + float getLatitude() const; + float getLongitude() const; + int getHeight() const; + std::string getLocation() const; + std::string getDescription() const; + std::string getURL() const; // The Log section unsigned int getLogDisplayLevel() const; @@ -319,6 +325,12 @@ private: unsigned int m_rxFrequency; unsigned int m_txFrequency; unsigned int m_power; + float m_latitude; + float m_longitude; + int m_height; + std::string m_location; + std::string m_description; + std::string m_url; unsigned int m_logDisplayLevel; unsigned int m_logFileLevel; diff --git a/DMRDirectNetwork.cpp b/DMRDirectNetwork.cpp index e178659..172fa17 100644 --- a/DMRDirectNetwork.cpp +++ b/DMRDirectNetwork.cpp @@ -58,6 +58,12 @@ m_rxFrequency(0U), m_txFrequency(0U), m_power(0U), m_colorCode(0U), +m_latitude(0.0F), +m_longitude(0.0F), +m_height(0), +m_location(), +m_description(), +m_url(), m_beacon(false) { assert(!address.empty()); @@ -103,13 +109,19 @@ void CDMRDirectNetwork::setOptions(const std::string& options) m_options = options; } -void CDMRDirectNetwork::setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode) +void CDMRDirectNetwork::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) { m_callsign = callsign; m_rxFrequency = rxFrequency; m_txFrequency = txFrequency; m_power = power; m_colorCode = colorCode; + m_latitude = latitude; + m_longitude = longitude; + m_height = height; + m_location = location; + m_description = description; + m_url = url; } bool CDMRDirectNetwork::open() @@ -573,31 +585,36 @@ bool CDMRDirectNetwork::writeConfig() case HWT_MMDVM_HS: software = "MMDVM_MMDVM_HS"; break; - case HWT_OPENGD77_HS: - software = "MMDVM_OpenGD77_HS"; - break; - case HWT_SKYBRIDGE: - software = "MMDVM_SkyBridge"; - break; default: software = "MMDVM_Unknown"; break; } } + char buffer[400U]; + + ::memcpy(buffer + 0U, "RPTC", 4U); + ::memcpy(buffer + 4U, m_id, 4U); + + char latitude[20U]; + ::sprintf(latitude, "%08f", m_latitude); + + char longitude[20U]; + ::sprintf(longitude, "%09f", m_longitude); + unsigned int power = m_power; if (power > 99U) power = 99U; - char buffer[150U]; + int height = m_height; + if (height > 999) + height = 999; - ::memcpy(buffer + 0U, "RPTC", 4U); - ::memcpy(buffer + 4U, m_id, 4U); - ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%c%-40.40s%-40.40s", - m_callsign.c_str(), m_rxFrequency, m_txFrequency, power, m_colorCode, slots, m_version, - software); + ::sprintf(buffer + 8U, "%-8.8s%09u%09u%02u%02u%8.8s%9.9s%03d%-20.20s%-19.19s%c%-124.124s%-40.40s%-40.40s", m_callsign.c_str(), + m_rxFrequency, m_txFrequency, power, m_colorCode, latitude, longitude, height, m_location.c_str(), + m_description.c_str(), slots, m_url.c_str(), m_version, software); - return write((unsigned char*)buffer, 119U); + return write((unsigned char*)buffer, 302U); } bool CDMRDirectNetwork::writePing() diff --git a/DMRDirectNetwork.h b/DMRDirectNetwork.h index ecd1a3c..896d5e4 100644 --- a/DMRDirectNetwork.h +++ b/DMRDirectNetwork.h @@ -37,7 +37,7 @@ public: virtual void setOptions(const std::string& options); - virtual void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode); + virtual 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); virtual bool open(); @@ -97,7 +97,12 @@ private: unsigned int m_txFrequency; unsigned int m_power; unsigned int m_colorCode; - + float m_latitude; + float m_longitude; + int m_height; + std::string m_location; + std::string m_description; + std::string m_url; bool m_beacon; bool writeLogin(); diff --git a/DMRGatewayNetwork.cpp b/DMRGatewayNetwork.cpp index 06776e9..9c9f551 100644 --- a/DMRGatewayNetwork.cpp +++ b/DMRGatewayNetwork.cpp @@ -90,7 +90,7 @@ CDMRGatewayNetwork::~CDMRGatewayNetwork() delete[] m_id; } -void CDMRGatewayNetwork::setConfig(const std::string & callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode) +void CDMRGatewayNetwork::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) { m_callsign = callsign; m_rxFrequency = rxFrequency; diff --git a/DMRGatewayNetwork.h b/DMRGatewayNetwork.h index 0fc74e2..55afc72 100644 --- a/DMRGatewayNetwork.h +++ b/DMRGatewayNetwork.h @@ -38,7 +38,7 @@ public: virtual void setOptions(const std::string& options); - virtual void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode); + virtual 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); virtual bool open(); diff --git a/DMRNetwork.h b/DMRNetwork.h index cf96692..69d3926 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -30,7 +30,7 @@ public: virtual void setOptions(const std::string& options) = 0; - virtual void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode) = 0; + virtual 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) = 0; virtual bool open() = 0; diff --git a/MMDVM.ini b/MMDVM.ini index ca886fe..2b3dcd1 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -13,6 +13,13 @@ Daemon=0 RXFrequency=435000000 TXFrequency=435000000 Power=1 +# The following lines are only needed if a direct connection to a DMR master is being used +Latitude=0.0 +Longitude=0.0 +Height=0 +Location=Nowhere +Description=Multi-Mode Repeater +URL=www.google.co.uk [Log] # Logging levels, 0=No logging diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index f4ccfae..17781b7 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1370,8 +1370,26 @@ bool CMMDVMHost::createDMRNetwork() LogInfo(" TX Frequency: %uHz", txFrequency); LogInfo(" Power: %uW", power); - m_dmrNetwork->setConfig(m_callsign, rxFrequency, txFrequency, power, colorCode); + if (type == "Direct") { + float latitude = m_conf.getLatitude(); + float longitude = m_conf.getLongitude(); + int height = m_conf.getHeight(); + std::string location = m_conf.getLocation(); + std::string description = m_conf.getDescription(); + std::string url = m_conf.getURL(); + LogInfo(" Latitude: %fdeg N", latitude); + LogInfo(" Longitude: %fdeg E", longitude); + LogInfo(" Height: %um", height); + LogInfo(" Location: \"%s\"", location.c_str()); + LogInfo(" Description: \"%s\"", description.c_str()); + LogInfo(" URL: \"%s\"", url.c_str()); + + m_dmrNetwork->setConfig(m_callsign, rxFrequency, txFrequency, power, colorCode, latitude, longitude, height, location, description, url); + } else { + m_dmrNetwork->setConfig(m_callsign, rxFrequency, txFrequency, power, colorCode, 0.0F, 0.0F, 0, "", "", ""); + } + if (!options.empty()) { LogInfo(" Options: %s", options.c_str()); diff --git a/Version.h b/Version.h index 5f311da..508710c 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20201208"; +const char* VERSION = "20201209"; #endif