mqttalarmdatathread.h 720 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef MQTTALARMDATATHREAD_H
  2. #define MQTTALARMDATATHREAD_H
  3. #include <QThread>
  4. #include <qmqtt.h>
  5. #include <QDateTime>
  6. #include <QTimer>
  7. class MqttAlarmDataThread : public QThread
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit MqttAlarmDataThread(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. };
  26. #endif // MQTTALARMDATATHREAD_H