#29 ad logging of DPRS

pull/32/head
Geoffrey Merck 3 years ago
parent e0892325db
commit 6d889c9372

@ -51,10 +51,14 @@ CAPRSCollector::~CAPRSCollector()
m_collectors.clear();
}
void CAPRSCollector::writeHeader(const std::string& callsign)
void CAPRSCollector::writeHeader(const CHeaderData& header)
{
std::string mycall1 = header.getMyCall1();
std::string mycall2 = header.getMyCall2();
for(auto collector : m_collectors) {
collector->setMyCall(callsign);
collector->setMyCall1(mycall1);
collector->setMyCall2(mycall2);
}
}
@ -95,12 +99,12 @@ unsigned int CAPRSCollector::getData(unsigned char dataType, unsigned char* data
return 0U;
}
void CAPRSCollector::getData(std::function<void(const std::string&)> dataHandler)
void CAPRSCollector::getData(std::function<void(const std::string&, const std::string&)> dataHandler)
{
for(auto collector : m_collectors) {
std::string data;
if(collector->getData(data)) {
dataHandler(data);
dataHandler(data, collector->getMyCall1().append("/").append(collector->getMyCall2()));
collector->reset();
}
}

@ -24,6 +24,7 @@
#include <functional>
#include "SlowDataCollector.h"
#include "HeaderData.h"
#include "Defs.h"
enum APRS_STATE {
@ -39,7 +40,7 @@ public:
CAPRSCollector();
~CAPRSCollector();
void writeHeader(const std::string& callsign);
void writeHeader(const CHeaderData& callsign);
bool writeData(const unsigned char* data);
@ -49,7 +50,7 @@ public:
unsigned int getData(unsigned char dataType, unsigned char* data, unsigned int length);
void getData(std::function<void(const std::string&)> dataHandler);
void getData(std::function<void(const std::string&, const std::string&)> dataHandler);
void clock(unsigned int ms);

@ -22,7 +22,6 @@
#include <cmath>
#include <cassert>
#include <algorithm>
#include "StringUtils.h"
#include "Log.h"
#include "APRSHandler.h"
@ -89,7 +88,7 @@ void CAPRSHandler::writeHeader(const std::string& callsign, const CHeaderData& h
CAPRSCollector* collector = entry->getCollector();
collector->writeHeader(header.getMyCall1());
collector->writeHeader(header);
}
void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data)
@ -122,17 +121,17 @@ void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data)
return;
}
collector->getData([=](const std::string& text)
collector->getData([=](const std::string& rawFrame, const std::string& dstarCall)
{
CAPRSFrame frame;
if(!CAPRSParser::parseFrame(text, frame)) {
CLog::logWarning("Failed to parse DPRS Frame : %s", text.c_str());
if(!CAPRSParser::parseFrame(rawFrame, frame)) {
CLog::logWarning("Failed to parse DPRS Frame : %s", rawFrame.c_str());
return;
}
// If we already have a q-construct, don't send it on
if(std::any_of(frame.getPath().begin(), frame.getPath().end(), [] (std::string s) { return !s.empty() && s[0] == 'q'; })) {
CLog::logWarning("DPRS Frame already has q construct, not forwarding to APRS-IS: %s", text.c_str());
CLog::logWarning("DPRS Frame already has q construct, not forwarding to APRS-IS: %s", rawFrame.c_str());
return;
}
@ -142,6 +141,8 @@ void CAPRSHandler::writeData(const std::string& callsign, const CAMBEData& data)
std::string output ;
CAPRSFormater::frameToString(output, frame);
CLog::logInfo("DPRS\t%s\t%s\t%s", dstarCall.c_str(), frame.getSource().c_str(), rawFrame.c_str());
m_thread->write(frame);
});
}

@ -98,14 +98,14 @@ unsigned int CNMEASentenceCollector::getDataInt(unsigned char * data, unsigned i
bool CNMEASentenceCollector::getDataInt(std::string& data)
{
if(getMyCall().empty() || getSentence().empty())
if(getMyCall1().empty() || getSentence().empty())
return false;
data.clear();
auto nmea = getSentence();
fixUpNMEATimeStamp(nmea);
std::string fromCall = getMyCall();
std::string fromCall = getMyCall1();
CAPRSUtils::dstarCallsignToAPRS(fromCall);
std::string aprsFrame(fromCall);
aprsFrame.append("-5>GPS30,DSTAR*:")

@ -27,7 +27,7 @@ const unsigned int SLOW_DATA_BLOCK_LENGTH = 6U;
CSlowDataCollector::CSlowDataCollector(unsigned char slowDataType) :
m_slowDataType(slowDataType),
m_myCall(),
m_myCall1(),
m_state(SS_FIRST)
{
m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH];
@ -39,14 +39,24 @@ CSlowDataCollector::~CSlowDataCollector()
delete[] m_buffer;
}
std::string CSlowDataCollector::getMyCall() const
std::string CSlowDataCollector::getMyCall1() const
{
return m_myCall;
return m_myCall1;
}
void CSlowDataCollector::setMyCall(const std::string& myCall)
void CSlowDataCollector::setMyCall1(const std::string& myCall)
{
m_myCall = myCall;
m_myCall1 = myCall;
}
std::string CSlowDataCollector::getMyCall2() const
{
return m_myCall2;
}
void CSlowDataCollector::setMyCall2(const std::string& myCall)
{
m_myCall2 = myCall;
}
bool CSlowDataCollector::writeData(const unsigned char* data)

@ -29,8 +29,10 @@ class ISlowDataCollector
public:
virtual ~ISlowDataCollector() { } ;
virtual std::string getMyCall() const = 0;
virtual void setMyCall(const std::string& mycall) = 0;
virtual std::string getMyCall1() const = 0;
virtual void setMyCall1(const std::string& mycall) = 0;
virtual std::string getMyCall2() const = 0;
virtual void setMyCall2(const std::string& mycall) = 0;
virtual bool writeData(const unsigned char* data) = 0;
virtual void sync() = 0;
virtual unsigned int getData(unsigned char* data, unsigned int length) = 0;
@ -46,8 +48,10 @@ public:
CSlowDataCollector(unsigned char slowDataType);
virtual ~CSlowDataCollector();
std::string getMyCall() const;
void setMyCall(const std::string& mycall);
std::string getMyCall1() const;
void setMyCall1(const std::string& mycall);
std::string getMyCall2() const;
void setMyCall2(const std::string& mycall);
bool writeData(const unsigned char* data);
void sync();
unsigned int getData(unsigned char* data, unsigned int length);
@ -64,7 +68,8 @@ protected:
private:
unsigned char m_slowDataType;
std::string m_myCall;
std::string m_myCall1;
std::string m_myCall2;
SLOWDATA_STATE m_state;
unsigned char * m_buffer;
};

@ -33,16 +33,27 @@ CSlowDataCollectorThrottle::~CSlowDataCollectorThrottle()
delete m_collector;
}
std::string CSlowDataCollectorThrottle::getMyCall() const
std::string CSlowDataCollectorThrottle::getMyCall1() const
{
return m_collector->getMyCall();
return m_collector->getMyCall1();
}
void CSlowDataCollectorThrottle::setMyCall(const std::string& mycall)
void CSlowDataCollectorThrottle::setMyCall1(const std::string& mycall)
{
m_isFirst = true;
m_collector->setMyCall(mycall);
m_collector->setMyCall1(mycall);
}
std::string CSlowDataCollectorThrottle::getMyCall2() const
{
return m_collector->getMyCall2();
}
void CSlowDataCollectorThrottle::setMyCall2(const std::string& mycall)
{
m_isFirst = true;
m_collector->setMyCall2(mycall);
}
bool CSlowDataCollectorThrottle::writeData(const unsigned char* data)
{
m_isComplete = false;

@ -28,8 +28,10 @@ class CSlowDataCollectorThrottle : public ISlowDataCollector
public:
CSlowDataCollectorThrottle(ISlowDataCollector* collector, unsigned int timeout);
~CSlowDataCollectorThrottle();
std::string getMyCall() const;
void setMyCall(const std::string& mycall);
std::string getMyCall1() const;
void setMyCall1(const std::string& mycall);
std::string getMyCall2() const;
void setMyCall2(const std::string& mycall);
bool writeData(const unsigned char* data);
void sync();
unsigned int getData(unsigned char* data, unsigned int length);

Loading…
Cancel
Save

Powered by TurnKey Linux.