Reinstated the location field.

This commit is contained in:
Jonathan Naylor 2020-08-26 12:13:34 +01:00
parent a9c9ff6011
commit 98879b5c14
9 changed files with 40 additions and 16 deletions

View file

@ -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;

2
Conf.h
View file

@ -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;

View file

@ -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()

View file

@ -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();

View file

@ -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();

View file

@ -13,6 +13,7 @@ Daemon=0
RXFrequency=435000000
TXFrequency=435000000
Power=1
Location=Nowhere
[Log]
# Logging levels, 0=No logging

View file

@ -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) {

View file

@ -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);
}

View file

@ -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);