Skip to content

Commit

Permalink
Reinstated the location field.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Aug 26, 2020
1 parent a9c9ff6 commit 98879b5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 16 deletions.
8 changes: 8 additions & 0 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CConf
unsigned int getRXFrequency() const;
unsigned int getTXFrequency() const;
unsigned int getPower() const;
std::string getLocation() const;

// The Log section
unsigned int getLogDisplayLevel() const;
Expand Down Expand Up @@ -315,6 +316,7 @@ class CConf
unsigned int m_rxFrequency;
unsigned int m_txFrequency;
unsigned int m_power;
std::string m_location;

unsigned int m_logDisplayLevel;
unsigned int m_logFileLevel;
Expand Down
10 changes: 7 additions & 3 deletions DMRNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion DMRNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CDMRNetwork
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();

Expand Down Expand Up @@ -78,6 +78,7 @@ class CDMRNetwork
unsigned int m_txFrequency;
unsigned int m_power;
unsigned int m_colorCode;
std::string m_location;
CTimer m_pingTimer;

bool writeConfig();
Expand Down
14 changes: 7 additions & 7 deletions Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,22 +556,22 @@ 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)
baudrate = SERIAL_115200;

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();
Expand Down
1 change: 1 addition & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Daemon=0
RXFrequency=435000000
TXFrequency=435000000
Power=1
Location=Nowhere

[Log]
# Logging levels, 0=No logging
Expand Down
6 changes: 4 additions & 2 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions Nextion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)"),
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -103,6 +103,7 @@ class CNextion : public CDisplay
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);
Expand Down

0 comments on commit 98879b5

Please sign in to comment.