jzmqttpub.h 741 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef MQTTPUB_H
  2. #define MQTTPUB_H
  3. #include <QThread>
  4. #include <QDateTime>
  5. #include <QJsonArray>
  6. #include <QJsonDocument>
  7. #include <QJsonObject>
  8. #include <QJsonValue>
  9. #include <QJsonParseError>
  10. #include <QVariantMap>
  11. class MqttData{
  12. public:
  13. explicit MqttData(QString t="",QByteArray d=""){
  14. topic = t;
  15. data = d;
  16. }
  17. QString topic;
  18. QByteArray data;
  19. };
  20. class JZMqttPub : public QThread
  21. {
  22. Q_OBJECT
  23. public:
  24. explicit JZMqttPub(QObject *parent = nullptr);
  25. void run();
  26. void stop();
  27. void devMessage(MqttData dev);
  28. signals:
  29. void mqttData(QString mqtt_msg);
  30. void dataListLog(QString msg);
  31. public slots:
  32. private:
  33. bool keep;
  34. QList<MqttData> mqttDataList;
  35. };
  36. #endif // MQTTPUB_H