#ifndef MQTTSUB_H
#define MQTTSUB_H

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

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

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:
    QString mqtt_ip,mqtt_port,mqtt_username,mqtt_passwd;
    QTimer *timer;

    QMQTT::Client *m_client;

};

#endif // MQTTSUB_H
