-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharacteristicsmodel.h
55 lines (39 loc) · 1.52 KB
/
characteristicsmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef CHARACTERISTICSMODEL_H
#define CHARACTERISTICSMODEL_H
#include <QBluetoothUuid>
#include <QAbstractListModel>
#include <QPointer>
class QLowEnergyService;
class QLowEnergyCharacteristic;
class CharacteriticsModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorOccurred)
public:
explicit CharacteriticsModel(QObject *parent = nullptr);
bool isRunning() const;
QString errorString() const;
Q_INVOKABLE void update(QObject *service);
Q_INVOKABLE void read(const QString &characteristicUuid);
Q_INVOKABLE void write(const QString &characteristicUuid,
const QByteArray &hexValue);
Q_INVOKABLE void enableNotification(const QString &characteristicUuid,
bool enable);
Q_INVOKABLE void enableIndication(const QString &characteristicUuid,
bool enable);
Q_INVOKABLE QObject *service() const;
signals:
void runningChanged(bool running);
void errorOccurred();
private:
void setRunning(bool running);
void updateCharacteristics();
int rowCount(const QModelIndex &parent) const final;
QVariant data(const QModelIndex &index, int role) const final;
QHash<int, QByteArray> roleNames() const final;
bool m_running = false;
QPointer<QLowEnergyService> m_service;
QVector<QBluetoothUuid> m_characteristicUuids;
};
#endif // CHARACTERISTICSMODEL_H