LedDisplay/OmobiDisplayApp/omobidisplaybackend.h

48 lines
1.2 KiB
C
Raw Normal View History

2020-10-08 20:06:57 +02:00
#ifndef OMOBIDISPLAYBACKEND_H
#define OMOBIDISPLAYBACKEND_H
#include <QObject>
2020-10-08 22:03:30 +02:00
#include <qbluetoothleuart.h>
2020-10-08 20:06:57 +02:00
class OmobiDisplayBackend : public QObject
{
Q_OBJECT
2020-10-09 00:03:50 +02:00
Q_PROPERTY(QBluetoothLeUart* bleController READ getBleController NOTIFY bleControllerChanged)
2020-10-11 15:50:13 +02:00
Q_PROPERTY(OmobiDisplayAppState state READ getState WRITE setState NOTIFY stateChanged)
2020-10-08 20:06:57 +02:00
public:
explicit OmobiDisplayBackend(QObject *parent = nullptr);
2020-10-11 15:50:13 +02:00
enum OmobiDisplayAppState {
Idle,
Scanning,
ReadyToConnect,
Connecting,
Connected
};
Q_ENUM(OmobiDisplayAppState)
2020-10-08 20:06:57 +02:00
private:
2020-10-11 15:50:13 +02:00
OmobiDisplayAppState state;
2020-10-08 20:06:57 +02:00
QBluetoothLeUart *ble;
2020-10-09 00:03:50 +02:00
public slots:
2020-10-11 15:50:13 +02:00
Q_INVOKABLE void startScanning();
Q_INVOKABLE QBluetoothLeUart* getBleController();
Q_INVOKABLE OmobiDisplayAppState getState();
2020-10-09 00:03:50 +02:00
2020-10-08 20:06:57 +02:00
private slots:
void handleBluetoothStateChange(QBluetoothLeUart::BluetoothLeUartState state);
2020-10-08 22:03:30 +02:00
void handleFoundNewDevice(QBluetoothLeUartDevice* device);
2020-10-08 20:06:57 +02:00
void DataHandler(const QString &s);
2020-10-09 00:03:50 +02:00
void handleBluetoothDeviceConected();
2020-10-08 20:06:57 +02:00
2020-10-11 15:50:13 +02:00
void setState(OmobiDisplayAppState state);
2020-10-08 20:06:57 +02:00
signals:
2020-10-11 15:50:13 +02:00
void stateChanged();
2020-10-09 00:03:50 +02:00
void bleControllerChanged();
2020-10-08 20:06:57 +02:00
};
#endif // OMOBIDISPLAYBACKEND_H