#ifndef CORE_H
#define CORE_H

#include <QObject>
#include <qmqtt.h>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDateTime>
#include <QTimer>
#include "logthread.h"
#include "jzmqttpub.h"
#include "jzmqttsub.h"
#include "httpthread.h"
#include "ytmqttpub.h"
#include "ytmqttsub.h"

class Core : public QObject
{
    Q_OBJECT
public:
    explicit Core(QObject *parent = nullptr);
    ~Core();
    void start();
    void shm_init();
    bool shm_load();

signals:

public slots:
    void onConnected();
    void dataLog(QString log);
    void receiveDevData(QString topic,QByteArray data);
    void receiveYtDevData(QString topic,QByteArray data);
    void mqtt_data(QString mqtt_msg);
    void mqtt_data1(QString mqtt_msg);
    void mqtt_data2(QString mqtt_msg);
    void time_out();

private:
    LogThread *logthread;
    JZMqttPub *jzmqttpub;
    JZMqttSub *jzmqttsub;
    HttpThread *httpthread;
    YTMqttPub *ytmqttpub;
    YTMqttSub *ytmqttsub;

    QMQTT::Client *m_client;
    QSqlDatabase db;
    quint16 mqttIdx,mqttIdx1,mqttIdx2;
    QString ip,port,username,password;
    QTimer *timer;
};

#endif // CORE_H
