From 36a852b38bc07e2cbec783440617c03f82258bcd Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sun, 14 Jun 2020 16:00:20 +0900 Subject: [PATCH 1/7] change ScreenLayout definition for Nextion to add new feature easily, the definition of ScreenLayout in [Nextion] has changed like this. ScreenLayout < 8: compatibile setting for old config file 0: G4KLX @ 9600bps 1: (reserved) 2: ON7LDS @ 9600bps 3: ON7LDS-DIY @ 9600bps 4: ON7LDS-DIY @ 115200bps ScreenLayout >= 8: new world, set the bit to enable each feature bit3 (8) use 115200bps bit4 (16) Display DMR Talker Alias bit5 (32) Colour change when displaying TA bit6 (64) Font size change when displaying long TA text bit7 (128) Display DIY status when MMDVM IDLE old settings are same as: 0 -> 0 2 -> 112 (16+32+64) 3 -> 144 (16+128) 4 -> 152 (8+16+128) --- Display.cpp | 2 +- Nextion.cpp | 106 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Display.cpp b/Display.cpp index 0b47b64..d0e6fd0 100644 --- a/Display.cpp +++ b/Display.cpp @@ -566,7 +566,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) } } else { SERIAL_SPEED baudrate = SERIAL_9600; - if (screenLayout==4U) + if (screenLayout&0x0cU) baudrate = SERIAL_115200; LogInfo(" Display baudrate: %u ",baudrate); diff --git a/Nextion.cpp b/Nextion.cpp index f15d6cf..adb8e76 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -38,6 +38,16 @@ const unsigned int P25_BER_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int NXDN_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms const unsigned int NXDN_BER_COUNT = 28U; // 28 * 40ms = 1120ms +#define LAYOUT_COMPAT_MASK (7 << 0) // compatibility for old setting +#define LAYOUT_TA_ENABLE (1 << 4) // enable Talker Alias (TA) display +#define LAYOUT_TA_COLOUR (1 << 5) // TA display with font colour change +#define LAYOUT_TA_FONTSIZE (1 << 6) // TA display with font size change +#define LAYOUT_DIY (1 << 7) // use ON7LDS-DIY layout + +// bit[3:2] is used in Display.cpp to set connection speed for LCD panel. +// 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, const std::string& location) : CDisplay(), m_callsign(callsign), @@ -49,7 +59,7 @@ m_mode(MODE_IDLE), m_displayClock(displayClock), m_utc(utc), m_idleBrightness(idleBrightness), -m_screenLayout(screenLayout), +m_screenLayout(0), m_clockDisplayTimer(1000U, 0U, 400U), m_rssiAccum1(0U), m_rssiAccum2(0U), @@ -68,6 +78,23 @@ m_location(location) { assert(serial != NULL); assert(brightness >= 0U && brightness <= 100U); + + static const unsigned int feature_set[] = { + 0, // 0: G4KLX + 0, // 1: (reserved, low speed) + // 2: ON7LDS + LAYOUT_TA_ENABLE | LAYOUT_TA_COLOUR | LAYOUT_TA_FONTSIZE, + LAYOUT_TA_ENABLE | LAYOUT_DIY, // 3: ON7LDS-DIY + LAYOUT_TA_ENABLE | LAYOUT_DIY, // 4: ON7LDS-DIY (high speed) + 0, // 5: (reserved, high speed) + 0, // 6: (reserved, high speed) + 0, // 7: (reserved, high speed) + }; + + if (screenLayout & ~LAYOUT_COMPAT_MASK) + m_screenLayout = screenLayout & ~LAYOUT_COMPAT_MASK; + else + m_screenLayout = feature_set[screenLayout]; } CNextion::~CNextion() @@ -118,7 +145,7 @@ void CNextion::setIdleInt() ::sprintf(command, "t0.txt=\"%s/%u\"", m_callsign.c_str(), m_dmrid); sendCommand(command); - if (m_screenLayout > 2U) { + if (m_screenLayout & LAYOUT_DIY) { ::sprintf(command, "t4.txt=\"%s\"", m_callsign.c_str()); sendCommand(command); ::sprintf(command, "t5.txt=\"%u\"", m_dmrid); @@ -350,17 +377,21 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro if (slotNo == 1U) { - if (m_screenLayout == 2U) { - sendCommand("t2.pco=0"); - sendCommand("t2.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t2.font=4"); } sendCommand("t2.txt=\"2 Listening\""); sendCommandAction(69U); } else { - if (m_screenLayout == 2U) { - sendCommand("t0.pco=0"); - sendCommand("t0.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t0.font=4"); } sendCommand("t0.txt=\"1 Listening\""); @@ -377,9 +408,11 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro if (slotNo == 1U) { ::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str()); - if (m_screenLayout == 2U) { - sendCommand("t0.pco=0"); - sendCommand("t0.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t0.font=4"); } sendCommand(text); @@ -391,9 +424,11 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro } else { ::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str()); - if (m_screenLayout == 2U) { - sendCommand("t2.pco=0"); - sendCommand("t2.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t2.font=4"); } sendCommand(text); @@ -448,15 +483,17 @@ void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi) void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type) { - if (m_screenLayout < 2U) + if (!(m_screenLayout & LAYOUT_TA_ENABLE)) return; if (type[0] == ' ') { if (slotNo == 1U) { - if (m_screenLayout == 2U) sendCommand("t0.pco=33808"); + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=33808"); sendCommandAction(64U); } else { - if (m_screenLayout == 2U) sendCommand("t2.pco=33808"); + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=33808"); sendCommandAction(72U); } @@ -467,33 +504,36 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, co char text[50U]; ::sprintf(text, "t0.txt=\"1 %s %s\"", type, talkerAlias); - if (m_screenLayout == 2U) { + if (m_screenLayout & LAYOUT_TA_FONTSIZE) { if (::strlen((char*)talkerAlias) > (16U-4U)) sendCommand("t0.font=3"); if (::strlen((char*)talkerAlias) > (20U-4U)) sendCommand("t0.font=2"); if (::strlen((char*)talkerAlias) > (24U-4U)) sendCommand("t0.font=1"); - - sendCommand("t0.pco=1024"); } + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=1024"); + sendCommand(text); sendCommandAction(63U); } else { char text[50U]; ::sprintf(text, "t2.txt=\"2 %s %s\"", type, talkerAlias); - if (m_screenLayout == 2U) { + if (m_screenLayout & LAYOUT_TA_FONTSIZE) { if (::strlen((char*)talkerAlias) > (16U-4U)) sendCommand("t2.font=3"); if (::strlen((char*)talkerAlias) > (20U-4U)) sendCommand("t2.font=2"); if (::strlen((char*)talkerAlias) > (24U-4U)) sendCommand("t2.font=1"); - - sendCommand("t2.pco=1024"); } + + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=1024"); + sendCommand(text); sendCommandAction(71U); } @@ -535,9 +575,11 @@ void CNextion::clearDMRInt(unsigned int slotNo) sendCommand("t0.txt=\"1 Listening\""); sendCommandAction(61U); - if (m_screenLayout == 2U) { - sendCommand("t0.pco=0"); - sendCommand("t0.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t0.font=4"); } sendCommand("t1.txt=\"\""); @@ -547,9 +589,11 @@ void CNextion::clearDMRInt(unsigned int slotNo) sendCommand("t2.txt=\"2 Listening\""); sendCommandAction(69U); - if (m_screenLayout == 2U) { - sendCommand("t2.pco=0"); - sendCommand("t2.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t2.font=4"); } sendCommand("t3.txt=\"\""); @@ -862,7 +906,7 @@ void CNextion::close() void CNextion::sendCommandAction(unsigned int status) { - if (m_screenLayout<3U) + if (!(m_screenLayout & LAYOUT_DIY)) return; char text[30U]; @@ -881,4 +925,4 @@ void CNextion::sendCommand(const char* command) // we must add a bit of a delay to allow the display to process the commands, else some are getting mangled. // 10 ms is just a guess, but seems to be sufficient. CThread::sleep(10U); - } +} From 3313fe8ec3528f107172855a240a8d7839e881cf Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 15 Jun 2020 17:00:37 +0100 Subject: [PATCH 2/7] Update OLED.cpp Modify the OLED code to only allow scroll commands when scrolling is enabled --- OLED.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index 6f9b4ec..02afc2d 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -240,7 +240,8 @@ void COLED::setIdleInt() // m_display.print("Idle"); // m_display.setTextSize(1); - m_display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen + if (m_displayScroll && m_displayLogoScreensaver) + m_display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen m_display.display(); unsigned char info[100U]; @@ -568,7 +569,8 @@ void COLED::writeCWInt() m_display.setTextSize(1); m_display.display(); - m_display.startscrollright(0x02,0x0f); + if (m_displayScroll) + m_display.startscrollright(0x02,0x0f); } void COLED::clearCWInt() @@ -581,14 +583,16 @@ void COLED::clearCWInt() m_display.setTextSize(1); m_display.display(); - m_display.startscrollleft(0x02,0x0f); + if (m_displayScroll) + m_display.startscrollleft(0x02,0x0f); } void COLED::close() { m_display.clearDisplay(); m_display.fillRect(0, 0, m_display.width(), 16, BLACK); - m_display.startscrollright(0x00,0x01); + if (m_displayScroll) + m_display.startscrollright(0x00,0x01); m_display.setCursor(0,00); m_display.setTextSize(2); m_display.print("-CLOSE-"); From 325b30d30b1111566c22cf107ed34fe3a689f79c Mon Sep 17 00:00:00 2001 From: Kimi Jin Date: Wed, 24 Jun 2020 13:33:23 +0800 Subject: [PATCH 3/7] Add install rules into Makefile. This will insatll MMDVMHost and RemoteCommand to /usr/local/bin/ path, so need exec with command 'sudo make install'. --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index e14f51c..984a3dc 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h From 1dc91b9a6459acf59f378589f13a8bec0b2c5d7f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 25 Jun 2020 09:55:28 +0100 Subject: [PATCH 4/7] Add the install target to the other makefiles. --- Makefile.Pi | 4 ++++ Makefile.Pi.Adafruit | 4 ++++ Makefile.Pi.HD44780 | 4 ++++ Makefile.Pi.OLED | 4 ++++ Makefile.Pi.PCF8574 | 4 ++++ Makefile.Solaris | 39 --------------------------------------- 6 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 Makefile.Solaris diff --git a/Makefile.Pi b/Makefile.Pi index d9c1acd..5a1334b 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index a9c0b35..fbeaf80 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -28,6 +28,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index a0127af..02ff78d 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 5629489..387a0a7 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index cd6b67f..5ac5b48 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -28,6 +28,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Solaris b/Makefile.Solaris deleted file mode 100644 index 4d46985..0000000 --- a/Makefile.Solaris +++ /dev/null @@ -1,39 +0,0 @@ -# This makefile is for Solaris using gcc - -CC = gcc -CXX = g++ -CFLAGS = -g -O3 -Wall -std=c++0x -pthread -LIBS = -lpthread -lsocket -LDFLAGS = -g - -OBJECTS = \ - AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ - DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o \ - NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o \ - NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o \ - P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o \ - StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o UserDB.o UserDBebtry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o \ - YSFNetwork.o YSFPayload.o - -all: MMDVMHost RemoteCommand - -MMDVMHost: GitVersion.h $(OBJECTS) - $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost - -RemoteCommand: Log.o RemoteCommand.o UDPSocket.o - $(CXX) Log.o RemoteCommand.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommand - -%.o: %.cpp - $(CXX) $(CFLAGS) -c -o $@ $< - -clean: - $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h - -# Export the current git version if the index file exists, else 000... -GitVersion.h: -ifneq ("$(wildcard .git/index)","") - echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ -else - echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ -endif From edce66701894d48424a0512bb9f4a20d89a8d9bc Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 29 Jun 2020 11:25:10 +0100 Subject: [PATCH 5/7] Replace MobileGPS with gpsd. --- Conf.cpp | 32 ++++++------- Conf.h | 14 +++--- GPSD.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++ MobileGPS.h => GPSD.h | 42 +++++++---------- MMDVM.ini | 4 +- MMDVMHost.cpp | 42 ++++++++++------- MMDVMHost.h | 6 ++- Makefile | 9 +++- Makefile.Pi | 8 +++- Makefile.Pi.Adafruit | 8 +++- Makefile.Pi.HD44780 | 9 +++- Makefile.Pi.OLED | 9 +++- Makefile.Pi.PCF8574 | 9 +++- MobileGPS.cpp | 101 ---------------------------------------- Version.h | 2 +- 15 files changed, 222 insertions(+), 177 deletions(-) create mode 100644 GPSD.cpp rename MobileGPS.h => GPSD.h (60%) delete mode 100644 MobileGPS.cpp diff --git a/Conf.cpp b/Conf.cpp index 8d61b30..5bc7dba 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -57,7 +57,7 @@ enum SECTION { SECTION_OLED, SECTION_LCDPROC, SECTION_LOCK_FILE, - SECTION_MOBILE_GPS, + SECTION_GPSD, SECTION_REMOTE_CONTROL }; @@ -283,9 +283,9 @@ m_lcdprocUTC(false), m_lcdprocDimOnIdle(false), m_lockFileEnabled(false), m_lockFileName(), -m_mobileGPSEnabled(false), -m_mobileGPSAddress(), -m_mobileGPSPort(0U), +m_gpsdEnabled(false), +m_gpsdAddress(), +m_gpsdPort(), m_remoteControlEnabled(false), m_remoteControlPort(0U) { @@ -367,8 +367,8 @@ bool CConf::read() section = SECTION_LCDPROC; else if (::strncmp(buffer, "[Lock File]", 11U) == 0) section = SECTION_LOCK_FILE; - else if (::strncmp(buffer, "[Mobile GPS]", 12U) == 0) - section = SECTION_MOBILE_GPS; + else if (::strncmp(buffer, "[GPSD]", 6U) == 0) + section = SECTION_GPSD; else if (::strncmp(buffer, "[Remote Control]", 16U) == 0) section = SECTION_REMOTE_CONTROL; else @@ -950,13 +950,13 @@ bool CConf::read() m_lockFileEnabled = ::atoi(value) == 1; else if (::strcmp(key, "File") == 0) m_lockFileName = value; - } else if (section == SECTION_MOBILE_GPS) { + } else if (section == SECTION_GPSD) { if (::strcmp(key, "Enable") == 0) - m_mobileGPSEnabled = ::atoi(value) == 1; + m_gpsdEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Address") == 0) - m_mobileGPSAddress = value; + m_gpsdAddress = value; else if (::strcmp(key, "Port") == 0) - m_mobileGPSPort = (unsigned int)::atoi(value); + m_gpsdPort = value; } else if (section == SECTION_REMOTE_CONTROL) { if (::strcmp(key, "Enable") == 0) m_remoteControlEnabled = ::atoi(value) == 1; @@ -2071,19 +2071,19 @@ std::string CConf::getLockFileName() const return m_lockFileName; } -bool CConf::getMobileGPSEnabled() const +bool CConf::getGPSDEnabled() const { - return m_mobileGPSEnabled; + return m_gpsdEnabled; } -std::string CConf::getMobileGPSAddress() const +std::string CConf::getGPSDAddress() const { - return m_mobileGPSAddress; + return m_gpsdAddress; } -unsigned int CConf::getMobileGPSPort() const +std::string CConf::getGPSDPort() const { - return m_mobileGPSPort; + return m_gpsdPort; } bool CConf::getRemoteControlEnabled() const diff --git a/Conf.h b/Conf.h index 77cff6c..a4f94eb 100644 --- a/Conf.h +++ b/Conf.h @@ -306,10 +306,10 @@ public: bool getLockFileEnabled() const; std::string getLockFileName() const; - // The Mobile GPS section - bool getMobileGPSEnabled() const; - std::string getMobileGPSAddress() const; - unsigned int getMobileGPSPort() const; + // The GPSD section + bool getGPSDEnabled() const; + std::string getGPSDAddress() const; + std::string getGPSDPort() const; // The Remote Control section bool getRemoteControlEnabled() const; @@ -565,9 +565,9 @@ private: bool m_lockFileEnabled; std::string m_lockFileName; - bool m_mobileGPSEnabled; - std::string m_mobileGPSAddress; - unsigned int m_mobileGPSPort; + bool m_gpsdEnabled; + std::string m_gpsdAddress; + std::string m_gpsdPort; bool m_remoteControlEnabled; unsigned int m_remoteControlPort; diff --git a/GPSD.cpp b/GPSD.cpp new file mode 100644 index 0000000..aec42f0 --- /dev/null +++ b/GPSD.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2018,2020 by Jonathan Naylor G4KLX + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "GPSD.h" + +#if defined(USE_GPS) + +#include +#include +#include +#include + +CGPSD::CGPSD(const std::string& address, const std::string& port, CDMRNetwork* network) : +m_gpsdAddress(address), +m_gpsdPort(port), +m_network(network), +m_gpsdData(), +m_idTimer(1000U, 60U) +{ + assert(!address.empty()); + assert(!port.empty()); + assert(network != NULL); +} + +CGPSD::~CGPSD() +{ +} + +bool CGPSD::open() +{ + int ret = ::gps_open(m_gpsdAddress.c_str(), m_gpsdPort.c_str(), &m_gpsdData); + if (ret != 0) { + LogError("Error when opening access to gpsd - %d - %s", errno, ::gps_errstr(errno)); + return false; + } + + ::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL); + + LogMessage("Connected to GPSD"); + + m_idTimer.start(); + + return true; +} + +void CGPSD::clock(unsigned int ms) +{ + m_idTimer.clock(ms); + + if (m_idTimer.hasExpired()) { + sendReport(); + m_idTimer.start(); + } +} + +void CGPSD::close() +{ + ::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL); + ::gps_close(&m_gpsdData); +} + +void CGPSD::sendReport() +{ + if (!::gps_waiting(&m_gpsdData, 0)) + return; + +#if GPSD_API_MAJOR_VERSION >= 7 + if (::gps_read(&m_gpsdData, NULL, 0) <= 0) + return; +#else + if (::gps_read(&m_gpsdData) <= 0) + return; +#endif + + if (m_gpsdData.status != STATUS_FIX) + return; + + bool latlonSet = (m_gpsdData.set & LATLON_SET) == LATLON_SET; + if (!latlonSet) + return; + + float latitude = float(m_gpsdData.fix.latitude); + float longitude = float(m_gpsdData.fix.longitude); + + m_network->writeHomePosition(latitude, longitude); +} + +#endif + diff --git a/MobileGPS.h b/GPSD.h similarity index 60% rename from MobileGPS.h rename to GPSD.h index 8d69572..d8838db 100644 --- a/MobileGPS.h +++ b/GPSD.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 2018,2020 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,32 +16,22 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef MobileGPS_H -#define MobileGPS_H +#ifndef GPSD_H +#define GPSD_H + +#if defined(USE_GPS) #include "DMRNetwork.h" -#include "UDPSocket.h" #include "Timer.h" #include -#if !defined(_WIN32) && !defined(_WIN64) -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#endif +#include -class CMobileGPS { +class CGPSD { public: - CMobileGPS(const std::string& address, unsigned int port, CDMRNetwork* network); - ~CMobileGPS(); + CGPSD(const std::string& address, const std::string& port, CDMRNetwork* network); + ~CGPSD(); bool open(); @@ -50,14 +40,16 @@ public: void close(); private: - CTimer m_idTimer; - in_addr m_address; - unsigned int m_port; - CUDPSocket m_socket; - CDMRNetwork* m_network; + std::string m_gpsdAddress; + std::string m_gpsdPort; + CDMRNetwork* m_network; + struct gps_data_t m_gpsdData; + CTimer m_idTimer; - bool pollGPS(); void sendReport(); }; #endif + +#endif + diff --git a/MMDVM.ini b/MMDVM.ini index 9b02e83..fc0e4db 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -288,10 +288,10 @@ UTC=0 Enable=0 File=/tmp/MMDVM_Active.lck -[Mobile GPS] +[GPSD] Enable=0 Address=127.0.0.1 -Port=7834 +Port=2947 [Remote Control] Enable=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8cbf318..b736a42 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -161,7 +161,9 @@ m_id(0U), m_cwCallsign(), m_lockFileEnabled(false), m_lockFileName(), -m_mobileGPS(NULL), +#if defined(USE_GPS) +m_gpsd(NULL), +#endif m_remoteControl(NULL), m_fixedMode(false) { @@ -1004,8 +1006,10 @@ int CMMDVMHost::run() if (m_pocsagNetwork != NULL) m_pocsagNetwork->clock(ms); - if (m_mobileGPS != NULL) - m_mobileGPS->clock(ms); +#if defined(USE_GPS) + if (m_gpsd != NULL) + m_gpsd->clock(ms); +#endif m_cwIdTimer.clock(ms); if (m_cwIdTimer.isRunning() && m_cwIdTimer.hasExpired()) { @@ -1082,10 +1086,12 @@ int CMMDVMHost::run() m_display->close(); delete m_display; - if (m_mobileGPS != NULL) { - m_mobileGPS->close(); - delete m_mobileGPS; +#if defined(USE_GPS) + if (m_gpsd != NULL) { + m_gpsd->close(); + delete m_gpsd; } +#endif if (m_ump != NULL) { m_ump->close(); @@ -1392,23 +1398,25 @@ bool CMMDVMHost::createDMRNetwork() return false; } - bool mobileGPSEnabled = m_conf.getMobileGPSEnabled(); - if (mobileGPSEnabled) { - std::string mobileGPSAddress = m_conf.getMobileGPSAddress(); - unsigned int mobileGPSPort = m_conf.getMobileGPSPort(); +#if defined(USE_GPS) + bool gpsdEnabled = m_conf.getGPSDEnabled(); + if (gpsdEnabled) { + std::string gpsdAddress = m_conf.getGPSDAddress(); + std::string gpsdPort = m_conf.getGPSDPort(); - LogInfo("Mobile GPS Parameters"); - LogInfo(" Address: %s", mobileGPSAddress.c_str()); - LogInfo(" Port: %u", mobileGPSPort); + LogInfo("GPSD Parameters"); + LogInfo(" Address: %s", gpsdAddress.c_str()); + LogInfo(" Port: %s", gpsdPort.c_str()); - m_mobileGPS = new CMobileGPS(address, port, m_dmrNetwork); + m_gpsd = new CGPSD(gpsdAddress, gpsdPort, m_dmrNetwork); - ret = m_mobileGPS->open(); + ret = m_gpsd->open(); if (!ret) { - delete m_mobileGPS; - m_mobileGPS = NULL; + delete m_gpsd; + m_gpsd = NULL; } } +#endif m_dmrNetwork->enable(true); diff --git a/MMDVMHost.h b/MMDVMHost.h index 6b1e078..4e2b039 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -34,11 +34,11 @@ #include "P25Network.h" #include "DMRNetwork.h" #include "DMRLookup.h" -#include "MobileGPS.h" #include "Display.h" #include "Timer.h" #include "Modem.h" #include "Conf.h" +#include "GPSD.h" #include "UMP.h" #include @@ -102,7 +102,9 @@ private: std::string m_cwCallsign; bool m_lockFileEnabled; std::string m_lockFileName; - CMobileGPS* m_mobileGPS; +#if defined(USE_GPS) + CGPSD* m_gpsd; +#endif CRemoteControl* m_remoteControl; bool m_fixedMode; diff --git a/Makefile b/Makefile index 984a3dc..029f36e 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,21 @@ CC = cc CXX = c++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread +#LIBS = -lpthread -lgps + LDFLAGS = -g OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o \ diff --git a/Makefile.Pi b/Makefile.Pi index 5a1334b..24650a3 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -2,14 +2,20 @@ CC = gcc CXX = g++ +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index fbeaf80..c273ce5 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -3,14 +3,20 @@ CC = gcc CXX = g++ +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index 02ff78d..eccc3cc 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -2,14 +2,21 @@ CC = gcc CXX = g++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 387a0a7..513e3f1 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -2,14 +2,21 @@ CC = gcc CXX = g++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DOLED -I/usr/local/include LIBS = -lArduiPi_OLED -lwiringPi -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DOLED -I/usr/local/include +#LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o OLED.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o I2CController.o OLED.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index 5ac5b48..ad46379 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -3,14 +3,21 @@ CC = gcc CXX = g++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/MobileGPS.cpp b/MobileGPS.cpp deleted file mode 100644 index 27721bd..0000000 --- a/MobileGPS.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2018 by Jonathan Naylor G4KLX - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "MobileGPS.h" - -#include -#include -#include -#include - -CMobileGPS::CMobileGPS(const std::string& address, unsigned int port, CDMRNetwork* network) : -m_idTimer(1000U, 60U), -m_address(), -m_port(port), -m_socket(), -m_network(network) -{ - assert(!address.empty()); - assert(port > 0U); - assert(network != NULL); - - m_address = CUDPSocket::lookup(address); -} - -CMobileGPS::~CMobileGPS() -{ -} - -bool CMobileGPS::open() -{ - bool ret = m_socket.open(); - if (!ret) - return false; - - m_idTimer.start(); - - return true; -} - -void CMobileGPS::clock(unsigned int ms) -{ - m_idTimer.clock(ms); - - if (m_idTimer.hasExpired()) { - pollGPS(); - m_idTimer.start(); - } - - sendReport(); -} - -void CMobileGPS::close() -{ - m_socket.close(); -} - -bool CMobileGPS::pollGPS() -{ - return m_socket.write((unsigned char*)"MMDVMHost", 9U, m_address, m_port); -} - -void CMobileGPS::sendReport() -{ - // Grab GPS data if it's available - unsigned char buffer[200U]; - in_addr address; - unsigned int port; - int ret = m_socket.read(buffer, 200U, address, port); - if (ret <= 0) - return; - - buffer[ret] = '\0'; - - // Parse the GPS data - char* pLatitude = ::strtok((char*)buffer, ",\n"); // Latitude - char* pLongitude = ::strtok(NULL, ",\n"); // Longitude - - if (pLatitude == NULL || pLongitude == NULL) - return; - - float latitude = float(::atof(pLatitude)); - float longitude = float(::atof(pLongitude)); - - m_network->writeHomePosition(latitude, longitude); -} - diff --git a/Version.h b/Version.h index 101ca94..68d6440 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200608"; +const char* VERSION = "20200629"; #endif From be8c29da3e62e6fb4a1b49132aa70936f7fc34f2 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 29 Jun 2020 11:50:33 +0100 Subject: [PATCH 6/7] Fix Windows compilation. --- MMDVMHost.vcxproj | 4 ++-- MMDVMHost.vcxproj.filters | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MMDVMHost.vcxproj b/MMDVMHost.vcxproj index 44b50f2..b17f851 100644 --- a/MMDVMHost.vcxproj +++ b/MMDVMHost.vcxproj @@ -183,13 +183,13 @@ + - @@ -281,12 +281,12 @@ + - diff --git a/MMDVMHost.vcxproj.filters b/MMDVMHost.vcxproj.filters index 01fcd3f..7168194 100644 --- a/MMDVMHost.vcxproj.filters +++ b/MMDVMHost.vcxproj.filters @@ -278,9 +278,6 @@ Header Files - - Header Files - Header Files @@ -305,6 +302,9 @@ Header Files + + Header Files + @@ -547,9 +547,6 @@ Source Files - - Source Files - Source Files @@ -574,5 +571,8 @@ Source Files + + Source Files + \ No newline at end of file From df47466aa2881ff3774f4660727c39227c97bc6c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 30 Jun 2020 11:38:25 +0100 Subject: [PATCH 7/7] Use USE_GPSD instead of USE_GPS. --- GPSD.cpp | 3 +-- GPSD.h | 3 +-- MMDVMHost.cpp | 8 ++++---- MMDVMHost.h | 2 +- Makefile | 2 +- Makefile.Pi | 2 +- Makefile.Pi.Adafruit | 2 +- Makefile.Pi.HD44780 | 2 +- Makefile.Pi.OLED | 2 +- Makefile.Pi.PCF8574 | 2 +- Version.h | 2 +- 11 files changed, 14 insertions(+), 16 deletions(-) diff --git a/GPSD.cpp b/GPSD.cpp index aec42f0..c06321a 100644 --- a/GPSD.cpp +++ b/GPSD.cpp @@ -18,7 +18,7 @@ #include "GPSD.h" -#if defined(USE_GPS) +#if defined(USE_GPSD) #include #include @@ -101,4 +101,3 @@ void CGPSD::sendReport() } #endif - diff --git a/GPSD.h b/GPSD.h index d8838db..cef93b5 100644 --- a/GPSD.h +++ b/GPSD.h @@ -19,7 +19,7 @@ #ifndef GPSD_H #define GPSD_H -#if defined(USE_GPS) +#if defined(USE_GPSD) #include "DMRNetwork.h" #include "Timer.h" @@ -52,4 +52,3 @@ private: #endif #endif - diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b736a42..b5a8aef 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -161,7 +161,7 @@ m_id(0U), m_cwCallsign(), m_lockFileEnabled(false), m_lockFileName(), -#if defined(USE_GPS) +#if defined(USE_GPSD) m_gpsd(NULL), #endif m_remoteControl(NULL), @@ -1006,7 +1006,7 @@ int CMMDVMHost::run() if (m_pocsagNetwork != NULL) m_pocsagNetwork->clock(ms); -#if defined(USE_GPS) +#if defined(USE_GPSD) if (m_gpsd != NULL) m_gpsd->clock(ms); #endif @@ -1086,7 +1086,7 @@ int CMMDVMHost::run() m_display->close(); delete m_display; -#if defined(USE_GPS) +#if defined(USE_GPSD) if (m_gpsd != NULL) { m_gpsd->close(); delete m_gpsd; @@ -1398,7 +1398,7 @@ bool CMMDVMHost::createDMRNetwork() return false; } -#if defined(USE_GPS) +#if defined(USE_GPSD) bool gpsdEnabled = m_conf.getGPSDEnabled(); if (gpsdEnabled) { std::string gpsdAddress = m_conf.getGPSDAddress(); diff --git a/MMDVMHost.h b/MMDVMHost.h index 4e2b039..3d77653 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -102,7 +102,7 @@ private: std::string m_cwCallsign; bool m_lockFileEnabled; std::string m_lockFileName; -#if defined(USE_GPS) +#if defined(USE_GPSD) CGPSD* m_gpsd; #endif CRemoteControl* m_remoteControl; diff --git a/Makefile b/Makefile index 029f36e..1ad3c8a 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread #LIBS = -lpthread -lgps LDFLAGS = -g diff --git a/Makefile.Pi b/Makefile.Pi index 24650a3..53e457e 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -7,7 +7,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index c273ce5..0a8fa85 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/l LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index eccc3cc..5417946 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 513e3f1..9949cf2 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DOLED -I/usr/local/include LIBS = -lArduiPi_OLED -lwiringPi -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DOLED -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DOLED -I/usr/local/include #LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index ad46379..aa84cc8 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -9,7 +9,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/lo LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Version.h b/Version.h index 68d6440..bb444d2 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200629"; +const char* VERSION = "20200630"; #endif