mirror of
https://github.com/oe7drt/YSFClients.git
synced 2025-12-06 05:32:02 +01:00
Make the use of gpsd optional.
This commit is contained in:
parent
b081264e64
commit
c38a8cfd27
|
|
@ -39,7 +39,7 @@ m_suffix(suffix),
|
||||||
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(),
|
||||||
|
|
@ -78,7 +78,7 @@ void CAPRSWriter::setStaticLocation(float latitude, float longitude, int height)
|
||||||
|
|
||||||
void CAPRSWriter::setGPSDLocation(const std::string& address, const std::string& port)
|
void CAPRSWriter::setGPSDLocation(const std::string& address, const std::string& port)
|
||||||
{
|
{
|
||||||
#if !defined(_WIN32) && !defined(_WIN64)
|
#if defined(USE_GPSD)
|
||||||
assert(!address.empty());
|
assert(!address.empty());
|
||||||
assert(!port.empty());
|
assert(!port.empty());
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ void CAPRSWriter::setGPSDLocation(const std::string& address, const std::string&
|
||||||
|
|
||||||
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.c_str(), m_gpsdPort.c_str(), &m_gpsdData);
|
int ret = ::gps_open(m_gpsdAddress.c_str(), m_gpsdPort.c_str(), &m_gpsdData);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|
@ -183,7 +183,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()) {
|
||||||
sendIdFrameMobile();
|
sendIdFrameMobile();
|
||||||
|
|
@ -197,7 +197,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
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +206,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);
|
||||||
|
|
@ -278,6 +278,7 @@ void CAPRSWriter::sendIdFrameFixed()
|
||||||
m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort);
|
m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_GPSD)
|
||||||
void CAPRSWriter::sendIdFrameMobile()
|
void CAPRSWriter::sendIdFrameMobile()
|
||||||
{
|
{
|
||||||
if (!::gps_waiting(&m_gpsdData, 0))
|
if (!::gps_waiting(&m_gpsdData, 0))
|
||||||
|
|
@ -367,4 +368,4 @@ void CAPRSWriter::sendIdFrameMobile()
|
||||||
|
|
||||||
m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort);
|
m_aprsSocket.write((unsigned char*)output, (unsigned int)::strlen(output), m_aprsAddress, m_aprsPort);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ private:
|
||||||
in_addr m_aprsAddress;
|
in_addr m_aprsAddress;
|
||||||
unsigned int m_aprsPort;
|
unsigned int m_aprsPort;
|
||||||
CUDPSocket m_aprsSocket;
|
CUDPSocket m_aprsSocket;
|
||||||
#if !defined(_WIN32) && !defined(_WIN64)
|
#if defined(USE_GPSD)
|
||||||
bool m_gpsdEnabled;
|
bool m_gpsdEnabled;
|
||||||
std::string m_gpsdAddress;
|
std::string m_gpsdAddress;
|
||||||
std::string m_gpsdPort;
|
std::string m_gpsdPort;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|
||||||
|
# Use the following CFLAGS if you don't want to use gpsd.
|
||||||
CFLAGS = -g -O3 -Wall -std=c++0x -pthread
|
CFLAGS = -g -O3 -Wall -std=c++0x -pthread
|
||||||
|
|
||||||
|
# Use the following CFLAGS if you do want to use gpsd.
|
||||||
|
CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread
|
||||||
|
|
||||||
LIBS = -lm -lpthread -lgps
|
LIBS = -lm -lpthread -lgps
|
||||||
LDFLAGS = -g
|
LDFLAGS = -g
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@
|
||||||
#if !defined(VERSION_H)
|
#if !defined(VERSION_H)
|
||||||
#define VERSION_H
|
#define VERSION_H
|
||||||
|
|
||||||
const char* VERSION = "20200605";
|
const char* VERSION = "20200621";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue