#ifndef ENVIRONMENTCORE_H
#define ENVIRONMENTCORE_H

#include <QObject>
#include <qmqtt.h>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDateTime>
#include <QTimer>
#include "logthread.h"
#include "mqttpub.h"
#include "mqttsub.h"

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

signals:

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

private:
    LogThread *logthread;
    MqttPub *mqttpub;
    MqttSub *mqttsub;

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

#endif // ENVIRONMENTCORE_H
