| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | #ifndef APRSISCLIENT_H
 | 
					
						
							|  |  |  | #define APRSISCLIENT_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 10:22:36 -04:00
										 |  |  | #include <QtGlobal>
 | 
					
						
							| 
									
										
										
										
											2018-09-05 14:57:40 -04:00
										 |  |  | #include <QDateTime>
 | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | #include <QTcpSocket>
 | 
					
						
							|  |  |  | #include <QQueue>
 | 
					
						
							|  |  |  | #include <QPair>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class APRSISClient : public QTcpSocket | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     APRSISClient(QString host, quint16 port, QObject *parent = nullptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static quint32 hashCallsign(QString callsign); | 
					
						
							|  |  |  |     static QString loginFrame(QString callsign); | 
					
						
							|  |  |  |     static QPair<float, float> grid2deg(QString grid); | 
					
						
							|  |  |  |     static QPair<QString, QString> grid2aprs(QString grid); | 
					
						
							| 
									
										
										
										
											2018-10-02 14:32:49 -04:00
										 |  |  |     static QString stripSSID(QString call); | 
					
						
							| 
									
										
										
										
											2018-09-21 14:43:02 -04:00
										 |  |  |     static QString replaceCallsignSuffixWithSSID(QString call, QString base); | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-31 15:22:48 -04:00
										 |  |  |     bool isPasscodeValid(){ return m_localPasscode == QString::number(hashCallsign(m_localCall)); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void enqueueRaw(QString aprsFrame); | 
					
						
							|  |  |  |     void processQueue(bool disconnect=true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public slots: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-11 11:46:12 -04:00
										 |  |  |     void setSkipPercent(float skipPercent){ | 
					
						
							|  |  |  |         m_skipPercent = skipPercent; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-02 00:05:15 -04:00
										 |  |  |     void setServer(QString host, quint16 port){ | 
					
						
							|  |  |  |         if(state() == QTcpSocket::ConnectedState){ | 
					
						
							|  |  |  |             disconnectFromHost(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_host = host; | 
					
						
							|  |  |  |         m_port = port; | 
					
						
							| 
									
										
										
										
											2018-09-21 14:43:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         qDebug() << "APRSISClient Server Change:" << m_host << m_port; | 
					
						
							| 
									
										
										
										
											2018-09-02 00:05:15 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void setPaused(bool paused){ | 
					
						
							|  |  |  |         m_paused = paused; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 23:07:40 -04:00
										 |  |  |     void setLocalStation(QString mycall, QString passcode){ | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  |         m_localCall = mycall; | 
					
						
							| 
									
										
										
										
											2018-09-05 11:33:50 -04:00
										 |  |  |         m_localPasscode = passcode; | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 23:07:40 -04:00
										 |  |  |     void enqueueSpot(QString by_call, QString from_call, QString grid, QString comment); | 
					
						
							|  |  |  |     void enqueueThirdParty(QString by_call, QString from_call, QString text); | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-02 00:05:15 -04:00
										 |  |  |     void sendReports(){ | 
					
						
							|  |  |  |         if(m_paused) return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         processQueue(true); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     QString m_localCall; | 
					
						
							| 
									
										
										
										
											2018-09-05 11:33:50 -04:00
										 |  |  |     QString m_localPasscode; | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 14:57:40 -04:00
										 |  |  |     QQueue<QPair<QString, QDateTime>> m_frameQueue; | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  |     QString m_host; | 
					
						
							|  |  |  |     quint16 m_port; | 
					
						
							|  |  |  |     QTimer m_timer; | 
					
						
							| 
									
										
										
										
											2018-09-02 00:05:15 -04:00
										 |  |  |     bool m_paused; | 
					
						
							| 
									
										
										
										
											2020-04-11 11:46:12 -04:00
										 |  |  |     float m_skipPercent; | 
					
						
							| 
									
										
										
										
											2018-08-27 21:19:38 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // APRSISCLIENT_H
 |