JS8Call-Improved master
Loading...
Searching...
No Matches
APRSISClient.h
Go to the documentation of this file.
1
5#ifndef APRSISCLIENT_H
6#define APRSISCLIENT_H
7
8#include <QDateTime>
9#include <QLoggingCategory>
10#include <QPair>
11#include <QQueue>
12#include <QTcpSocket>
13#include <QTimer>
14#include <QtGlobal>
15
16Q_DECLARE_LOGGING_CATEGORY(aprsisclient_js8)
17
18
21class APRSISClient : public QTcpSocket {
22 Q_OBJECT
23
24 public:
31 APRSISClient(QString host, quint16 port, QObject *parent = nullptr);
32
38 static quint32 hashCallsign(QString callsign);
45 static QString loginFrame(QString callsign, QString filter = QString());
46 static QPair<float, float> grid2deg(QString grid);
47 static QPair<QString, QString> grid2aprs(QString grid);
48 static QString stripSSID(QString call);
49 static QString replaceCallsignSuffixWithSSID(QString call, QString base);
50
51 bool isPasscodeValid() {
52 return m_localPasscode == QString::number(hashCallsign(m_localCall));
53 }
54
55 void enqueueRaw(QString aprsFrame);
56 void processQueue(bool disconnect = true);
57
58 public slots:
63 void setIncomingRelayEnabled(bool enabled);
64
65 void setSkipPercent(float skipPercent) { m_skipPercent = skipPercent; }
66
67 void setServer(QString host, quint16 port) {
68 if (state() == QTcpSocket::ConnectedState) {
69 disconnectFromHost();
70 }
71
72 m_host = host;
73 m_port = port;
74
75 qCDebug(aprsisclient_js8)
76 << "APRSISClient Server Change:" << m_host << m_port;
77 }
78
79 void setPaused(bool paused) { m_paused = paused; }
80
81 void setLocalStation(QString mycall, QString passcode) {
82 m_localCall = mycall;
83 m_localPasscode = passcode;
84 }
85
86 void enqueueSpot(QString by_call, QString from_call, QString grid,
87 QString comment);
88 void enqueueThirdParty(QString by_call, QString from_call, QString text);
95 void enqueueMessageAck(QString from_call, QString to_call,
96 QString messageId);
97
98 void sendReports() {
99 if (m_paused)
100 return;
101
102 processQueue(!m_incomingRelayEnabled);
103 }
104
105 signals:
113 void messageReceived(QString from, QString to, QString message,
114 QString messageId);
115
116 private slots:
117 void onSocketConnected();
118 void onSocketReadyRead();
119 void onSocketDisconnected();
120 void onSocketError(QAbstractSocket::SocketError socketError);
121
122 private:
123 QString m_localCall;
124 QString m_localPasscode;
125
126 QQueue<QPair<QString, QDateTime>> m_frameQueue;
127 QString m_host;
128 quint16 m_port;
129 QTimer m_timer;
130 bool m_paused;
131 bool m_incomingRelayEnabled;
132 bool m_isLoggedIn;
133 float m_skipPercent;
134};
135
136#endif // APRSISCLIENT_H
void enqueueSpot(QString by_call, QString from_call, QString grid, QString comment)
Enqueue a spot frame for APRS-IS.
Definition APRSISClient.cpp:348
static QString stripSSID(QString call)
Strip SSID from callsign.
Definition APRSISClient.cpp:283
APRSISClient(QString host, quint16 port, QObject *parent=nullptr)
Construct a new APRSISClient object.
Definition APRSISClient.cpp:51
void enqueueThirdParty(QString by_call, QString from_call, QString text)
Enqueue a third-party message frame for APRS-IS.
Definition APRSISClient.cpp:371
static QString replaceCallsignSuffixWithSSID(QString call, QString base)
Replace callsign suffix with SSID.
Definition APRSISClient.cpp:294
void messageReceived(QString from, QString to, QString message, QString messageId)
Emitted when a parsed APRS-IS message is received.
void enqueueMessageAck(QString from_call, QString to_call, QString messageId)
Enqueue a standard APRS message ACK frame.
Definition APRSISClient.cpp:392
static QString loginFrame(QString callsign, QString filter=QString())
Build an APRS-IS login frame.
Definition APRSISClient.cpp:101
void processQueue(bool disconnect=true)
Process the APRS-IS frame queue.
Definition APRSISClient.cpp:425
static QPair< float, float > grid2deg(QString grid)
Convert grid locator to degrees.
Definition APRSISClient.cpp:161
static QPair< QString, QString > grid2aprs(QString grid)
Convert grid locator to APRS format.
Definition APRSISClient.cpp:222
void setIncomingRelayEnabled(bool enabled)
Enable or disable persistent inbound message relay.
Definition APRSISClient.cpp:319
static quint32 hashCallsign(QString callsign)
Compute APRS-IS passcode for a callsign.
Definition APRSISClient.cpp:76
void enqueueRaw(QString aprsFrame)
Enqueue a raw APRS frame for APRS-IS.
Definition APRSISClient.cpp:416