#ifndef BASECONN_H #define BASECONN_H #include #include #include #include #include #include class BaseConn : public QObject { Q_OBJECT Q_PROPERTY(QString ipAdress WRITE setIP READ getIP) Q_PROPERTY(QString state READ getState NOTIFY stateChanged) Q_PROPERTY(int progress READ getProgress NOTIFY progressChanged) public: explicit BaseConn(QObject *parent = nullptr); // values for the socket connection int connection_progress; QString ip; qint16 port = 3563; int errors; int errors_until_disconnect = 4; // the current state QString state; // can be: // - 'disconnected' // - 'connecting' // - 'connected' QString latestReadReply; private: QDateTime *date; //to get the current time QTcpSocket *socket; //socket for communication with the extention signals: void stateChanged(); //is emitted, when the connection state changes void progressChanged(); //is emmited during the connection process when the progress changes void gotReply(); public slots: Q_INVOKABLE bool connectToHost(); //function to connect to the base station Q_INVOKABLE QString sendCommand(QString command); // functions for the qml adapter QString getIP() const; void setIP(const QString &ipAdress); QString getState() const; void setState(QString newState); int getProgress() const; private slots: void readyRead(); }; #endif // BASECONN_H