qt/ledset/pcaprethread.h
2023-09-01 17:25:53 +08:00

41 lines
988 B
C++

#ifndef PCAPRETHREAD_H
#define PCAPRETHREAD_H
#include "waitingdlg.h"
#include "pcap.h"
#include <QThread>
typedef std::function<void(int, const QByteArray)> FuncIntByte;
#define LineLen 16
struct PcapResp {
FuncIntByte callback;
int id;
qint64 timeout;
bool isMulti = false;
bool notCancelled = true;
};
class PcapReThread : public QThread {
Q_OBJECT
public:
explicit PcapReThread(pcap *pcap);
~PcapReThread();
int sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, bool = false, WaitingDlg *waitingDlg = 0);
void addMultiCallback(int id, FuncIntByte callback);
QList<PcapResp*> resps;
std::mutex mtx;
pcap *pcap;
std::atomic<char> status{0};
QByteArray intro{"\x55\x55"};
char fmt{0};
signals:
void onCallback(FuncIntByte callback, int code, const QByteArray data);
void onMsg(const QString &);
void onError(char *);
protected:
void run();
};
#endif // PCAPRETHREAD_H