ytmqttsub.h 613 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef YTMQTTSUB_H
  2. #define YTMQTTSUB_H
  3. #include <QThread>
  4. #include <qmqtt.h>
  5. #include <QDateTime>
  6. #include <QTimer>
  7. class YTMqttSub : public QThread
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit YTMqttSub(QObject *parent = nullptr);
  12. void run();
  13. void mqtt_conf(QString ip, QString port, QString username, QString passwd);
  14. signals:
  15. void mq_log(QString log);
  16. void sendMqttData(QString topic, QByteArray data);
  17. public slots:
  18. void time_out();
  19. void onConnected();
  20. void onReceived(const QMQTT::Message &message);
  21. private:
  22. QTimer *timer;
  23. QMQTT::Client *m_client;
  24. };
  25. #endif // YTMQTTSUB_H