From 98879b5c14ec6691a686374dacf794a6ca8e22c6 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 26 Aug 2020 12:13:34 +0100 Subject: [PATCH] Reinstated the location field. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ DMRNetwork.cpp | 10 +++++++--- DMRNetwork.h | 3 ++- Display.cpp | 14 +++++++------- MMDVM.ini | 1 + MMDVMHost.cpp | 6 ++++-- Nextion.cpp | 9 +++++++-- Nextion.h | 3 ++- 9 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 8b2578b..4410443 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -71,6 +71,7 @@ m_daemon(false), m_rxFrequency(0U), m_txFrequency(0U), m_power(0U), +m_location(), m_logDisplayLevel(0U), m_logFileLevel(0U), m_logFilePath(), @@ -420,6 +421,8 @@ 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, "Location") == 0) + m_location = value; } else if (section == SECTION_LOG) { if (::strcmp(key, "FilePath") == 0) m_logFilePath = value; @@ -993,6 +996,11 @@ unsigned int CConf::getPower() const return m_power; } +std::string CConf::getLocation() const +{ + return m_location; +} + unsigned int CConf::getLogDisplayLevel() const { return m_logDisplayLevel; diff --git a/Conf.h b/Conf.h index f75fdb4..3e868ef 100644 --- a/Conf.h +++ b/Conf.h @@ -42,6 +42,7 @@ public: unsigned int getRXFrequency() const; unsigned int getTXFrequency() const; unsigned int getPower() const; + std::string getLocation() const; // The Log section unsigned int getLogDisplayLevel() const; @@ -315,6 +316,7 @@ private: unsigned int m_rxFrequency; unsigned int m_txFrequency; unsigned int m_power; + std::string m_location; unsigned int m_logDisplayLevel; unsigned int m_logFileLevel; diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 061cac3..d784e21 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -55,6 +55,7 @@ m_rxFrequency(0U), m_txFrequency(0U), m_power(0U), m_colorCode(0U), +m_location(), m_pingTimer(1000U, 10U) { assert(!address.empty()); @@ -88,13 +89,14 @@ CDMRNetwork::~CDMRNetwork() delete[] m_id; } -void CDMRNetwork::setConfig(const std::string & callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode) +void CDMRNetwork::setConfig(const std::string & callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, const std::string& location) { m_callsign = callsign; m_rxFrequency = rxFrequency; m_txFrequency = txFrequency; m_power = power; m_colorCode = colorCode; + m_location = location; } bool CDMRNetwork::open() @@ -403,9 +405,11 @@ bool CDMRNetwork::writeConfig() ::memcpy(buffer + 0U, "DMRC", 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%-20.20s%c%-40.40s%-40.40s", + m_callsign.c_str(), m_rxFrequency, m_txFrequency, power, m_colorCode, m_location.c_str(), slots, m_version, + software); - return write((unsigned char*)buffer, 119U); + return write((unsigned char*)buffer, 139U); } bool CDMRNetwork::wantsBeacon() diff --git a/DMRNetwork.h b/DMRNetwork.h index 9f01925..7539ec3 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -35,7 +35,7 @@ public: CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType); ~CDMRNetwork(); - void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode); + void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, const std::string& location); bool open(); @@ -78,6 +78,7 @@ private: unsigned int m_txFrequency; unsigned int m_power; unsigned int m_colorCode; + std::string m_location; CTimer m_pingTimer; bool writeConfig(); diff --git a/Display.cpp b/Display.cpp index 29f00d0..6238d57 100644 --- a/Display.cpp +++ b/Display.cpp @@ -556,14 +556,14 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) if (port == "modem") { ISerialPort* serial = new CModemSerialPort(modem); - display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF); + display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF, conf.getLocation()); } else if (port == "ump") { if (ump != NULL) { - display = new CNextion(conf.getCallsign(), dmrid, ump, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF); - } else { - LogInfo(" NullDisplay loaded"); - display = new CNullDisplay; - } + display = new CNextion(conf.getCallsign(), dmrid, ump, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF, conf.getLocation()); + } else { + LogInfo(" NullDisplay loaded"); + display = new CNullDisplay; + } } else { SERIAL_SPEED baudrate = SERIAL_9600; if (screenLayout&0x0cU) @@ -571,7 +571,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) LogInfo(" Display baudrate: %u ",baudrate); ISerialPort* serial = new CSerialController(port, baudrate); - display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF); + display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF, conf.getLocation()); } } else if (type == "LCDproc") { std::string address = conf.getLCDprocAddress(); diff --git a/MMDVM.ini b/MMDVM.ini index 9600db8..c4f11e0 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -13,6 +13,7 @@ Daemon=0 RXFrequency=435000000 TXFrequency=435000000 Power=1 +Location=Nowhere [Log] # Logging levels, 0=No logging diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8faff95..8a6c5d0 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1345,14 +1345,16 @@ bool CMMDVMHost::createDMRNetwork() unsigned int txFrequency = m_conf.getTXFrequency(); unsigned int power = m_conf.getPower(); unsigned int colorCode = m_conf.getDMRColorCode(); + std::string location = m_conf.getLocation(); - LogInfo("RF Parameters"); + LogInfo("Info Parameters"); LogInfo(" Callsign: %s", m_callsign.c_str()); LogInfo(" RX Frequency: %uHz", rxFrequency); LogInfo(" TX Frequency: %uHz", txFrequency); LogInfo(" Power: %uW", power); + LogInfo(" Location: \"%s\"", location.c_str()); - m_dmrNetwork->setConfig(m_callsign, rxFrequency, txFrequency, power, colorCode); + m_dmrNetwork->setConfig(m_callsign, rxFrequency, txFrequency, power, colorCode, location); bool ret = m_dmrNetwork->open(); if (!ret) { diff --git a/Nextion.cpp b/Nextion.cpp index fa6851e..b5253c1 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -47,7 +47,7 @@ const unsigned int NXDN_BER_COUNT = 28U; // 28 * 40ms = 1120ms // 00:low, others:high-speed. bit[2] is overlapped with LAYOUT_COMPAT_MASK. #define LAYOUT_HIGHSPEED (3 << 2) -CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness, unsigned int screenLayout, unsigned int txFrequency, unsigned int rxFrequency, bool displayTempInF) : +CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness, unsigned int screenLayout, unsigned int txFrequency, unsigned int rxFrequency, bool displayTempInF, const std::string& location) : CDisplay(), m_callsign(callsign), m_ipaddress("(ip unknown)"), @@ -72,7 +72,8 @@ m_txFrequency(txFrequency), m_rxFrequency(rxFrequency), m_fl_txFrequency(0.0F), m_fl_rxFrequency(0.0F), -m_displayTempInF(displayTempInF) +m_displayTempInF(displayTempInF), +m_location(location) { assert(serial != NULL); assert(brightness >= 0U && brightness <= 100U); @@ -177,6 +178,10 @@ void CNextion::setIdleInt() sendCommandAction(22U); } } + + ::sprintf(command, "t31.txt=\"%s\"", m_location.c_str()); // location + sendCommand(command); + sendCommandAction(23U); } else { sendCommandAction(17U); } diff --git a/Nextion.h b/Nextion.h index 488372f..7217d2a 100644 --- a/Nextion.h +++ b/Nextion.h @@ -29,7 +29,7 @@ class CNextion : public CDisplay { public: - CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness, unsigned int screenLayout, unsigned int txFrequency, unsigned int rxFrequency, bool displayTempInF); + CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness, unsigned int screenLayout, unsigned int txFrequency, unsigned int rxFrequency, bool displayTempInF, const std::string& location); virtual ~CNextion(); virtual bool open(); @@ -103,6 +103,7 @@ private: double m_fl_txFrequency; double m_fl_rxFrequency; bool m_displayTempInF; + std::string m_location; void sendCommand(const char* command); void sendCommandAction(unsigned int status);