Add optional reporting of the home location to APRS-IS directly.

This commit is contained in:
Jonathan Naylor
2020-08-28 15:15:25 +01:00
parent 8ef67976ab
commit f93c48a922
12 changed files with 430 additions and 34 deletions

View File

@@ -30,7 +30,8 @@ m_gpsdAddress(address),
m_gpsdPort(port),
m_gpsdData(),
m_idTimer(1000U, 60U),
m_networks()
m_networks(),
m_aprs(NULL)
{
assert(!address.empty());
assert(!port.empty());
@@ -47,6 +48,13 @@ void CGPSD::addNetwork(CDMRNetwork* network)
m_networks.push_back(network);
}
void CGPSD::addAPRS(CAPRSWriter* aprs)
{
assert(aprs != NULL);
m_aprs = aprs;
}
bool CGPSD::open()
{
int ret = ::gps_open(m_gpsdAddress.c_str(), m_gpsdPort.c_str(), &m_gpsdData);
@@ -100,8 +108,18 @@ void CGPSD::sendReport()
if (!latlonSet)
return;
bool altitudeSet = (m_gpsdData.set & ALTITUDE_SET) == ALTITUDE_SET;
float latitude = float(m_gpsdData.fix.latitude);
float longitude = float(m_gpsdData.fix.longitude);
#if GPSD_API_MAJOR_VERSION >= 9
float altitude = float(m_gpsdData.fix.altMSL);
#else
float altitude = float(m_gpsdData.fix.altitude);
#endif
if (m_aprs != NULL)
m_aprs->setLocation(;latitude, longitude, altitudeSet ? altitude : 0.0F);
for (std::vector<CDMRNetwork*>::const_iterator it = m_networks.begin(); it != m_networks.end(); ++it)
(*it)->writeHomePosition(latitude, longitude);