80 lines
1.1 KiB
C++
80 lines
1.1 KiB
C++
#ifndef DLINK_H
|
|
#define DLINK_H
|
|
|
|
#include <QObject>
|
|
#include "QtSerialPort"
|
|
#include <QHostAddress>
|
|
#include <QUdpSocket>
|
|
#include "QDebug"
|
|
#include "mavlinknode.h"
|
|
|
|
struct Node{
|
|
QUdpSocket * sock;
|
|
QHostAddress addr;
|
|
quint16 port;
|
|
};
|
|
|
|
|
|
#ifdef QtDlink
|
|
#include <dlinkglobal.h>
|
|
class DLINKSHARED_EXPORT DLink : public QObject {
|
|
#else
|
|
class DLink : public QObject
|
|
{
|
|
#endif
|
|
|
|
|
|
Q_OBJECT
|
|
public:
|
|
explicit DLink(QObject *parent = nullptr);
|
|
~DLink();
|
|
|
|
void setupPort(const QString port, qint32 baudrate, QSerialPort::Parity parity);
|
|
bool statesPort();
|
|
void stopPort();
|
|
|
|
void setupClient(const QHostAddress &remote_addr, int remote_port, int local_port);
|
|
|
|
|
|
|
|
int SendMessageTo(uint8_t, uint8_t *msg, uint16_t len);
|
|
|
|
|
|
MavLinkNode *mavlinknode = nullptr;
|
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void readPendingDatagramsSerialPort(void);
|
|
|
|
void readPendingDatagramsClient(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
enum SourceType{
|
|
c_sock = 0,
|
|
s_port = 1
|
|
};
|
|
|
|
|
|
QSerialPort *serialPort = nullptr;
|
|
QUdpSocket *Clientsock = nullptr;
|
|
|
|
QList<Node> clientSockets;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif // DLINK_H
|