#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(); 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) { 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; 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) { for(auto collector : m_collectors) {
std::string data; std::string data;
if(collector->getData(data)) { if(collector->getData(data)) {
dataHandler(data); dataHandler(data, collector->getMyCall1().append("/").append(collector->getMyCall2()));
collector->reset(); collector->reset();
} }
} }

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

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

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

@ -27,7 +27,7 @@ const unsigned int SLOW_DATA_BLOCK_LENGTH = 6U;
CSlowDataCollector::CSlowDataCollector(unsigned char slowDataType) : CSlowDataCollector::CSlowDataCollector(unsigned char slowDataType) :
m_slowDataType(slowDataType), m_slowDataType(slowDataType),
m_myCall(), m_myCall1(),
m_state(SS_FIRST) m_state(SS_FIRST)
{ {
m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH]; m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH];
@ -39,14 +39,24 @@ CSlowDataCollector::~CSlowDataCollector()
delete[] m_buffer; 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) bool CSlowDataCollector::writeData(const unsigned char* data)

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

@ -33,16 +33,27 @@ CSlowDataCollectorThrottle::~CSlowDataCollectorThrottle()
delete m_collector; 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_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) bool CSlowDataCollectorThrottle::writeData(const unsigned char* data)
{ {
m_isComplete = false; m_isComplete = false;

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

Loading…
Cancel
Save

Powered by TurnKey Linux.