mqttsub.h 676 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef MQTTSUB_H
  2. #define MQTTSUB_H
  3. #include <QThread>
  4. #include <qmqtt.h>
  5. #include <QDateTime>
  6. #include <QTimer>
  7. class MqttSub : public QThread
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit MqttSub(QObject *parent = nullptr);
  12. void run();
  13. void mqtt_conf(QString ip,QString port,QString username,QString password);
  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. QString mqtt_ip,mqtt_port,mqtt_username,mqtt_passwd;
  23. QTimer *timer;
  24. QMQTT::Client *m_client;
  25. int minute;
  26. };
  27. #endif // MQTTSUB_H