12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef MQTTTHREAD_H
- #define MQTTTHREAD_H
- #include <QThread>
- #include <qmqtt.h>
- #include <QTimer>
- #include <QJsonDocument>
- #include <QJsonArray>
- #include <QJsonObject>
- #include <QJsonValue>
- #include <QJsonParseError>
- class MqttInfo{
- public:
- explicit MqttInfo(QString t="",QByteArray d=""){
- topic = t;
- data = d;
- }
- QString topic;
- QByteArray data;
- };
- class MqttThread : public QThread
- {
- Q_OBJECT
- public:
- explicit MqttThread(QObject *parent = nullptr);
- ~MqttThread();
- void run();
- signals:
- void mqttLog(QString log);
- void sendDevData(QString data);
- public slots:
- void time_out();
- void onConnected();
- void onReceived(const QMQTT::Message &message);
- private:
- QTimer *timer;
- QMQTT::Client *m_client;
- bool keep;
- QList<MqttInfo>mqttDataList;
- };
- #endif // MQTTTHREAD_H
|