SkyPulse UAV V0.1
Loading...
Searching...
No Matches
TCP.h
Go to the documentation of this file.
1#ifndef TCP_H
2#define TCP_H
3
4#include <QThread>
5#include <QObject>
6#include <QTcpSocket>
7#include "MediatorInterface.h"
8
9#define WRITE 0x01
10#define READ 0x00
11
12class TCP : public QObject {
13 Q_OBJECT
14
15public:
16 explicit TCP(QObject *parent = nullptr, MediatorInterface* mediator = nullptr);
18
19 void connectToServer(const QString &host, quint16 port);
20 void disconnectToServer();
21
22private:
23 QTcpSocket *TCPSocket;
24 QThread *TCPThread;
25 MediatorInterface* mediator;
26
27 QString dataCheckOut(const QByteArray &data);
28
29public slots:
30 void sendMessage(const QString &message);
31 void sendMessageQByte(const QByteArray &message);
32 void readMessage();
33 void PWM_Controler(const int &code, const int &value);
34 void controlMessageSender(const uint8_t &action, const uint8_t &data_length, const uint8_t &value);
35
36private slots:
37 void tcpInitial();
38
39 void onConnected();
40 void onDisconnected();
41 void onErrorOccurred();
42
43signals:
44 void sig_connectionSuccessful(); // 判断是否连接成功的信号
45 void sig_disconnectionSuccessful(); // 判断是否成功断开的信号
47};
48
49#endif // TCP_H
Definition MediatorInterface.h:6
Definition TCP.h:86
TCP Server Class.
Definition TCP.h:14
void disconnectToServer()
Definition TCP.cpp:45
void PWM_Controler(const int &code, const int &value)
Definition TCP.cpp:85
void sig_disconnectionSuccessful()
void sendMessage(const QString &message)
Definition TCP.cpp:65
void sig_connectionSuccessful()
void sendMessageQByte(const QByteArray &message)
Definition TCP.cpp:106
void readMessage()
Definition TCP.cpp:74
~TCP()
void sig_connectionError()
TCP(string host, in_port_t port)
Definition TCP.cpp:7
void connectToServer(const QString &host, quint16 port)
Definition TCP.cpp:33
void controlMessageSender(const uint8_t &action, const uint8_t &data_length, const uint8_t &value)
Definition TCP.cpp:96