Replace MobileGPS with GPSD.

This commit is contained in:
Jonathan Naylor 2020-06-03 13:47:34 +01:00
parent 05b6249f4f
commit d6f04c3bc2
14 changed files with 203 additions and 197 deletions

View file

@ -124,10 +124,13 @@ m_gateway(),
m_array(),
m_aprsAddress(),
m_aprsPort(port),
m_aprsSocket(),
m_mobileAddress(),
m_mobilePort(0U),
m_mobileSocket(NULL)
m_aprsSocket()
#if !defined(_WIN32) && !defined(_WIN64)
,m_gpsdEnabled(false),
m_gpsdAddress(),
m_gpsdPort(),
m_gpsdData()
#endif
{
wxASSERT(!address.IsEmpty());
wxASSERT(port > 0U);
@ -157,38 +160,44 @@ void CAPRSWriter::setPortFixed(const wxString& callsign, const wxString& band, d
m_array[temp] = new CAPRSEntry(callsign, band, frequency, offset, range, latitude, longitude, agl);
}
void CAPRSWriter::setPortMobile(const wxString& callsign, const wxString& band, double frequency, double offset, double range, const wxString& address, unsigned int 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)
wxASSERT(!address.IsEmpty());
wxASSERT(!port.IsEmpty());
wxString temp = callsign;
temp.resize(LONG_CALLSIGN_LENGTH - 1U, wxT(' '));
temp.Append(band);
m_array[temp] = new CAPRSEntry(callsign, band, frequency, offset, range, 0.0, 0.0, 0.0);
if (m_mobileSocket == NULL) {
m_mobileAddress = CUDPReaderWriter::lookup(address);
m_mobilePort = port;
m_mobileSocket = new CUDPReaderWriter;
}
m_gpsdEnabled = true;
m_gpsdAddress = address;
m_gpsdPort = port;
#endif
}
bool CAPRSWriter::open()
{
if (m_mobileSocket != NULL) {
bool ret = m_mobileSocket->open();
if (!ret) {
delete m_mobileSocket;
m_mobileSocket = NULL;
#if !defined(_WIN32) && !defined(_WIN64)
if (m_gpsdEnabled) {
int ret = ::gps_open(m_gpsdAddress.mb_str(), m_gpsdPort.mb_str(), &m_gpsdData);
if (ret != 0) {
wxLogError(wxT("Error when opening access to gpsd - %d - %s"), errno, ::gps_errstr(errno));
return false;
}
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL);
// Poll the GPS every minute
m_idTimer.setTimeout(60U);
} else {
m_idTimer.setTimeout(20U * 60U);
}
#else
m_idTimer.setTimeout(20U * 60U);
#endif
m_idTimer.start();
return m_aprsSocket.open();
@ -280,20 +289,22 @@ void CAPRSWriter::clock(unsigned int ms)
{
m_idTimer.clock(ms);
if (m_mobileSocket != NULL) {
#if !defined(_WIN32) && !defined(_WIN64)
if (m_gpsdEnabled) {
if (m_idTimer.hasExpired()) {
pollGPS();
sendIdFramesMobile();
m_idTimer.start();
}
sendIdFramesMobile();
} else {
#endif
if (m_idTimer.hasExpired()) {
sendIdFramesFixed();
m_idTimer.start();
}
#if !defined(_WIN32) && !defined(_WIN64)
}
#endif
for (CEntry_t::iterator it = m_array.begin(); it != m_array.end(); ++it)
it->second->clock(ms);
}
@ -302,17 +313,12 @@ void CAPRSWriter::close()
{
m_aprsSocket.close();
if (m_mobileSocket != NULL) {
m_mobileSocket->close();
delete m_mobileSocket;
#if !defined(_WIN32) && !defined(_WIN64)
if (m_gpsdEnabled) {
::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL);
::gps_close(&m_gpsdData);
}
}
bool CAPRSWriter::pollGPS()
{
assert(m_mobileSocket != NULL);
return m_mobileSocket->write((unsigned char*)"ircDDBGateway", 13U, m_mobileAddress, m_mobilePort);
#endif
}
void CAPRSWriter::sendIdFramesFixed()
@ -426,29 +432,28 @@ void CAPRSWriter::sendIdFramesFixed()
void CAPRSWriter::sendIdFramesMobile()
{
// Grab GPS data if it's available
unsigned char buffer[200U];
in_addr address;
unsigned int port;
int ret = m_mobileSocket->read(buffer, 200U, address, port);
if (ret <= 0)
if (!m_gpsdEnabled)
return;
buffer[ret] = '\0';
// Parse the GPS data
char* pLatitude = ::strtok((char*)buffer, ",\n"); // Latitude
char* pLongitude = ::strtok(NULL, ",\n"); // Longitude
char* pAltitude = ::strtok(NULL, ",\n"); // Altitude (m)
char* pVelocity = ::strtok(NULL, ",\n"); // Velocity (kms/h)
char* pBearing = ::strtok(NULL, "\n"); // Bearing
if (pLatitude == NULL || pLongitude == NULL || pAltitude == NULL)
if (!::gps_waiting(&m_gpsdData, 0))
return;
double rawLatitude = ::atof(pLatitude);
double rawLongitude = ::atof(pLongitude);
double rawAltitude = ::atof(pAltitude);
if (::gps_read(&m_gpsdData, NULL, 0) <= 0)
return;
bool latlonSet = (m_gpsdData.set & LATLON_SET) == LATLON_SET;
bool altitudeSet = (m_gpsdData.set & ALTITUDE_SET) == ALTITUDE_SET;
bool velocitySet = (m_gpsdData.set & SPEED_SET) == SPEED_SET;
bool bearingSet = (m_gpsdData.set & TRACK_SET) == TRACK_SET;
if (!latlonSet)
return;
float rawLatitude = float(m_gpsdData.fix.latitude);
float rawLongitude = float(m_gpsdData.fix.longitude);
float rawAltitude = float(m_gpsdData.fix.altMSL);
float rawVelocity = float(m_gpsdData.fix.speed);
float rawBearing = float(m_gpsdData.fix.track);
time_t now;
::time(&now);
@ -531,12 +536,8 @@ void CAPRSWriter::sendIdFramesMobile()
rawAltitude * 3.28);
wxString output2;
if (pBearing != NULL && pVelocity != NULL) {
double rawBearing = ::atof(pBearing);
double rawVelocity = ::atof(pVelocity);
if (bearingSet && velocitySet)
output2.Printf(wxT("%03.0lf/%03.0lf"), rawBearing, rawVelocity * 0.539957F);
}
wxString output3;
output3.Printf(wxT("RNG%04.0lf %s %s\r\n"), entry->getRange() * 0.6214, band.c_str(), desc.c_str());
@ -554,11 +555,17 @@ void CAPRSWriter::sendIdFramesMobile()
m_aprsSocket.write((unsigned char*)ascii, (unsigned int)::strlen(ascii), m_aprsAddress, m_aprsPort);
if (entry->getBand().Len() == 1U) {
output1.Printf(wxT("%s-%s>APDG02,TCPIP*,qAC,%s-%sS:!%s%cD%s%c&/A=%06.0lf"),
entry->getCallsign().c_str(), entry->getBand().c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
lat.c_str(), (rawLatitude < 0.0) ? wxT('S') : wxT('N'),
lon.c_str(), (rawLongitude < 0.0) ? wxT('W') : wxT('E'),
rawAltitude * 3.28);
if (altitudeSet)
output1.Printf(wxT("%s-%s>APDG02,TCPIP*,qAC,%s-%sS:!%s%cD%s%c&/A=%06.0lf"),
entry->getCallsign().c_str(), entry->getBand().c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
lat.c_str(), (rawLatitude < 0.0) ? wxT('S') : wxT('N'),
lon.c_str(), (rawLongitude < 0.0) ? wxT('W') : wxT('E'),
rawAltitude * 3.28);
else
output1.Printf(wxT("%s-%s>APDG02,TCPIP*,qAC,%s-%sS:!%s%cD%s%c&"),
entry->getCallsign().c_str(), entry->getBand().c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
lat.c_str(), (rawLatitude < 0.0) ? wxT('S') : wxT('N'),
lon.c_str(), (rawLongitude < 0.0) ? wxT('W') : wxT('E'));
::memset(ascii, 0x00, 300U);
unsigned int n = 0U;

View file

@ -27,6 +27,10 @@
#include "Timer.h"
#include "Defs.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include <gps.h>
#endif
#include <wx/wx.h>
class CAPRSEntry {
@ -74,7 +78,7 @@ public:
void setPortFixed(const wxString& callsign, const wxString& band, double frequency, double offset, double range, double latitude, double longitude, double agl);
void setPortMobile(const wxString& callsign, const wxString& band, double frequency, double offset, double range, const wxString& address, unsigned int port);
void setPortGPSD(const wxString& callsign, const wxString& band, double frequency, double offset, double range, const wxString& address, const wxString& port);
void writeHeader(const wxString& callsign, const CHeaderData& header);
@ -91,11 +95,13 @@ private:
in_addr m_aprsAddress;
unsigned int m_aprsPort;
CUDPReaderWriter m_aprsSocket;
in_addr m_mobileAddress;
unsigned int m_mobilePort;
CUDPReaderWriter* m_mobileSocket;
#if !defined(_WIN32) && !defined(_WIN64)
bool m_gpsdEnabled;
wxString m_gpsdAddress;
wxString m_gpsdPort;
struct gps_data_t m_gpsdData;
#endif
bool pollGPS();
void sendIdFramesFixed();
void sendIdFramesMobile();
};

View file

@ -200,9 +200,9 @@ const wxString KEY_ECHO_ENABLED = wxT("echoEnabled");
const wxString KEY_LOG_ENABLED = wxT("logEnabled");
const wxString KEY_DRATS_ENABLED = wxT("dratsEnabled");
const wxString KEY_DTMF_ENABLED = wxT("dtmfEnabled");
const wxString KEY_MOBILE_GPS_ENABLED = wxT("mobileGPSEnabled");
const wxString KEY_MOBILE_GPS_ADDRESS = wxT("mobileGPSAddress");
const wxString KEY_MOBILE_GPS_PORT = wxT("mobileGPSPort");
const wxString KEY_GPSD_ENABLED = wxT("gpsdEnabled");
const wxString KEY_GPSD_ADDRESS = wxT("gpsdAddress");
const wxString KEY_GPSD_PORT = wxT("gpsdPort");
const wxString KEY_WINDOW_X = wxT("windowX");
const wxString KEY_WINDOW_Y = wxT("windowY");
@ -284,9 +284,9 @@ const bool DEFAULT_INFO_ENABLED = true;
const bool DEFAULT_ECHO_ENABLED = true;
const bool DEFAULT_DRATS_ENABLED = false;
const bool DEFAULT_DTMF_ENABLED = true;
const bool DEFAULT_MOBILE_GPS_ENABLED = false;
const wxString DEFAULT_MOBILE_GPS_ADDRESS = wxT("127.0.0.1");
const unsigned int DEFAULT_MOBILE_GPS_PORT = 7834U;
const bool DEFAULT_GPSD_ENABLED = false;
const wxString DEFAULT_GPSD_ADDRESS = wxT("127.0.0.1");
const wxString DEFAULT_GPSD_PORT = wxT("2947");
const int DEFAULT_WINDOW_X = -1;
const int DEFAULT_WINDOW_Y = -1;
@ -477,9 +477,9 @@ m_echoEnabled(DEFAULT_ECHO_ENABLED),
m_logEnabled(DEFAULT_LOG_ENABLED),
m_dratsEnabled(DEFAULT_DRATS_ENABLED),
m_dtmfEnabled(DEFAULT_DTMF_ENABLED),
m_mobileGPSEnabled(DEFAULT_MOBILE_GPS_ENABLED),
m_mobileGPSAddress(DEFAULT_MOBILE_GPS_ADDRESS),
m_mobileGPSPort(DEFAULT_MOBILE_GPS_PORT),
m_gpsdEnabled(DEFAULT_GPSD_ENABLED),
m_gpsdAddress(DEFAULT_GPSD_ADDRESS),
m_gpsdPort(DEFAULT_GPSD_PORT),
m_x(DEFAULT_WINDOW_X),
m_y(DEFAULT_WINDOW_Y)
{
@ -893,12 +893,12 @@ m_y(DEFAULT_WINDOW_Y)
m_config->Read(m_name + KEY_DTMF_ENABLED, &m_dtmfEnabled, DEFAULT_DTMF_ENABLED);
m_config->Read(m_name + KEY_MOBILE_GPS_ENABLED, &m_mobileGPSEnabled, DEFAULT_MOBILE_GPS_ENABLED);
m_config->Read(m_name + KEY_GPSD_ENABLED, &m_gpsdEnabled, DEFAULT_GPSD_ENABLED);
m_config->Read(m_name + KEY_MOBILE_GPS_ADDRESS, &m_mobileGPSAddress, DEFAULT_MOBILE_GPS_ADDRESS);
m_config->Read(m_name + KEY_GPSD_ADDRESS, &m_gpsdAddress, DEFAULT_GPSD_ADDRESS);
m_config->Read(m_name + KEY_MOBILE_GPS_PORT, &temp, long(DEFAULT_MOBILE_GPS_PORT));
m_mobileGPSPort = (unsigned int)temp;
m_config->Read(m_name + KEY_GPSD_PORT, &temp, long(DEFAULT_GPSD_PORT));
m_gpsdPort = (unsigned int)temp;
m_config->Read(m_name + KEY_WINDOW_X, &temp, long(DEFAULT_WINDOW_X));
m_x = int(temp);
@ -1096,9 +1096,9 @@ m_echoEnabled(DEFAULT_ECHO_ENABLED),
m_logEnabled(DEFAULT_LOG_ENABLED),
m_dratsEnabled(DEFAULT_DRATS_ENABLED),
m_dtmfEnabled(DEFAULT_DTMF_ENABLED),
m_mobileGPSEnabled(DEFAULT_MOBILE_GPS_ENABLED),
m_mobileGPSAddress(DEFAULT_MOBILE_GPS_ADDRESS),
m_mobileGPSPort(DEFAULT_MOBILE_GPS_PORT),
m_gpsdEnabled(DEFAULT_GPSD_ENABLED),
m_gpsdAddress(DEFAULT_GPSD_ADDRESS),
m_gpsdPort(DEFAULT_GPSD_PORT),
m_x(DEFAULT_WINDOW_X),
m_y(DEFAULT_WINDOW_Y)
{
@ -1574,14 +1574,13 @@ m_y(DEFAULT_WINDOW_Y)
} else if (key.IsSameAs(KEY_DTMF_ENABLED)) {
val.ToLong(&temp1);
m_dtmfEnabled = temp1 == 1L;
} else if (key.IsSameAs(KEY_MOBILE_GPS_ENABLED)) {
} else if (key.IsSameAs(KEY_GPSD_ENABLED)) {
val.ToLong(&temp1);
m_mobileGPSEnabled = temp1 == 1L;
} else if (key.IsSameAs(KEY_MOBILE_GPS_ADDRESS)) {
m_mobileGPSAddress = val;
} else if (key.IsSameAs(KEY_MOBILE_GPS_PORT)) {
val.ToULong(&temp2);
m_mobileGPSPort = (unsigned int)temp2;
m_gpsdEnabled = temp1 == 1L;
} else if (key.IsSameAs(KEY_GPSD_ADDRESS)) {
m_gpsdAddress = val;
} else if (key.IsSameAs(KEY_GPSD_PORT)) {
m_gpsdPort = val;
} else if (key.IsSameAs(KEY_WINDOW_X)) {
val.ToLong(&temp1);
m_x = int(temp1);
@ -2199,18 +2198,18 @@ void CIRCDDBGatewayConfig::setMiscellaneous(TEXT_LANG language, bool infoEnabled
m_dtmfEnabled = dtmfEnabled;
}
void CIRCDDBGatewayConfig::getMobileGPS(bool& enabled, wxString& address, unsigned int& port) const
void CIRCDDBGatewayConfig::getGPSD(bool& enabled, wxString& address, wxString& port) const
{
enabled = m_mobileGPSEnabled;
address = m_mobileGPSAddress;
port = m_mobileGPSPort;
enabled = m_gpsdEnabled;
address = m_gpsdAddress;
port = m_gpsdPort;
}
void CIRCDDBGatewayConfig::setMobileGPS(bool enabled, const wxString& address, unsigned int port)
void CIRCDDBGatewayConfig::setGPSD(bool enabled, const wxString& address, const wxString& port)
{
m_mobileGPSEnabled = enabled;
m_mobileGPSAddress = address;
m_mobileGPSPort = port;
m_gpsdEnabled = enabled;
m_gpsdAddress = address;
m_gpsdPort = port;
}
void CIRCDDBGatewayConfig::getPosition(int& x, int& y) const
@ -2451,9 +2450,9 @@ bool CIRCDDBGatewayConfig::write()
m_config->Write(m_name + KEY_LOG_ENABLED, m_logEnabled);
m_config->Write(m_name + KEY_DRATS_ENABLED, m_dratsEnabled);
m_config->Write(m_name + KEY_DTMF_ENABLED, m_dtmfEnabled);
m_config->Write(m_name + KEY_MOBILE_GPS_ENABLED, m_mobileGPSEnabled);
m_config->Write(m_name + KEY_MOBILE_GPS_ADDRESS, m_mobileGPSAddress);
m_config->Write(m_name + KEY_MOBILE_GPS_PORT, long(m_mobileGPSPort));
m_config->Write(m_name + KEY_GPSD_ENABLED, m_gpsdEnabled);
m_config->Write(m_name + KEY_GPSD_ADDRESS, m_gpsdAddress);
m_config->Write(m_name + KEY_GPSD_PORT, m_gpsdPort);
m_config->Write(m_name + KEY_WINDOW_X, long(m_x));
m_config->Write(m_name + KEY_WINDOW_Y, long(m_y));
m_config->Flush();
@ -2660,9 +2659,9 @@ bool CIRCDDBGatewayConfig::write()
buffer.Printf(wxT("%s=%d"), KEY_LOG_ENABLED.c_str(), m_logEnabled ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_DRATS_ENABLED.c_str(), m_dratsEnabled ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_DTMF_ENABLED.c_str(), m_dtmfEnabled ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_MOBILE_GPS_ENABLED.c_str(), m_mobileGPSEnabled ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%s"), KEY_MOBILE_GPS_ADDRESS.c_str(), m_mobileGPSAddress.c_str()); file.AddLine(buffer);
buffer.Printf(wxT("%s=%u"), KEY_MOBILE_GPS_PORT.c_str(), m_mobileGPSPort); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_GPSD_ENABLED.c_str(), m_gpsdEnabled ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%s"), KEY_GPSD_ADDRESS.c_str(), m_gpsdAddress.c_str()); file.AddLine(buffer);
buffer.Printf(wxT("%s=%s"), KEY_GPSD_PORT.c_str(), m_gpsdPort.c_str()); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_WINDOW_X.c_str(), m_x); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_WINDOW_Y.c_str(), m_y); file.AddLine(buffer);
@ -2677,3 +2676,4 @@ bool CIRCDDBGatewayConfig::write()
return true;
}

View file

@ -112,8 +112,8 @@ public:
void getMiscellaneous(TEXT_LANG& language, bool& infoEnabled, bool& echoEnabled, bool& logEnabled, bool& dratsEnabled, bool& dtmfEnabled) const;
void setMiscellaneous(TEXT_LANG language, bool infoEnabled, bool echoEnabled, bool logEnabled, bool dratsEnabled, bool dtmfEnabled);
void getMobileGPS(bool& enabled, wxString& address, unsigned int& port) const;
void setMobileGPS(bool enabled, const wxString& address, unsigned int port);
void getGPSD(bool& enabled, wxString& address, wxString& port) const;
void setGPSD(bool enabled, const wxString& address, const wxString& port);
void getPosition(int& x, int& y) const;
void setPosition(int x, int y);
@ -307,9 +307,9 @@ private:
bool m_logEnabled;
bool m_dratsEnabled;
bool m_dtmfEnabled;
bool m_mobileGPSEnabled;
wxString m_mobileGPSAddress;
unsigned int m_mobileGPSPort;
bool m_gpsdEnabled;
wxString m_gpsdAddress;
wxString m_gpsdPort;
int m_x;
int m_y;
};

View file

@ -24,9 +24,9 @@
const wxString VENDOR_NAME = wxT("G4KLX");
#if defined(__WXDEBUG__)
const wxString VERSION = wxT("20200601 - DEBUG");
const wxString VERSION = wxT("20200603 - DEBUG");
#else
const wxString VERSION = wxT("20190601");
const wxString VERSION = wxT("20190603");
#endif
#endif

View file

@ -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,7 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "MobileGPSSet.h"
#include "GPSDSet.h"
const unsigned int CONTROL_WIDTH1 = 130U;
const unsigned int CONTROL_WIDTH2 = 80U;
@ -26,7 +26,7 @@ const unsigned int PORT_LENGTH = 5U;
const unsigned int BORDER_SIZE = 5U;
CMobileGPSSet::CMobileGPSSet(wxWindow* parent, int id, const wxString& title, bool enabled, const wxString& address, unsigned int port) :
CGPSDSet::CGPSDSet(wxWindow* parent, int id, const wxString& title, bool enabled, const wxString& address, const wxString& port) :
wxPanel(parent, id),
m_title(title),
m_enabled(NULL),
@ -54,10 +54,7 @@ m_port(NULL)
wxStaticText* portLabel = new wxStaticText(this, -1, _("Port"));
sizer->Add(portLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
wxString buffer;
buffer.Printf(wxT("%u"), port);
m_port = new CPortTextCtrl(this, -1, buffer, wxDefaultPosition, wxSize(CONTROL_WIDTH2, -1));
m_port = new CPortTextCtrl(this, -1, port, wxDefaultPosition, wxSize(CONTROL_WIDTH2, -1));
m_port->SetMaxLength(PORT_LENGTH);
sizer->Add(m_port, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
@ -67,11 +64,11 @@ m_port(NULL)
}
CMobileGPSSet::~CMobileGPSSet()
CGPSDSet::~CGPSDSet()
{
}
bool CMobileGPSSet::Validate()
bool CGPSDSet::Validate()
{
if (m_enabled->GetCurrentSelection() == wxNOT_FOUND)
return false;
@ -84,9 +81,10 @@ bool CMobileGPSSet::Validate()
return false;
}
unsigned int port = getPort();
unsigned long port;
getPort().ToULong(&port);
if (port == 0U || port > 65535U) {
if (port == 0UL || port > 65535UL) {
wxMessageDialog dialog(this, _("The Mobile GPS Port is not valid"), m_title + _(" Error"), wxICON_ERROR);
dialog.ShowModal();
return false;
@ -95,7 +93,7 @@ bool CMobileGPSSet::Validate()
return true;
}
bool CMobileGPSSet::getEnabled() const
bool CGPSDSet::getEnabled() const
{
int c = m_enabled->GetCurrentSelection();
if (c == wxNOT_FOUND)
@ -104,15 +102,13 @@ bool CMobileGPSSet::getEnabled() const
return c == 1;
}
wxString CMobileGPSSet::getAddress() const
wxString CGPSDSet::getAddress() const
{
return m_address->GetValue();
}
unsigned int CMobileGPSSet::getPort() const
wxString CGPSDSet::getPort() const
{
unsigned long n;
m_port->GetValue().ToULong(&n);
return n;
return m_port->GetValue();
}

View file

@ -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,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MobileGPSSet_H
#define MobileGPSSet_H
#ifndef GPSDSet_H
#define GPSDSet_H
#include "AddressTextCtrl.h"
#include "PortTextCtrl.h"
@ -25,16 +25,16 @@
#include <wx/wx.h>
class CMobileGPSSet: public wxPanel {
class CGPSDSet: public wxPanel {
public:
CMobileGPSSet(wxWindow* parent, int id, const wxString& title, bool enabled, const wxString& address, unsigned int port);
virtual ~CMobileGPSSet();
CGPSDSet(wxWindow* parent, int id, const wxString& title, bool enabled, const wxString& address, const wxString& port);
virtual ~CGPSDSet();
virtual bool Validate();
virtual bool getEnabled() const;
virtual wxString getAddress() const;
virtual unsigned int getPort() const;
virtual bool getEnabled() const;
virtual wxString getAddress() const;
virtual wxString getPort() const;
private:
wxString m_title;

View file

@ -1,4 +1,4 @@
OBJECTS = AddressTextCtrl.o CallsignTextCtrl.o DCSSet.o DescriptionTextCtrl.o DExtraSet.o DPlusSet.o DPRSSet.o MobileGPSSet.o PortTextCtrl.o RemoteSet.o \
OBJECTS = AddressTextCtrl.o CallsignTextCtrl.o DCSSet.o DescriptionTextCtrl.o DExtraSet.o DPlusSet.o DPRSSet.o GPSDSet.o PortTextCtrl.o RemoteSet.o \
RepeaterDataSet.o RepeaterInfoSet.o RestrictedTextCtrl.o StarNetSet.o XLXSet.o
.PHONY: all

View file

@ -23,7 +23,7 @@ ifeq ($(BUILD), debug)
else ifeq ($(BUILD), release)
export CFLAGS := $(CFLAGS) $(RELEASEFLAGS)
endif
export LIBS := $(shell wx-config --libs base,net)
export LIBS := $(shell wx-config --libs base,net) -lgps
export LDFLAGS :=
.PHONY: all

View file

@ -15,8 +15,8 @@ endif
export CXX := $(shell wx-config --cxx)
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)
export LIBS := $(shell wx-config --libs base,net)
export GUILIBS := $(shell wx-config --libs adv,core,base) -lgps
export LIBS := $(shell wx-config --libs base,net) -lgps
export LDFLAGS :=
.PHONY: all

View file

@ -290,11 +290,10 @@ void CIRCDDBGatewayApp::createThread()
m_config->getMiscellaneous(language, infoEnabled, echoEnabled, logEnabled, dratsEnabled, dtmfEnabled);
wxLogInfo(wxT("Language: %d, info enabled: %d, echo enabled: %d, log enabled : %d, D-RATS enabled: %d, DTMF control enabled: %d"), int(language), int(infoEnabled), int(echoEnabled), int(logEnabled), int(dratsEnabled), int(dtmfEnabled));
bool mobileGPSEnabled;
wxString mobileGPSAddress;
unsigned int mobileGPSPort;
m_config->getMobileGPS(mobileGPSEnabled, mobileGPSAddress, mobileGPSPort);
wxLogInfo(wxT("Mobile GPS: %d, address: %s, port: %u"), int(mobileGPSEnabled), mobileGPSAddress.c_str(), mobileGPSPort);
bool gpsdEnabled;
wxString gpsdAddress, gpsdPort;
m_config->getGPSD(gpsdEnabled, gpsdAddress, gpsdPort);
wxLogInfo(wxT("GPSD: %d, address: %s, port: %s"), int(gpsdEnabled), gpsdAddress.c_str(), gpsdPort.c_str());
CIcomRepeaterProtocolHandler* icomRepeaterHandler = NULL;
CHBRepeaterProtocolHandler* hbRepeaterHandler = NULL;
@ -372,8 +371,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign1, repeaterBand1, repeaterAddress1, repeaterPort1, repeaterType1, reflector1, atStartup1, reconnect1, dratsEnabled, frequency1, offset1, range1, latitude1, longitude1, agl1, description11, description12, url1, icomRepeaterHandler, band11, band12, band13);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign1, repeaterBand1, frequency1, offset1, range1, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign1, repeaterBand1, frequency1, offset1, range1, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign1, repeaterBand1, frequency1, offset1, range1, latitude1, longitude1, agl1);
}
@ -383,8 +382,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign1, repeaterBand1, repeaterAddress1, repeaterPort1, repeaterType1, reflector1, atStartup1, reconnect1, dratsEnabled, frequency1, offset1, range1, latitude1, longitude1, agl1, description11, description12, url1, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign1, repeaterBand1, frequency1, offset1, range1, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign1, repeaterBand1, frequency1, offset1, range1, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign1, repeaterBand1, frequency1, offset1, range1, latitude1, longitude1, agl1);
}
@ -468,8 +467,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign2, repeaterBand2, repeaterAddress2, repeaterPort2, repeaterType2, reflector2, atStartup2, reconnect2, dratsEnabled, frequency2, offset2, range2, latitude2, longitude2, agl2, description21, description22, url2, icomRepeaterHandler, band21, band22, band23);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign2, repeaterBand2, frequency2, offset2, range2, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign2, repeaterBand2, frequency2, offset2, range2, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign2, repeaterBand2, frequency2, offset2, range2, latitude2, longitude2, agl2);
}
@ -479,8 +478,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign2, repeaterBand2, repeaterAddress2, repeaterPort2, repeaterType2, reflector2, atStartup2, reconnect2, dratsEnabled, frequency2, offset2, range2, latitude2, longitude2, agl2, description21, description22, url2, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign2, repeaterBand2, frequency2, offset2, range2, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign2, repeaterBand2, frequency2, offset2, range2, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign2, repeaterBand2, frequency2, offset2, range2, latitude2, longitude2, agl2);
}
@ -568,8 +567,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign3, repeaterBand3, repeaterAddress3, repeaterPort3, repeaterType3, reflector3, atStartup3, reconnect3, dratsEnabled, frequency3, offset3, range3, latitude3, longitude3, agl3, description31, description32, url3, icomRepeaterHandler, band31, band32, band33);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign3, repeaterBand3, frequency3, offset3, range3, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign3, repeaterBand3, frequency3, offset3, range3, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign3, repeaterBand3, frequency3, offset3, range3, latitude3, longitude3, agl3);
}
@ -579,8 +578,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign3, repeaterBand3, repeaterAddress3, repeaterPort3, repeaterType3, reflector3, atStartup3, reconnect3, dratsEnabled, frequency3, offset3, range3, latitude3, longitude3, agl3, description31, description32, url3, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign3, repeaterBand3, frequency3, offset3, range3, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign3, repeaterBand3, frequency3, offset3, range3, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign3, repeaterBand3, frequency3, offset3, range3, latitude3, longitude3, agl3);
}
@ -672,8 +671,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign4, repeaterBand4, repeaterAddress4, repeaterPort4, repeaterType4, reflector4, atStartup4, reconnect4, dratsEnabled, frequency4, offset4, range4, latitude4, longitude4, agl4, description41, description42, url4, icomRepeaterHandler, band41, band42, band43);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign4, repeaterBand4, frequency4, offset4, range4, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign4, repeaterBand4, frequency4, offset4, range4, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign4, repeaterBand4, frequency4, offset4, range4, latitude4, longitude4, agl4);
}
@ -683,8 +682,8 @@ void CIRCDDBGatewayApp::createThread()
thread->addRepeater(callsign4, repeaterBand4, repeaterAddress4, repeaterPort4, repeaterType4, reflector4, atStartup4, reconnect4, dratsEnabled, frequency4, offset4, range4, latitude4, longitude4, agl4, description41, description42, url4, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign4, repeaterBand4, frequency4, offset4, range4, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign4, repeaterBand4, frequency4, offset4, range4, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign4, repeaterBand4, frequency4, offset4, range4, latitude4, longitude4, agl4);
}

View file

@ -297,11 +297,10 @@ bool CIRCDDBGatewayAppD::createThread()
config.getMiscellaneous(language, infoEnabled, echoEnabled, logEnabled, dratsEnabled, dtmfEnabled);
wxLogInfo(wxT("Language: %d, info enabled: %d, echo enabled: %d, log enabled : %d, D-RATS enabled: %d, DTMF control enabled: %d"), int(language), int(infoEnabled), int(echoEnabled), int(logEnabled), int(dratsEnabled), int(dtmfEnabled));
bool mobileGPSEnabled;
wxString mobileGPSAddress;
unsigned int mobileGPSPort;
config.getMobileGPS(mobileGPSEnabled, mobileGPSAddress, mobileGPSPort);
wxLogInfo(wxT("Mobile GPS: %d, address: %s, port: %u"), int(mobileGPSEnabled), mobileGPSAddress.c_str(), mobileGPSPort);
bool gpsdEnabled;
wxString gpsdAddress, gpsdPort;
config.getGPSD(gpsdEnabled, gpsdAddress, gpsdPort);
wxLogInfo(wxT("GPSD: %d, address: %s, port: %s"), int(gpsdEnabled), gpsdAddress.c_str(), gpsdPort.c_str());
CIcomRepeaterProtocolHandler* icomRepeaterHandler = NULL;
CHBRepeaterProtocolHandler* hbRepeaterHandler = NULL;
@ -379,8 +378,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign1, repeaterBand1, repeaterAddress1, repeaterPort1, repeaterType1, reflector1, atStartup1, reconnect1, dratsEnabled, frequency1, offset1, range1, latitude1, longitude1, agl1, description11, description12, url1, icomRepeaterHandler, band11, band12, band13);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign1, repeaterBand1, frequency1, offset1, range1, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign1, repeaterBand1, frequency1, offset1, range1, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign1, repeaterBand1, frequency1, offset1, range1, latitude1, longitude1, agl1);
}
@ -390,8 +389,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign1, repeaterBand1, repeaterAddress1, repeaterPort1, repeaterType1, reflector1, atStartup1, reconnect1, dratsEnabled, frequency1, offset1, range1, latitude1, longitude1, agl1, description11, description12, url1, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign1, repeaterBand1, frequency1, offset1, range1, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign1, repeaterBand1, frequency1, offset1, range1, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign1, repeaterBand1, frequency1, offset1, range1, latitude1, longitude1, agl1);
}
@ -475,8 +474,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign2, repeaterBand2, repeaterAddress2, repeaterPort2, repeaterType2, reflector2, atStartup2, reconnect2, dratsEnabled, frequency2, offset2, range2, latitude2, longitude2, agl2, description21, description22, url2, icomRepeaterHandler, band21, band22, band23);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign2, repeaterBand2, frequency2, offset2, range2, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign2, repeaterBand2, frequency2, offset2, range2, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign2, repeaterBand2, frequency2, offset2, range2, latitude2, longitude2, agl2);
}
@ -486,8 +485,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign2, repeaterBand2, repeaterAddress2, repeaterPort2, repeaterType2, reflector2, atStartup2, reconnect2, dratsEnabled, frequency2, offset2, range2, latitude2, longitude2, agl2, description21, description22, url2, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign2, repeaterBand2, frequency2, offset2, range2, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign2, repeaterBand2, frequency2, offset2, range2, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign2, repeaterBand2, frequency2, offset2, range2, latitude2, longitude2, agl1);
}
@ -575,8 +574,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign3, repeaterBand3, repeaterAddress3, repeaterPort3, repeaterType3, reflector3, atStartup3, reconnect3, dratsEnabled, frequency3, offset3, range3, latitude3, longitude3, agl3, description31, description32, url3, icomRepeaterHandler, band31, band32, band33);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign3, repeaterBand3, frequency3, offset3, range3, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign3, repeaterBand3, frequency3, offset3, range3, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign3, repeaterBand3, frequency3, offset3, range3, latitude3, longitude3, agl3);
}
@ -586,8 +585,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign3, repeaterBand3, repeaterAddress3, repeaterPort3, repeaterType3, reflector3, atStartup3, reconnect3, dratsEnabled, frequency3, offset3, range3, latitude3, longitude3, agl3, description31, description32, url3, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign3, repeaterBand3, frequency3, offset3, range3, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign3, repeaterBand3, frequency3, offset3, range3, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign3, repeaterBand3, frequency3, offset3, range3, latitude3, longitude3, agl3);
}
@ -679,8 +678,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign4, repeaterBand4, repeaterAddress4, repeaterPort4, repeaterType4, reflector4, atStartup4, reconnect4, dratsEnabled, frequency4, offset4, range4, latitude4, longitude4, agl4, description41, description42, url4, icomRepeaterHandler, band41, band42, band43);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign4, repeaterBand4, frequency4, offset4, range4, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign4, repeaterBand4, frequency4, offset4, range4, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign4, repeaterBand4, frequency4, offset4, range4, latitude4, longitude4, agl4);
}
@ -690,8 +689,8 @@ bool CIRCDDBGatewayAppD::createThread()
m_thread->addRepeater(callsign4, repeaterBand4, repeaterAddress4, repeaterPort4, repeaterType4, reflector4, atStartup4, reconnect4, dratsEnabled, frequency4, offset4, range4, latitude4, longitude4, agl4, description41, description42, url4, hbRepeaterHandler);
if (aprs != NULL) {
if (mobileGPSEnabled)
aprs->setPortMobile(callsign4, repeaterBand4, frequency4, offset4, range4, mobileGPSAddress, mobileGPSPort);
if (gpsdEnabled)
aprs->setPortGPSD(callsign4, repeaterBand4, frequency4, offset4, range4, gpsdAddress, gpsdPort);
else
aprs->setPortFixed(callsign4, repeaterBand4, frequency4, offset4, range4, latitude4, longitude4, agl4);
}

View file

@ -65,7 +65,7 @@ m_starNet3(NULL),
m_starNet4(NULL),
m_starNet5(NULL),
m_remote(NULL),
m_mobileGPS(NULL),
m_gpsd(NULL),
m_miscellaneous(NULL)
{
SetMenuBar(createMenuBar());
@ -314,13 +314,12 @@ m_miscellaneous(NULL)
m_remote = new CRemoteSet(noteBook, -1, APPLICATION_NAME, remoteEnabled, remotePassword, remotePort);
noteBook->AddPage(m_remote, wxT("Remote"), false);
bool mobileGPSEnabled;
wxString mobileGPSAddress;
unsigned int mobileGPSPort;
m_config->getMobileGPS(mobileGPSEnabled, mobileGPSAddress, mobileGPSPort);
bool gpsdEnabled;
wxString gpsdAddress, gpsdPort;
m_config->getGPSD(gpsdEnabled, gpsdAddress, gpsdPort);
m_mobileGPS = new CMobileGPSSet(noteBook, -1, APPLICATION_NAME, mobileGPSEnabled, mobileGPSAddress, mobileGPSPort);
noteBook->AddPage(m_mobileGPS, wxT("Mobile GPS"), false);
m_gpsd = new CGPSDSet(noteBook, -1, APPLICATION_NAME, gpsdEnabled, gpsdAddress, gpsdPort);
noteBook->AddPage(m_gpsd, wxT("GPSD"), false);
TEXT_LANG language;
bool infoEnabled, echoEnabled, logEnabled, dratsEnabled, dtmfEnabled;
@ -379,7 +378,7 @@ void CIRCDDBGatewayConfigFrame::onSave(wxCommandEvent&)
!m_repeaterInfo4->Validate() ||
!m_ircDDB->Validate() || !m_ircDDB2->Validate() || !m_ircDDB3->Validate() || !m_ircDDB4->Validate() || !m_dprs->Validate() || !m_dplus->Validate() || !m_dcs->Validate() || !m_xlx->Validate() ||
!m_starNet1->Validate() || !m_starNet2->Validate() || !m_starNet3->Validate() || !m_starNet4->Validate() ||
!m_starNet5->Validate() || !m_remote->Validate() || !m_mobileGPS->Validate() || !m_miscellaneous->Validate())
!m_starNet5->Validate() || !m_remote->Validate() || !m_gpsd->Validate() || !m_miscellaneous->Validate())
return;
GATEWAY_TYPE gatewayType = m_gateway->getType();
@ -612,10 +611,10 @@ void CIRCDDBGatewayConfigFrame::onSave(wxCommandEvent&)
unsigned int remotePort = m_remote->getPort();
m_config->setRemote(remoteEnabled, remotePassword, remotePort);
bool mobileGPSEnabled = m_mobileGPS->getEnabled();
wxString mobileGPSAddress = m_mobileGPS->getAddress();
unsigned int mobileGPSPort = m_mobileGPS->getPort();
m_config->setMobileGPS(mobileGPSEnabled, mobileGPSAddress, mobileGPSPort);
bool gpsdEnabled = m_gpsd->getEnabled();
wxString gpsdAddress = m_gpsd->getAddress();
wxString gpsdPort = m_gpsd->getPort();
m_config->setGPSD(gpsdEnabled, gpsdAddress, gpsdPort);
TEXT_LANG language = m_miscellaneous->getLanguage();
bool infoEnabled = m_miscellaneous->getInfoEnabled();

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2014,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2010-2014,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
@ -25,12 +25,12 @@
#include "IRCDDBGatewayConfig.h"
#include "RepeaterInfoSet.h"
#include "RepeaterDataSet.h"
#include "MobileGPSSet.h"
#include "StarNetSet.h"
#include "RemoteSet.h"
#include "DExtraSet.h"
#include "DPlusSet.h"
#include "DPRSSet.h"
#include "GPSDSet.h"
#include "DCSSet.h"
#include "XLXSet.h"
#include "Defs.h"
@ -73,7 +73,7 @@ private:
CStarNetSet* m_starNet4;
CStarNetSet* m_starNet5;
CRemoteSet* m_remote;
CMobileGPSSet* m_mobileGPS;
CGPSDSet* m_gpsd;
CIRCDDBGatewayConfigMiscellaneousSet* m_miscellaneous;
DECLARE_EVENT_TABLE()