commit
277e8766ff
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010,2011,2012,2018 by Jonathan Naylor G4KLX
|
||||||
|
* Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include "APRSEntry.h"
|
||||||
|
|
||||||
|
CAPRSEntry::CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl) :
|
||||||
|
m_callsign(callsign),
|
||||||
|
m_band(band),
|
||||||
|
m_frequency(frequency),
|
||||||
|
m_offset(offset),
|
||||||
|
m_range(range),
|
||||||
|
m_latitude(latitude),
|
||||||
|
m_longitude(longitude),
|
||||||
|
m_agl(agl),
|
||||||
|
m_timer(1000U, 10U),
|
||||||
|
m_first(true),
|
||||||
|
m_collector(NULL),
|
||||||
|
m_linkStatus()
|
||||||
|
{
|
||||||
|
boost::trim(m_callsign);
|
||||||
|
|
||||||
|
m_collector = new CAPRSCollector;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAPRSEntry::~CAPRSEntry()
|
||||||
|
{
|
||||||
|
delete m_collector;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CAPRSEntry::getCallsign() const
|
||||||
|
{
|
||||||
|
return m_callsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CAPRSEntry::getBand() const
|
||||||
|
{
|
||||||
|
return m_band;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CAPRSEntry::getFrequency() const
|
||||||
|
{
|
||||||
|
return m_frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CAPRSEntry::getOffset() const
|
||||||
|
{
|
||||||
|
return m_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CAPRSEntry::getRange() const
|
||||||
|
{
|
||||||
|
return m_range;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CAPRSEntry::getLatitude() const
|
||||||
|
{
|
||||||
|
return m_latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CAPRSEntry::getLongitude() const
|
||||||
|
{
|
||||||
|
return m_longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CAPRSEntry::getAGL() const
|
||||||
|
{
|
||||||
|
return m_agl;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAPRSCollector* CAPRSEntry::getCollector() const
|
||||||
|
{
|
||||||
|
return m_collector;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAPRSEntryStatus& CAPRSEntry::getStatus()
|
||||||
|
{
|
||||||
|
return m_linkStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAPRSEntry::reset()
|
||||||
|
{
|
||||||
|
m_first = true;
|
||||||
|
m_timer.stop();
|
||||||
|
m_collector->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAPRSEntry::clock(unsigned int ms)
|
||||||
|
{
|
||||||
|
m_linkStatus.clock(ms);
|
||||||
|
m_timer.clock(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAPRSEntry::isOK()
|
||||||
|
{
|
||||||
|
if (m_first) {
|
||||||
|
m_first = false;
|
||||||
|
m_timer.start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_timer.hasExpired()) {
|
||||||
|
m_timer.start();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
m_timer.start();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010,2011,2012,2018 by Jonathan Naylor G4KLX
|
||||||
|
* Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "APRSCollector.h"
|
||||||
|
#include "APRSEntryStatus.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
#include "Defs.h"
|
||||||
|
|
||||||
|
class CAPRSEntry {
|
||||||
|
public:
|
||||||
|
CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl);
|
||||||
|
~CAPRSEntry();
|
||||||
|
|
||||||
|
std::string getCallsign() const;
|
||||||
|
std::string getBand() const;
|
||||||
|
double getFrequency() const;
|
||||||
|
double getOffset() const;
|
||||||
|
double getRange() const;
|
||||||
|
double getLatitude() const;
|
||||||
|
double getLongitude() const;
|
||||||
|
double getAGL() const;
|
||||||
|
CAPRSCollector* getCollector() const;
|
||||||
|
CAPRSEntryStatus& getStatus();
|
||||||
|
|
||||||
|
// Transmission timer
|
||||||
|
void reset();
|
||||||
|
void clock(unsigned int ms);
|
||||||
|
bool isOK();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_callsign;
|
||||||
|
std::string m_band;
|
||||||
|
double m_frequency;
|
||||||
|
double m_offset;
|
||||||
|
double m_range;
|
||||||
|
double m_latitude;
|
||||||
|
double m_longitude;
|
||||||
|
double m_agl;
|
||||||
|
CTimer m_timer;
|
||||||
|
bool m_first;
|
||||||
|
CAPRSCollector* m_collector;
|
||||||
|
CAPRSEntryStatus m_linkStatus;
|
||||||
|
};
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 "APRSEntryStatus.h"
|
||||||
|
|
||||||
|
CAPRSEntryStatus::CAPRSEntryStatus() :
|
||||||
|
m_status(),
|
||||||
|
m_statusChanged(false),
|
||||||
|
m_timer(1000U)
|
||||||
|
{
|
||||||
|
m_timer.setTimeout(20U * 60U); //statuses go out every 20 minutes or every change
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAPRSEntryStatus::isOutOfDate()
|
||||||
|
{
|
||||||
|
bool ouOfDate = m_statusChanged || m_timer.hasExpired();
|
||||||
|
m_statusChanged = false;
|
||||||
|
return ouOfDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string CAPRSEntryStatus::getStatus() const
|
||||||
|
{
|
||||||
|
return m_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAPRSEntryStatus::setStatus(const std::string& linkstatus)
|
||||||
|
{
|
||||||
|
bool changed = m_status != linkstatus;
|
||||||
|
if(changed) {
|
||||||
|
m_status = linkstatus;
|
||||||
|
}
|
||||||
|
m_statusChanged = changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAPRSEntryStatus::clock(unsigned int ms)
|
||||||
|
{
|
||||||
|
m_timer.clock(ms);
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
|
class CAPRSEntryStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAPRSEntryStatus() ;
|
||||||
|
|
||||||
|
std::string getStatus() const;
|
||||||
|
bool isOutOfDate();
|
||||||
|
void setStatus(const std::string& destination);
|
||||||
|
void clock(unsigned int ms);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_status;
|
||||||
|
bool m_statusChanged;
|
||||||
|
CTimer m_timer;
|
||||||
|
};
|
||||||
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 <string>
|
||||||
|
#include <cmath>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include "APRSFixedIdFrameProvider.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
|
CAPRSFixedIdFrameProvider::CAPRSFixedIdFrameProvider() :
|
||||||
|
CAPRSIdFrameProvider(20U) // Initial timeout of 20 seconds
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAPRSFixedIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * entry, std::vector<std::string>& frames)
|
||||||
|
{
|
||||||
|
if (entry == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Default values aren't passed on
|
||||||
|
if (entry->getLatitude() == 0.0 && entry->getLongitude() == 0.0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
frames.clear();
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
::time(&now);
|
||||||
|
struct tm* tm = ::gmtime(&now);
|
||||||
|
|
||||||
|
std::string desc;
|
||||||
|
if (entry->getBand().length() > 1U) {
|
||||||
|
if (entry->getFrequency() != 0.0)
|
||||||
|
desc = CStringUtils::string_format("Data %.5lfMHz", entry->getFrequency());
|
||||||
|
else
|
||||||
|
desc = "Data";
|
||||||
|
} else {
|
||||||
|
if (entry->getFrequency() != 0.0)
|
||||||
|
desc = CStringUtils::string_format("Voice %.5lfMHz %c%.4lfMHz",
|
||||||
|
entry->getFrequency(),
|
||||||
|
entry->getOffset() < 0.0 ? '-' : '+',
|
||||||
|
std::fabs(entry->getOffset()));
|
||||||
|
else
|
||||||
|
desc = "Voice";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string band;
|
||||||
|
if (entry->getFrequency() >= 1200.0)
|
||||||
|
band = "1.2";
|
||||||
|
else if (entry->getFrequency() >= 420.0)
|
||||||
|
band = "440";
|
||||||
|
else if (entry->getFrequency() >= 144.0)
|
||||||
|
band = "2m";
|
||||||
|
else if (entry->getFrequency() >= 50.0)
|
||||||
|
band = "6m";
|
||||||
|
else if (entry->getFrequency() >= 28.0)
|
||||||
|
band = "10m";
|
||||||
|
|
||||||
|
double tempLat = ::fabs(entry->getLatitude());
|
||||||
|
double tempLong = ::fabs(entry->getLongitude());
|
||||||
|
|
||||||
|
double latitude = ::floor(tempLat);
|
||||||
|
double longitude = ::floor(tempLong);
|
||||||
|
|
||||||
|
latitude = (tempLat - latitude) * 60.0 + latitude * 100.0;
|
||||||
|
longitude = (tempLong - longitude) * 60.0 + longitude * 100.0;
|
||||||
|
|
||||||
|
std::string lat;
|
||||||
|
if (latitude >= 1000.0F)
|
||||||
|
lat = CStringUtils::string_format("%.2lf", latitude);
|
||||||
|
else if (latitude >= 100.0F)
|
||||||
|
lat = CStringUtils::string_format("0%.2lf", latitude);
|
||||||
|
else if (latitude >= 10.0F)
|
||||||
|
lat = CStringUtils::string_format("00%.2lf", latitude);
|
||||||
|
else
|
||||||
|
lat = CStringUtils::string_format("000%.2lf", latitude);
|
||||||
|
|
||||||
|
std::string lon;
|
||||||
|
if (longitude >= 10000.0F)
|
||||||
|
lon = CStringUtils::string_format("%.2lf", longitude);
|
||||||
|
else if (longitude >= 1000.0F)
|
||||||
|
lon = CStringUtils::string_format("0%.2lf", longitude);
|
||||||
|
else if (longitude >= 100.0F)
|
||||||
|
lon = CStringUtils::string_format("00%.2lf", longitude);
|
||||||
|
else if (longitude >= 10.0F)
|
||||||
|
lon = CStringUtils::string_format("000%.2lf", longitude);
|
||||||
|
else
|
||||||
|
lon = CStringUtils::string_format("0000%.2lf", longitude);
|
||||||
|
|
||||||
|
// Convert commas to periods in the latitude and longitude
|
||||||
|
boost::replace_all(lat, ",", ".");
|
||||||
|
boost::replace_all(lon, ",", ".");
|
||||||
|
|
||||||
|
std::string output = CStringUtils::string_format("%s-S>APD5T1,TCPIP*,qAC,%s-GS:;%-7s%-2s*%02d%02d%02dz%s%cD%s%caRNG%04.0lf/A=%06.0lf %s %s\r\n",
|
||||||
|
gateway.c_str(), gateway.c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
|
||||||
|
tm->tm_mday, tm->tm_hour, tm->tm_min,
|
||||||
|
lat.c_str(), (entry->getLatitude() < 0.0F) ? 'S' : 'N',
|
||||||
|
lon.c_str(), (entry->getLongitude() < 0.0F) ? 'W' : 'E',
|
||||||
|
entry->getRange() * 0.6214, entry->getAGL() * 3.28, band.c_str(), desc.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
frames.push_back(output);
|
||||||
|
|
||||||
|
if (entry->getBand().length() == 1U) {
|
||||||
|
output = CStringUtils::string_format("%s-%s>APD5T2,TCPIP*,qAC,%s-%sS:!%s%cD%s%c&RNG%04.0lf/A=%06.0lf %s %s\r\n",
|
||||||
|
entry->getCallsign().c_str(), entry->getBand().c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
|
||||||
|
lat.c_str(), (entry->getLatitude() < 0.0F) ? 'S' : 'N',
|
||||||
|
lon.c_str(), (entry->getLongitude() < 0.0F) ? 'W' : 'E',
|
||||||
|
entry->getRange() * 0.6214, entry->getAGL() * 3.28, band.c_str(), desc.c_str());
|
||||||
|
|
||||||
|
frames.push_back(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(20U * 60U);//20 minutes, plenty enough for fixed
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "APRSIdFrameProvider.h"
|
||||||
|
|
||||||
|
class CAPRSFixedIdFrameProvider : public CAPRSIdFrameProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAPRSFixedIdFrameProvider();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector<std::string>& frames);
|
||||||
|
};
|
||||||
@ -0,0 +1,212 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef USE_DGPS
|
||||||
|
#include <cmath>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include "APRSGPSDIdFrameProvider.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
|
CAPRSGPSDIdFrameProvider::CAPRSGPSDIdFrameProvider(std::string address, std::string port) :
|
||||||
|
CAPRSIdFrameProvider(20U),
|
||||||
|
m_gpsdAddress(address),
|
||||||
|
m_gpsdPort(port),
|
||||||
|
m_gpsdData(),
|
||||||
|
m_hasConnection(false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAPRSGPSDIdFrameProvider::start()
|
||||||
|
{
|
||||||
|
int ret = ::gps_open(m_gpsdAddress.c_str(), m_gpsdPort.c_str(), &m_gpsdData);
|
||||||
|
if (ret != 0) {
|
||||||
|
CLog::logError("Error when opening access to gpsd - %d - %s", errno, ::gps_errstr(errno));
|
||||||
|
m_hasConnection = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL);
|
||||||
|
CLog::logError("Connected to GPSD");
|
||||||
|
m_hasConnection = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAPRSGPSDIdFrameProvider::close()
|
||||||
|
{
|
||||||
|
if(m_hasConnection) {
|
||||||
|
::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL);
|
||||||
|
::gps_close(&m_gpsdData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAPRSGPSDIdFrameProvider::buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * entry, std::vector<std::string>& frames)
|
||||||
|
{
|
||||||
|
if(!m_hasConnection) {
|
||||||
|
this->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_hasConnection || !::gps_waiting(&m_gpsdData, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if GPSD_API_MAJOR_VERSION >= 7
|
||||||
|
char message[1024];
|
||||||
|
if (::gps_read(&m_gpsdData, message, 1024) <= 0)
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
if (::gps_read(&m_gpsdData) <= 0)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if GPSD_API_MAJOR_VERSION >= 10
|
||||||
|
if(m_gpsdData.fix.status == STATUS_NO_FIX)
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
if (m_gpsdData.status != STATUS_FIX)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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 false;
|
||||||
|
|
||||||
|
float rawLatitude = float(m_gpsdData.fix.latitude);
|
||||||
|
float rawLongitude = float(m_gpsdData.fix.longitude);
|
||||||
|
#if GPSD_API_MAJOR_VERSION >= 9
|
||||||
|
float rawAltitude = float(m_gpsdData.fix.altMSL);
|
||||||
|
#else
|
||||||
|
float rawAltitude = float(m_gpsdData.fix.altitude);
|
||||||
|
#endif
|
||||||
|
float rawVelocity = float(m_gpsdData.fix.speed);
|
||||||
|
float rawBearing = float(m_gpsdData.fix.track);
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
::time(&now);
|
||||||
|
struct tm* tm = ::gmtime(&now);
|
||||||
|
if (entry == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string desc;
|
||||||
|
if (entry->getBand().length() > 1U) {
|
||||||
|
if (entry->getFrequency() != 0.0)
|
||||||
|
desc = CStringUtils::string_format("Data %.5lfMHz", entry->getFrequency());
|
||||||
|
else
|
||||||
|
desc = "Data";
|
||||||
|
} else {
|
||||||
|
if (entry->getFrequency() != 0.0)
|
||||||
|
desc = CStringUtils::string_format("Voice %.5lfMHz %c%.4lfMHz",
|
||||||
|
entry->getFrequency(),
|
||||||
|
entry->getOffset() < 0.0 ? '-' : '+',
|
||||||
|
::fabs(entry->getOffset()));
|
||||||
|
else
|
||||||
|
desc = "Voice";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string band;
|
||||||
|
if (entry->getFrequency() >= 1200.0)
|
||||||
|
band = "1.2";
|
||||||
|
else if (entry->getFrequency() >= 420.0)
|
||||||
|
band = "440";
|
||||||
|
else if (entry->getFrequency() >= 144.0)
|
||||||
|
band = "2m";
|
||||||
|
else if (entry->getFrequency() >= 50.0)
|
||||||
|
band = "6m";
|
||||||
|
else if (entry->getFrequency() >= 28.0)
|
||||||
|
band = "10m";
|
||||||
|
|
||||||
|
double tempLat = ::fabs(rawLatitude);
|
||||||
|
double tempLong = ::fabs(rawLongitude);
|
||||||
|
|
||||||
|
double latitude = ::floor(tempLat);
|
||||||
|
double longitude = ::floor(tempLong);
|
||||||
|
|
||||||
|
latitude = (tempLat - latitude) * 60.0 + latitude * 100.0;
|
||||||
|
longitude = (tempLong - longitude) * 60.0 + longitude * 100.0;
|
||||||
|
|
||||||
|
std::string lat;
|
||||||
|
if (latitude >= 1000.0F)
|
||||||
|
lat = CStringUtils::string_format("%.2lf", latitude);
|
||||||
|
else if (latitude >= 100.0F)
|
||||||
|
lat = CStringUtils::string_format("0%.2lf", latitude);
|
||||||
|
else if (latitude >= 10.0F)
|
||||||
|
lat = CStringUtils::string_format("00%.2lf", latitude);
|
||||||
|
else
|
||||||
|
lat = CStringUtils::string_format("000%.2lf", latitude);
|
||||||
|
|
||||||
|
std::string lon;
|
||||||
|
if (longitude >= 10000.0F)
|
||||||
|
lon = CStringUtils::string_format("%.2lf", longitude);
|
||||||
|
else if (longitude >= 1000.0F)
|
||||||
|
lon = CStringUtils::string_format("0%.2lf", longitude);
|
||||||
|
else if (longitude >= 100.0F)
|
||||||
|
lon = CStringUtils::string_format("00%.2lf", longitude);
|
||||||
|
else if (longitude >= 10.0F)
|
||||||
|
lon = CStringUtils::string_format("000%.2lf", longitude);
|
||||||
|
else
|
||||||
|
lon = CStringUtils::string_format("0000%.2lf", longitude);
|
||||||
|
|
||||||
|
// Convert commas to periods in the latitude and longitude
|
||||||
|
boost::replace_all(lat, ",", ".");
|
||||||
|
boost::replace_all(lon, ",", ".");
|
||||||
|
|
||||||
|
std::string output1 = CStringUtils::string_format("%s-S>APD5T1,TCPIP*,qAC,%s-GS:;%-7s%-2s*%02d%02d%02dz%s%cD%s%ca/A=%06.0lf",
|
||||||
|
gateway.c_str(), gateway.c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
|
||||||
|
tm->tm_mday, tm->tm_hour, tm->tm_min,
|
||||||
|
lat.c_str(), (rawLatitude < 0.0) ? 'S' : 'N',
|
||||||
|
lon.c_str(), (rawLongitude < 0.0) ? 'W' : 'E',
|
||||||
|
rawAltitude * 3.28);
|
||||||
|
|
||||||
|
std::string output2;
|
||||||
|
if (bearingSet && velocitySet)
|
||||||
|
output2 = CStringUtils::string_format("%03.0lf/%03.0lf", rawBearing, rawVelocity * 0.539957F);
|
||||||
|
|
||||||
|
std::string output3;
|
||||||
|
output3 = CStringUtils::string_format("RNG%04.0lf %s %s\r\n", entry->getRange() * 0.6214, band.c_str(), desc.c_str());
|
||||||
|
|
||||||
|
CLog::logDebug("APRS ==> %s%s%s", output1.c_str(), output2.c_str(), output3.c_str());
|
||||||
|
|
||||||
|
frames.push_back(output1.append(output2).append(output3));
|
||||||
|
|
||||||
|
if (entry->getBand().length() == 1U) {
|
||||||
|
if (altitudeSet)
|
||||||
|
output1 = CStringUtils::string_format("%s-%s>APD5T2,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) ? 'S' : 'N',
|
||||||
|
lon.c_str(), (rawLongitude < 0.0) ? 'W' : 'E',
|
||||||
|
rawAltitude * 3.28);
|
||||||
|
else
|
||||||
|
output1 = CStringUtils::string_format("%s-%s>APD5T2,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) ? 'S' : 'N',
|
||||||
|
lon.c_str(), (rawLongitude < 0.0) ? 'W' : 'E');
|
||||||
|
|
||||||
|
CLog::logDebug("APRS ==> %s%s%s", output1.c_str(), output2.c_str(), output3.c_str());
|
||||||
|
|
||||||
|
frames.push_back(output1.append(output2).append(output3));
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(60U * 5U);//5 Minutes is plenty enough we aint an APRS tracker !
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Defs.h"
|
||||||
|
|
||||||
|
#ifdef USE_GPSD
|
||||||
|
#include <gps.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "APRSIdFrameProvider.h"
|
||||||
|
|
||||||
|
class CAPRSGPSDIdFrameProvider : public CAPRSIdFrameProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAPRSGPSDIdFrameProvider(std::string address, std::string port);
|
||||||
|
|
||||||
|
virtual void start();
|
||||||
|
virtual void close();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector<std::string>& frames);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_gpsdAddress;
|
||||||
|
std::string m_gpsdPort;
|
||||||
|
struct gps_data_t m_gpsdData;
|
||||||
|
bool m_hasConnection;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 <cassert>
|
||||||
|
|
||||||
|
#include "APRSIdFrameProvider.h"
|
||||||
|
|
||||||
|
CAPRSIdFrameProvider::CAPRSIdFrameProvider(unsigned int timeout) :
|
||||||
|
m_timer(1000U)
|
||||||
|
{
|
||||||
|
m_timer.start(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
CAPRSIdFrameProvider::~CAPRSIdFrameProvider()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAPRSIdFrameProvider::buildAPRSFrames(const std::string& gateway, const CAPRSEntry * entry, std::vector<std::string> & frames)
|
||||||
|
{
|
||||||
|
assert(entry != nullptr);
|
||||||
|
|
||||||
|
return buildAPRSFramesInt(gateway, entry, frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAPRSIdFrameProvider::wantsToSend()
|
||||||
|
{
|
||||||
|
if(m_timer.hasExpired())
|
||||||
|
{
|
||||||
|
m_timer.start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Timer.h"
|
||||||
|
#include "APRSEntry.h"
|
||||||
|
|
||||||
|
class CAPRSIdFrameProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAPRSIdFrameProvider(unsigned int timeOut);
|
||||||
|
virtual ~CAPRSIdFrameProvider();
|
||||||
|
|
||||||
|
bool buildAPRSFrames(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector<std::string>& frames);
|
||||||
|
void clock(unsigned int ms) { m_timer.clock(ms); }
|
||||||
|
bool wantsToSend();
|
||||||
|
virtual void start() { };
|
||||||
|
virtual void close() { };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool buildAPRSFramesInt(const std::string& gateway, const CAPRSEntry * aprsEntry, std::vector<std::string>& frames) = 0;
|
||||||
|
|
||||||
|
void setTimeout(unsigned int timeout)
|
||||||
|
{
|
||||||
|
m_timer.start(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CTimer m_timer;
|
||||||
|
};
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 <iostream>
|
||||||
|
|
||||||
|
#include "LogConsoleTarget.h"
|
||||||
|
|
||||||
|
CLogConsoleTarget::CLogConsoleTarget(LOG_SEVERITY logLevel) :
|
||||||
|
CLogTarget(logLevel)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogConsoleTarget::printLogInt(const std::string& msg)
|
||||||
|
{
|
||||||
|
std::cout << msg;
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "LogTarget.h"
|
||||||
|
|
||||||
|
class CLogConsoleTarget : public CLogTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLogConsoleTarget(LOG_SEVERITY logLevel);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void printLogInt(const std::string& msg);
|
||||||
|
};
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <chrono>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
#include "LogFileTarget.h"
|
||||||
|
|
||||||
|
CLogFileTarget::CLogFileTarget(LOG_SEVERITY logLevel, const std::string & dir, bool rotate) :
|
||||||
|
CLogTarget(logLevel),
|
||||||
|
m_dir(dir),
|
||||||
|
m_rotate(rotate)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogFileTarget::printLogInt(const std::string& msg)
|
||||||
|
{
|
||||||
|
// construct filename
|
||||||
|
std::string fileName(m_dir);
|
||||||
|
if(fileName[fileName.length() - 1U] != '/') fileName.push_back('/');
|
||||||
|
fileName.append("dstargateway");
|
||||||
|
|
||||||
|
if(m_rotate) {
|
||||||
|
std::time_t now = std::time(0);
|
||||||
|
std::tm* now_tm = std::gmtime(&now);
|
||||||
|
char buf[64];
|
||||||
|
std::strftime(buf, 42, "-%Y-%m-%d", now_tm);
|
||||||
|
fileName.append(std::string(buf));
|
||||||
|
}
|
||||||
|
fileName.append(".log");
|
||||||
|
|
||||||
|
std::ofstream file;
|
||||||
|
file.open(fileName, std::ios::app);
|
||||||
|
if(file.is_open()) {
|
||||||
|
file << msg;
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "LogTarget.h"
|
||||||
|
|
||||||
|
class CLogFileTarget : public CLogTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLogFileTarget(LOG_SEVERITY logLevel, const std::string& directory, bool rotate);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void printLogInt(const std::string& msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_dir;
|
||||||
|
bool m_rotate;
|
||||||
|
};
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
enum LOG_SEVERITY : unsigned int {
|
||||||
|
LOG_TRACE = 1,
|
||||||
|
LOG_DEBUG,
|
||||||
|
LOG_INFO,
|
||||||
|
LOG_WARNING,
|
||||||
|
LOG_ERROR,
|
||||||
|
LOG_FATAL,
|
||||||
|
LOG_NONE = 0xFFFFFFFF
|
||||||
|
};
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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 "LogTarget.h"
|
||||||
|
|
||||||
|
CLogTarget::CLogTarget(LOG_SEVERITY logLevel) :
|
||||||
|
m_logLevel(logLevel)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogTarget::~CLogTarget()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogTarget::printLog(const std::string& msg)
|
||||||
|
{
|
||||||
|
printLogInt(msg);
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022 by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "LogSeverity.h"
|
||||||
|
|
||||||
|
class CLogTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLogTarget(LOG_SEVERITY logLevel);
|
||||||
|
virtual ~CLogTarget();
|
||||||
|
void printLog(const std::string& msg);
|
||||||
|
LOG_SEVERITY getLevel() { return m_logLevel; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void printLogInt(const std::string& msg) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
LOG_SEVERITY m_logLevel;
|
||||||
|
};
|
||||||
Loading…
Reference in new issue