LedDisplay/OmobiDisplayApp/omobidisplaybackend.h

56 lines
1.5 KiB
C++

#ifndef OMOBIDISPLAYBACKEND_H
#define OMOBIDISPLAYBACKEND_H
#include <QObject>
#include <qbluetoothleuart.h>
#include <omobidisplaytextmodel.h>
class OmobiDisplayBackend : public QObject
{
Q_OBJECT
Q_PROPERTY(QBluetoothLeUart* bleController READ getBleController NOTIFY bleControllerChanged)
Q_PROPERTY(OmobiDisplayAppState state READ getState WRITE setState NOTIFY stateChanged)
Q_PROPERTY(OmobiDisplayTextModel* displayTextModel READ getDisplayTextModel NOTIFY displayTextModelChanged)
public:
explicit OmobiDisplayBackend(QObject *parent = nullptr);
enum OmobiDisplayAppState {
Idle,
Scanning,
ReadyToConnect,
Connecting,
Connected
};
Q_ENUM(OmobiDisplayAppState)
private:
OmobiDisplayAppState state;
QBluetoothLeUart *ble;
OmobiDisplayTextModel* displayTextModel;
public slots:
Q_INVOKABLE void startScanning();
Q_INVOKABLE QBluetoothLeUart* getBleController();
Q_INVOKABLE OmobiDisplayAppState getState();
Q_INVOKABLE OmobiDisplayTextModel* getDisplayTextModel();
private slots:
void handleBluetoothStateChange(QBluetoothLeUart::BluetoothLeUartState state);
void handleFoundNewDevice(QBluetoothLeUartDevice* device);
void DataHandler(const QString &s);
void handleBluetoothDeviceConected();
void handleDisplayTextModelDataChanged();
void setState(OmobiDisplayAppState state);
signals:
void stateChanged();
void bleControllerChanged();
void displayTextModelChanged();
};
#endif // OMOBIDISPLAYBACKEND_H