-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAPRSWriterThread.h
69 lines (53 loc) · 2.04 KB
/
APRSWriterThread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright (C) 2010,2011,2012,2016,2020,2022 by Jonathan Naylor G4KLX
*
* 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 APRSWriterThread_H
#define APRSWriterThread_H
#include "TCPSocket.h"
#include "RingBuffer.h"
#include "Timer.h"
#include "Thread.h"
#include <string>
const unsigned int FRAME_BUFFER_SIZE = 300U;
typedef void (*ReadAPRSFrameCallback)(const std::string&);
class CAPRSWriterThread : public CThread {
public:
CAPRSWriterThread(const std::string& callsign, const std::string& password, const std::string& address, unsigned short port, const std::string& version, bool debug);
virtual ~CAPRSWriterThread();
virtual bool start();
virtual bool isConnected() const;
virtual bool write(const unsigned char* data, unsigned int length);
virtual void entry();
virtual void stop();
void setReadAPRSCallback(ReadAPRSFrameCallback cb);
void clock(unsigned int ms);
private:
std::string m_username;
std::string m_password;
bool m_debug;
CTCPSocket m_socket;
CRingBuffer<unsigned char> m_queue;
bool m_exit;
bool m_connected;
CTimer m_reconnectTimer;
unsigned int m_tries;
ReadAPRSFrameCallback m_aprsReadCallback;
std::string m_version;
bool connect();
void startReconnectionTimer();
};
#endif