2018-05-09 20:23:17 +02:00
|
|
|
/*
|
2018-06-26 23:04:05 +02:00
|
|
|
* Copyright (C) 2010,2012,2018 by Jonathan Naylor G4KLX
|
2018-05-09 20:23:17 +02:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef APRSCollector_H
|
|
|
|
|
#define APRSCollector_H
|
|
|
|
|
|
|
|
|
|
#include "Defs.h"
|
|
|
|
|
|
|
|
|
|
#include <wx/wx.h>
|
|
|
|
|
|
|
|
|
|
enum APRS_STATE {
|
|
|
|
|
AS_NONE,
|
|
|
|
|
AS_GGA,
|
|
|
|
|
AS_RMC,
|
2018-06-26 23:04:05 +02:00
|
|
|
AS_CRC
|
2018-05-09 20:23:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CAPRSCollector {
|
|
|
|
|
public:
|
|
|
|
|
CAPRSCollector();
|
|
|
|
|
~CAPRSCollector();
|
|
|
|
|
|
2018-07-17 20:15:25 +02:00
|
|
|
void writeHeader(const wxString& callsign);
|
2018-05-09 20:23:17 +02:00
|
|
|
|
2018-07-17 20:15:25 +02:00
|
|
|
bool writeData(const unsigned char* data);
|
2018-05-09 20:23:17 +02:00
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
|
2018-07-17 20:15:25 +02:00
|
|
|
void sync();
|
|
|
|
|
|
2018-05-09 20:23:17 +02:00
|
|
|
unsigned int getData(unsigned char* data, unsigned int length);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
APRS_STATE m_state;
|
|
|
|
|
unsigned char* m_ggaData;
|
|
|
|
|
unsigned int m_ggaLength;
|
|
|
|
|
bool m_ggaValid;
|
|
|
|
|
unsigned char* m_rmcData;
|
|
|
|
|
unsigned int m_rmcLength;
|
|
|
|
|
bool m_rmcValid;
|
|
|
|
|
unsigned char* m_crcData;
|
|
|
|
|
unsigned int m_crcLength;
|
|
|
|
|
bool m_crcValid;
|
|
|
|
|
unsigned char* m_buffer;
|
|
|
|
|
SLOWDATA_STATE m_slowData;
|
2018-06-26 23:04:05 +02:00
|
|
|
wxString m_collector;
|
2018-06-27 07:31:33 +02:00
|
|
|
wxString m_callsign;
|
2018-05-09 20:23:17 +02:00
|
|
|
|
2018-06-26 23:04:05 +02:00
|
|
|
bool addGPSData(const unsigned char* data);
|
|
|
|
|
|
|
|
|
|
void addGGAData();
|
2018-06-27 07:31:33 +02:00
|
|
|
bool addRMCData();
|
2018-06-26 23:04:05 +02:00
|
|
|
bool addCRCData();
|
2018-05-09 20:23:17 +02:00
|
|
|
|
|
|
|
|
bool checkXOR(const unsigned char* data, unsigned int length) const;
|
|
|
|
|
unsigned char calcXOR(const unsigned char* buffer, unsigned int length) const;
|
|
|
|
|
|
|
|
|
|
bool checkCRC(const unsigned char* data, unsigned int length) const;
|
|
|
|
|
unsigned int calcCRC(const unsigned char* buffer, unsigned int length) const;
|
|
|
|
|
|
|
|
|
|
unsigned int convertNMEA1(unsigned char* data, unsigned int length);
|
|
|
|
|
unsigned int convertNMEA2(unsigned char* data, unsigned int length);
|
|
|
|
|
|
2018-07-17 20:15:25 +02:00
|
|
|
void dstarCallsignToAPRS(const wxString& dstarCallsign, char* aprsCallsign) const;
|
|
|
|
|
|
2018-05-09 20:23:17 +02:00
|
|
|
char* mystrsep(char** sp, const char* sep) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|