2020-03-13 17:37:48 +08:00
|
|
|
#ifndef DLINK_H
|
|
|
|
|
#define DLINK_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include "QtSerialPort"
|
|
|
|
|
#include <QHostAddress>
|
|
|
|
|
#include <QUdpSocket>
|
|
|
|
|
#include "QDebug"
|
|
|
|
|
#include "mavlinknode.h"
|
|
|
|
|
|
2020-04-09 20:19:56 +08:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//class DLinkPrivate;
|
|
|
|
|
|
2020-03-13 17:37:48 +08:00
|
|
|
#ifdef QtDlink
|
|
|
|
|
#include <dlinkglobal.h>
|
|
|
|
|
class DLINKSHARED_EXPORT DLink : public QObject {
|
|
|
|
|
#else
|
|
|
|
|
class DLink : public QObject
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
Q_OBJECT
|
2020-04-09 20:19:56 +08:00
|
|
|
//Q_DECLARE_PRIVATE(DLink)
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
|
|
|
struct Node{
|
|
|
|
|
QUdpSocket * sock;
|
|
|
|
|
QHostAddress addr;
|
|
|
|
|
quint16 port;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit DLink(QObject *parent = nullptr);
|
|
|
|
|
~DLink();
|
|
|
|
|
|
2020-06-15 18:24:22 +08:00
|
|
|
bool setupPort(const QString port, qint32 baudrate, QSerialPort::Parity parity);
|
2020-03-13 17:37:48 +08:00
|
|
|
bool statesPort();
|
|
|
|
|
void stopPort();
|
|
|
|
|
|
2020-06-15 18:24:22 +08:00
|
|
|
bool setupClient(const QHostAddress &remote_addr, int remote_port, int local_port);
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
|
|
|
MavLinkNode *mavlinknode = nullptr;
|
|
|
|
|
|
2020-05-19 19:02:32 +08:00
|
|
|
signals:
|
2020-03-13 17:37:48 +08:00
|
|
|
|
2020-06-15 18:24:22 +08:00
|
|
|
void PortConnected(QVariant m_state,
|
|
|
|
|
QVariant m_usrName,QVariant m_Type,
|
|
|
|
|
QVariant m_Param1,QVariant m_Param2,
|
|
|
|
|
QVariant m_Param3,QVariant m_Param4,
|
|
|
|
|
QVariant m_Param5);
|
2020-03-13 17:37:48 +08:00
|
|
|
|
2020-05-19 19:02:32 +08:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
void connectSignal(QVariant m_state,
|
|
|
|
|
QVariant m_usrName,QVariant m_Type,
|
|
|
|
|
QVariant m_Param1,QVariant m_Param2,
|
|
|
|
|
QVariant m_Param3,QVariant m_Param4,
|
|
|
|
|
QVariant m_Param5);
|
|
|
|
|
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
|
|
|
void readPendingDatagramsSerialPort(void);
|
|
|
|
|
|
|
|
|
|
void readPendingDatagramsClient(void);
|
|
|
|
|
|
2020-03-18 00:17:40 +08:00
|
|
|
int SendMessageTo(quint8 ch, quint8 *msg, quint16 len);
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
enum SourceType{
|
|
|
|
|
c_sock = 0,
|
|
|
|
|
s_port = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSerialPort *serialPort = nullptr;
|
|
|
|
|
QUdpSocket *Clientsock = nullptr;
|
|
|
|
|
|
|
|
|
|
QList<Node> clientSockets;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-10 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-09 20:19:56 +08:00
|
|
|
QT_END_NAMESPACE
|
2020-03-13 17:37:48 +08:00
|
|
|
|
2020-04-10 15:46:03 +08:00
|
|
|
|
|
|
|
|
|
2020-03-13 17:37:48 +08:00
|
|
|
#endif // DLINK_H
|