Files
gcs-nf/dlink/dlink.h
T

91 lines
1.8 KiB
C++
Raw Normal View History

#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;
#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)
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);
bool statesPort();
void stopPort();
2020-06-15 18:24:22 +08:00
bool setupClient(const QHostAddress &remote_addr, int remote_port, int local_port);
MavLinkNode *mavlinknode = nullptr;
2020-05-19 19:02:32 +08:00
signals:
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-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);
void readPendingDatagramsSerialPort(void);
void readPendingDatagramsClient(void);
int SendMessageTo(quint8 ch, quint8 *msg, quint16 len);
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-04-10 15:46:03 +08:00
#endif // DLINK_H