Make the use of gpsd optional.

This commit is contained in:
Jonathan Naylor 2020-06-21 18:02:05 +01:00
parent 7f71576b5f
commit 94db475b2e
5 changed files with 21 additions and 14 deletions

View file

@ -125,7 +125,7 @@ m_array(),
m_aprsAddress(), m_aprsAddress(),
m_aprsPort(port), m_aprsPort(port),
m_aprsSocket() m_aprsSocket()
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
,m_gpsdEnabled(false), ,m_gpsdEnabled(false),
m_gpsdAddress(), m_gpsdAddress(),
m_gpsdPort(), m_gpsdPort(),
@ -162,7 +162,7 @@ void CAPRSWriter::setPortFixed(const wxString& callsign, const wxString& band, d
void CAPRSWriter::setPortGPSD(const wxString& callsign, const wxString& band, double frequency, double offset, double range, const wxString& address, const wxString& port) void CAPRSWriter::setPortGPSD(const wxString& callsign, const wxString& band, double frequency, double offset, double range, const wxString& address, const wxString& port)
{ {
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
wxASSERT(!address.IsEmpty()); wxASSERT(!address.IsEmpty());
wxASSERT(!port.IsEmpty()); wxASSERT(!port.IsEmpty());
@ -180,7 +180,7 @@ void CAPRSWriter::setPortGPSD(const wxString& callsign, const wxString& band, do
bool CAPRSWriter::open() bool CAPRSWriter::open()
{ {
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
if (m_gpsdEnabled) { if (m_gpsdEnabled) {
int ret = ::gps_open(m_gpsdAddress.mb_str(), m_gpsdPort.mb_str(), &m_gpsdData); int ret = ::gps_open(m_gpsdAddress.mb_str(), m_gpsdPort.mb_str(), &m_gpsdData);
if (ret != 0) { if (ret != 0) {
@ -293,7 +293,7 @@ void CAPRSWriter::clock(unsigned int ms)
{ {
m_idTimer.clock(ms); m_idTimer.clock(ms);
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
if (m_gpsdEnabled) { if (m_gpsdEnabled) {
if (m_idTimer.hasExpired()) { if (m_idTimer.hasExpired()) {
sendIdFramesMobile(); sendIdFramesMobile();
@ -307,7 +307,7 @@ void CAPRSWriter::clock(unsigned int ms)
m_idTimer.setTimeout(20U * 60U); m_idTimer.setTimeout(20U * 60U);
m_idTimer.start(); m_idTimer.start();
} }
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
} }
#endif #endif
for (CEntry_t::iterator it = m_array.begin(); it != m_array.end(); ++it) for (CEntry_t::iterator it = m_array.begin(); it != m_array.end(); ++it)
@ -318,7 +318,7 @@ void CAPRSWriter::close()
{ {
m_aprsSocket.close(); m_aprsSocket.close();
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
if (m_gpsdEnabled) { if (m_gpsdEnabled) {
::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL); ::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL);
::gps_close(&m_gpsdData); ::gps_close(&m_gpsdData);
@ -439,6 +439,7 @@ void CAPRSWriter::sendIdFramesFixed()
} }
} }
#if defined(USE_GPSD)
void CAPRSWriter::sendIdFramesMobile() void CAPRSWriter::sendIdFramesMobile()
{ {
if (!m_gpsdEnabled) if (!m_gpsdEnabled)
@ -596,4 +597,4 @@ void CAPRSWriter::sendIdFramesMobile()
} }
} }
} }
#endif

View file

@ -27,7 +27,7 @@
#include "Timer.h" #include "Timer.h"
#include "Defs.h" #include "Defs.h"
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
#include <gps.h> #include <gps.h>
#endif #endif
@ -95,7 +95,7 @@ private:
in_addr m_aprsAddress; in_addr m_aprsAddress;
unsigned int m_aprsPort; unsigned int m_aprsPort;
CUDPReaderWriter m_aprsSocket; CUDPReaderWriter m_aprsSocket;
#if !defined(_WIN32) && !defined(_WIN64) #if defined(USE_GPSD)
bool m_gpsdEnabled; bool m_gpsdEnabled;
wxString m_gpsdAddress; wxString m_gpsdAddress;
wxString m_gpsdPort; wxString m_gpsdPort;

View file

@ -24,9 +24,9 @@
const wxString VENDOR_NAME = wxT("G4KLX"); const wxString VENDOR_NAME = wxT("G4KLX");
#if defined(__WXDEBUG__) #if defined(__WXDEBUG__)
const wxString VERSION = wxT("20200605 - DEBUG"); const wxString VERSION = wxT("20200621 - DEBUG");
#else #else
const wxString VERSION = wxT("20190605"); const wxString VERSION = wxT("20190621");
#endif #endif
#endif #endif

View file

@ -14,6 +14,9 @@ endif
# Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet # Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet
# Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet # Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet
# Add -DUSE_GPS to the end of the CFLAGS line to enable the use of gpsd, and add -lgps to
# end of the LIBS line.
DEBUGFLAGS := -g -D_DEBUG DEBUGFLAGS := -g -D_DEBUG
RELEASEFLAGS := -DNDEBUG -DwxDEBUG_LEVEL=0 RELEASEFLAGS := -DNDEBUG -DwxDEBUG_LEVEL=0
export CXX := $(shell wx-config --cxx) export CXX := $(shell wx-config --cxx)
@ -23,7 +26,7 @@ ifeq ($(BUILD), debug)
else ifeq ($(BUILD), release) else ifeq ($(BUILD), release)
export CFLAGS := $(CFLAGS) $(RELEASEFLAGS) export CFLAGS := $(CFLAGS) $(RELEASEFLAGS)
endif endif
export LIBS := $(shell wx-config --libs base,net) -lgps export LIBS := $(shell wx-config --libs base,net)
export LDFLAGS := export LDFLAGS :=
.PHONY: all .PHONY: all

View file

@ -13,10 +13,13 @@ endif
# Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet # Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet
# Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet # Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet
# Add -DUSE_GPS to the end of the CFLAGS line to enable the use of gpsd, and add -lgps to
# end of the LIBS and GUILIBS lines.
export CXX := $(shell wx-config --cxx) export CXX := $(shell wx-config --cxx)
export CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' export CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)'
export GUILIBS := $(shell wx-config --libs adv,core,base) -lgps export GUILIBS := $(shell wx-config --libs adv,core,base)
export LIBS := $(shell wx-config --libs base,net) -lgps export LIBS := $(shell wx-config --libs base,net)
export LDFLAGS := export LDFLAGS :=
.PHONY: all .PHONY: all