#9 Refactor APRS Collection logic
This is quie a deep change. Collecting logic has been moved to individual objects/classes. This reduces amount of code (better maitainability) and prepares the path for supporting messages. Supporting newer slow data types is just a matter of adding new ClowDataCollector. This also brings the benefit to support interleaved slow data as this is the case with RS-MS1A messages (messages are interleaved with GPS Data) The source callsign for NMEA sentences is also set with correct SSID (-5) as per http://www.aprs.org/aprs11/SSIDs.txt The NMEA sentences are no longer converted but sent to APRS-S almost as is, just packed into an APRS frame.pull/32/head
parent
769701bedc
commit
045127d90b
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 <cstring>
|
||||
#include <cassert>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "GPSACollector.h"
|
||||
#include "StringUtils.h"
|
||||
#include "Log.h"
|
||||
|
||||
const unsigned int APRS_CSUM_LENGTH = 4U;
|
||||
|
||||
CGPSACollector::CGPSACollector() :
|
||||
CSentenceCollector(SLOW_DATA_TYPE_GPS, "$$CRC", '\x0D')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CGPSACollector::isValidSentence(const std::string& sentence)
|
||||
{
|
||||
return isValidGPSA(sentence);
|
||||
}
|
||||
|
||||
bool CGPSACollector::isValidGPSA(const std::string& gpsa)
|
||||
{
|
||||
if(gpsa.length() < 10U || !boost::starts_with(gpsa, "$$CRC"))
|
||||
return false;
|
||||
|
||||
auto csum = calcCRC(gpsa);
|
||||
auto csumStr = CStringUtils::string_format("%04X", csum);
|
||||
auto expectedCsum = gpsa.substr(5U, APRS_CSUM_LENGTH);
|
||||
bool res = ::strcasecmp(csumStr.c_str(), expectedCsum.c_str()) == 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned int CGPSACollector::calcCRC(const std::string& gpsa)
|
||||
{
|
||||
unsigned int icomcrc = 0xFFFFU;
|
||||
|
||||
auto length = gpsa.length();
|
||||
for (unsigned int j = 10U; j < length; j++) {
|
||||
unsigned char ch = (unsigned char)gpsa[j];
|
||||
|
||||
for (unsigned int i = 0U; i < 8U; i++) {
|
||||
bool xorflag = (((icomcrc ^ ch) & 0x01U) == 0x01U);
|
||||
|
||||
icomcrc >>= 1;
|
||||
|
||||
if (xorflag)
|
||||
icomcrc ^= 0x8408U;
|
||||
|
||||
ch >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ~icomcrc & 0xFFFFU;
|
||||
}
|
||||
|
||||
unsigned int CGPSACollector::getDataInt(unsigned char * data, unsigned int length)
|
||||
{
|
||||
if(data == nullptr || length == 0U || getSentence().empty())
|
||||
return 0U;
|
||||
|
||||
auto aprsFrame = getSentence();
|
||||
if(aprsFrame.length() < 11U)
|
||||
return 0U;
|
||||
|
||||
aprsFrame = aprsFrame.substr(10).append("\r\n");
|
||||
auto aprsFrameLen = aprsFrame.length();
|
||||
|
||||
if(length < aprsFrameLen) {
|
||||
CLog::logDebug("Not enough space to copy GPS-A APRS frame");
|
||||
return 0U;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0U; i < aprsFrameLen; i++){
|
||||
data[i] = aprsFrame[i];
|
||||
}
|
||||
|
||||
return aprsFrameLen;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 "SentenceCollector.h"
|
||||
|
||||
class CGPSACollector : public CSentenceCollector
|
||||
{
|
||||
public:
|
||||
CGPSACollector();
|
||||
|
||||
protected:
|
||||
unsigned int getDataInt(unsigned char * data, unsigned int length);
|
||||
bool isValidSentence(const std::string& sentence);
|
||||
|
||||
private:
|
||||
static unsigned int calcCRC(const std::string& gpsa);
|
||||
static bool isValidGPSA(const std::string& gpsa);
|
||||
|
||||
std::string m_sentence;
|
||||
std::string m_collector;
|
||||
|
||||
};
|
||||
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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.h>
|
||||
#include <cassert>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "NMEASentenceCollector.h"
|
||||
#include "StringUtils.h"
|
||||
#include "Log.h"
|
||||
|
||||
CNMEASentenceCollector::CNMEASentenceCollector(const std::string& sentence) :
|
||||
CSentenceCollector(SLOW_DATA_TYPE_GPS, sentence, '\x0A')
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CNMEASentenceCollector::isValidSentence(const std::string& sentence)
|
||||
{
|
||||
return isValidNMEA(sentence);
|
||||
}
|
||||
|
||||
bool CNMEASentenceCollector::isValidNMEA(const std::string& nmea)
|
||||
{
|
||||
if(nmea.empty() || nmea[0] != '$')
|
||||
return false;
|
||||
|
||||
auto posStar = nmea.find_last_of('*');
|
||||
if(posStar == 0U || posStar == std::string::npos)
|
||||
return false;
|
||||
|
||||
auto csum = calcXOR(nmea);
|
||||
auto csumStr = CStringUtils::string_format("%02X", csum);
|
||||
auto expctedCSumStr = nmea.substr(posStar + 1, 2U);
|
||||
auto res = ::strcasecmp(expctedCSumStr.c_str(), csumStr.c_str()) == 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned char CNMEASentenceCollector::calcXOR(const std::string& nmea)
|
||||
{
|
||||
unsigned char res = 0U;
|
||||
|
||||
if(!nmea.empty()) {
|
||||
unsigned int i = nmea[0] == '$' ? 1U : 0U; //skip $ it it is there
|
||||
while(i < nmea.length())
|
||||
{
|
||||
if(nmea[i] != '*') {
|
||||
res ^= (unsigned char)nmea[i];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned int CNMEASentenceCollector::getDataInt(unsigned char * data, unsigned int length)
|
||||
{
|
||||
if(data == nullptr || length == 0U || getMyCall().empty() || getSentence().empty())
|
||||
return 0U;
|
||||
|
||||
auto nmea = getSentence();
|
||||
fixUpNMEATimeStamp(nmea);
|
||||
|
||||
std::string fromCall = getMyCall();
|
||||
dstarCallsignToAPRS(fromCall);
|
||||
std::string aprsFrame(fromCall);
|
||||
aprsFrame.append("-5>GPS30,DSTAR*:")
|
||||
.append(nmea)
|
||||
.append("\r\n");
|
||||
|
||||
auto aprsFrameLen = aprsFrame.length();
|
||||
if(length < aprsFrameLen) {
|
||||
CLog::logDebug("Not enough space to copy NMEA APRS frame");
|
||||
return 0U;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0U; i < aprsFrameLen; i++){
|
||||
data[i] = aprsFrame[i];
|
||||
}
|
||||
|
||||
return aprsFrameLen;
|
||||
}
|
||||
|
||||
|
||||
void CNMEASentenceCollector::dstarCallsignToAPRS(std::string& dstarCallsign)
|
||||
{
|
||||
if(dstarCallsign[dstarCallsign.length() - 1] == ' ') {
|
||||
boost::trim(dstarCallsign);
|
||||
} else {
|
||||
//loop until got rid of all double blanks
|
||||
while(dstarCallsign.find(" ") != std::string::npos) {
|
||||
boost::replace_all(dstarCallsign, " ", " ");
|
||||
}
|
||||
boost::replace_all(dstarCallsign, " ", "-");//replace remaining blank with a -
|
||||
}
|
||||
}
|
||||
|
||||
// When set on manual position Icom radios send 000000.00 as NMEA timestamps
|
||||
// this is a dirty hack to correct this issue. Actually I am not sure about APRS
|
||||
// software being peeky about this except APRS.fi
|
||||
void CNMEASentenceCollector::fixUpNMEATimeStamp(std::string& nmea)
|
||||
{
|
||||
auto posStar = nmea.find_last_of('*');
|
||||
if(posStar != std::string::npos)
|
||||
nmea = nmea.substr(0, posStar);
|
||||
|
||||
time_t now;
|
||||
::time(&now);
|
||||
struct tm* tm = ::gmtime(&now);
|
||||
auto timeStamp = CStringUtils::string_format(",%02d%02d%02d.00,", tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
boost::replace_all(nmea, ",000000.00,", timeStamp);
|
||||
//recalculate checksum
|
||||
nmea = CStringUtils::string_format("%s*%02x", nmea.c_str(), calcXOR(nmea));
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 "SentenceCollector.h"
|
||||
|
||||
class CNMEASentenceCollector : public CSentenceCollector
|
||||
{
|
||||
public:
|
||||
CNMEASentenceCollector(const std::string& sentence);
|
||||
|
||||
protected:
|
||||
unsigned int getDataInt(unsigned char * data, unsigned int length);
|
||||
bool isValidSentence(const std::string& sentence);
|
||||
|
||||
private:
|
||||
static void dstarCallsignToAPRS(std::string& call);
|
||||
static bool isValidNMEA(const std::string& nmea);
|
||||
static unsigned char calcXOR(const std::string& nmea);
|
||||
static void fixUpNMEATimeStamp(std::string& nmea);
|
||||
};
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 "SentenceCollector.h"
|
||||
|
||||
CSentenceCollector::CSentenceCollector(unsigned char slowDataType, const std::string& sentenceIdentifier, unsigned char endMarker) :
|
||||
CSlowDataCollector(slowDataType),
|
||||
m_collector(),
|
||||
m_sentenceIdentifier(sentenceIdentifier),
|
||||
m_sentence(),
|
||||
m_endMarker(endMarker)
|
||||
{
|
||||
assert(!sentenceIdentifier.empty());
|
||||
}
|
||||
|
||||
bool CSentenceCollector::addData(const unsigned char * data)
|
||||
{
|
||||
m_collector.append(std::string((char*)data, 5U));
|
||||
|
||||
std::string::size_type n2 = m_collector.find_last_of(m_endMarker);
|
||||
if (n2 == std::string::npos)
|
||||
return false;
|
||||
|
||||
std::string::size_type n1 = m_collector.find(m_sentenceIdentifier);
|
||||
if (n1 == std::string::npos)
|
||||
return false;
|
||||
|
||||
if(n2 < n1)
|
||||
return false;
|
||||
|
||||
std::string sentence;
|
||||
for(unsigned int i = n1; i <= n2; i++) {
|
||||
sentence.push_back(m_collector[i] & 0x7FU);
|
||||
}
|
||||
|
||||
bool ret = isValidSentence(sentence);
|
||||
if(ret) {
|
||||
m_sentence = sentence;
|
||||
} else {
|
||||
m_sentence.clear();
|
||||
}
|
||||
|
||||
m_collector = m_collector.substr(n2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string CSentenceCollector::getSentence()
|
||||
{
|
||||
return m_sentence;
|
||||
}
|
||||
|
||||
void CSentenceCollector::resetInt()
|
||||
{
|
||||
m_collector.clear();
|
||||
m_sentence.clear();
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 "SlowDataCollector.h"
|
||||
|
||||
class CSentenceCollector : public CSlowDataCollector
|
||||
{
|
||||
public:
|
||||
CSentenceCollector(unsigned char slowDataType, const std::string& sentenceIdentifier, unsigned char endMarker);
|
||||
|
||||
protected:
|
||||
bool addData(const unsigned char * data);
|
||||
|
||||
virtual unsigned int getDataInt(unsigned char * data, unsigned int length) = 0;
|
||||
static void dstarCallsignToAPRS(std::string& call);
|
||||
std::string getSentence();
|
||||
|
||||
private:
|
||||
virtual bool isValidSentence(const std::string& sentence) = 0;
|
||||
virtual void resetInt();
|
||||
|
||||
std::string m_collector;
|
||||
std::string m_sentenceIdentifier;
|
||||
std::string m_sentence;
|
||||
unsigned char m_endMarker;
|
||||
};
|
||||
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 <cstring>
|
||||
|
||||
#include "SlowDataCollector.h"
|
||||
|
||||
const unsigned int SLOW_DATA_BLOCK_LENGTH = 6U;
|
||||
|
||||
CSlowDataCollector::CSlowDataCollector(unsigned char slowDataType) :
|
||||
m_slowDataType(slowDataType),
|
||||
m_myCall(),
|
||||
m_state(SS_FIRST)
|
||||
{
|
||||
m_buffer = new unsigned char[SLOW_DATA_BLOCK_LENGTH];
|
||||
std::memset(m_buffer, 0, SLOW_DATA_BLOCK_LENGTH);
|
||||
}
|
||||
|
||||
CSlowDataCollector::~CSlowDataCollector()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
}
|
||||
|
||||
std::string CSlowDataCollector::getMyCall() const
|
||||
{
|
||||
return m_myCall;
|
||||
}
|
||||
|
||||
void CSlowDataCollector::setMyCall(const std::string& myCall)
|
||||
{
|
||||
m_myCall = myCall;
|
||||
}
|
||||
|
||||
bool CSlowDataCollector::writeData(const unsigned char* data)
|
||||
{
|
||||
assert(data != nullptr);
|
||||
|
||||
switch (m_state) {
|
||||
case SS_FIRST:
|
||||
m_buffer[0U] = data[0U] ^ SCRAMBLER_BYTE1;
|
||||
m_buffer[1U] = data[1U] ^ SCRAMBLER_BYTE2;
|
||||
m_buffer[2U] = data[2U] ^ SCRAMBLER_BYTE3;
|
||||
m_state = SS_SECOND;
|
||||
return false;
|
||||
|
||||
case SS_SECOND:
|
||||
m_buffer[3U] = data[0U] ^ SCRAMBLER_BYTE1;
|
||||
m_buffer[4U] = data[1U] ^ SCRAMBLER_BYTE2;
|
||||
m_buffer[5U] = data[2U] ^ SCRAMBLER_BYTE3;
|
||||
m_state = SS_FIRST;
|
||||
break;
|
||||
}
|
||||
|
||||
if((m_buffer[0] & SLOW_DATA_TYPE_MASK) == m_slowDataType)
|
||||
return addData(m_buffer + 1U);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSlowDataCollector::sync()
|
||||
{
|
||||
m_state = SS_FIRST;
|
||||
}
|
||||
|
||||
unsigned int CSlowDataCollector::getData(unsigned char * data, unsigned int length)
|
||||
{
|
||||
return getDataInt(data, length);
|
||||
}
|
||||
|
||||
void CSlowDataCollector::reset()
|
||||
{
|
||||
m_state = SS_FIRST;
|
||||
m_myCall.clear();
|
||||
resetInt();
|
||||
}
|
||||
|
||||
unsigned char CSlowDataCollector::getDataType()
|
||||
{
|
||||
return m_slowDataType;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
||||
* 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 "DStarDefines.h"
|
||||
#include "Defs.h"
|
||||
|
||||
class CSlowDataCollector
|
||||
{
|
||||
public:
|
||||
CSlowDataCollector(unsigned char slowDataType);
|
||||
virtual ~CSlowDataCollector();
|
||||
|
||||
std::string getMyCall() const;
|
||||
void setMyCall(const std::string& mycall);
|
||||
bool writeData(const unsigned char* data);
|
||||
void sync();
|
||||
unsigned int getData(unsigned char* data, unsigned int length);
|
||||
void reset();
|
||||
unsigned char getDataType();
|
||||
|
||||
protected:
|
||||
virtual bool addData(const unsigned char* data) = 0;
|
||||
virtual unsigned int getDataInt(unsigned char* data, unsigned int length) = 0;
|
||||
virtual void resetInt() { }
|
||||
|
||||
private:
|
||||
unsigned char m_slowDataType;
|
||||
std::string m_myCall;
|
||||
SLOWDATA_STATE m_state;
|
||||
unsigned char * m_buffer;
|
||||
};
|
||||
Loading…
Reference in new issue