#ifndef YTMQTTSUB_H
#define YTMQTTSUB_H

#include <QThread>
#include <qmqtt.h>
#include <QDateTime>
#include <QTimer>

class YTMqttSub : public QThread
{
    Q_OBJECT
public:
    explicit YTMqttSub(QObject *parent = nullptr);
    void run();
    void mqtt_conf(QString ip, QString port, QString username, QString passwd);

signals:
    void mq_log(QString log);
    void sendMqttData(QString topic, QByteArray data);

public slots:
    void time_out();
    void onConnected();
    void onReceived(const QMQTT::Message &message);

private:
    QTimer *timer;
    QMQTT::Client *m_client;
};

#endif // YTMQTTSUB_H
