app/headers/buzzerconn.h

59 lines
1.7 KiB
C
Raw Normal View History

#ifndef BUZZERCONN_H
#define BUZZERCONN_H
#include <QObject>
#include <QObject>
#include <QDir>
#include <QUrl>
#include <QtNetwork>
#include <QAuthenticator>
#include <QDesktopServices>
#include <QDateTime>
typedef struct strReturnData{
int status_code;
QString text;
}ReturnData_t;
class BuzzerConn : public QObject
{
Q_OBJECT
public:
explicit BuzzerConn(QObject *parent = nullptr, QUrl ip = QUrl("http://192.168.4.1"));
double offset;
QList<double> latest_offsets;
2018-07-26 14:54:11 +02:00
double latest_button_pressed;
double starttime;
bool connected;
int connection_progress;
QUrl buzz_url;
2018-07-26 14:54:11 +02:00
private:
QNetworkAccessManager *networkManager;
QNetworkAccessManager *reloadNetworkManager;
2018-07-26 14:54:11 +02:00
QDateTime *date;
signals:
public slots:
ReturnData_t senddata(QNetworkAccessManager * NetMan, QUrl serviceUrl, int timeout);
//function to communicate with the buzzer
2018-08-02 12:50:55 +02:00
Q_INVOKABLE QList<double> gettimes(int timeout);
//function to get the times from the buzzer as a list with the normal network manager
2018-07-26 14:54:11 +02:00
Q_INVOKABLE bool connect();
//function to connect to buzzer
Q_INVOKABLE bool calcoffset(QList<double> times);
//function that calculates the average time offset between the buzzer and the device
2018-07-26 14:54:11 +02:00
Q_INVOKABLE bool buzzer_triggered();
//function that checks ih the buzzer has been pushed since the last call of this function
2018-07-26 14:54:11 +02:00
Q_INVOKABLE bool start();
//syncs the buzzer and the base to make a start possible
2018-07-26 14:54:11 +02:00
Q_INVOKABLE double get(QString key);
//can return some things (offset, lastpressed, currtime, connection_progress, connected)
2018-07-26 14:54:11 +02:00
Q_INVOKABLE QString test();
Q_INVOKABLE bool refresh();
//refreshed the connection to the buzzer
};
#endif // BUZZERCONN_H