1 | /* |
2 | * BluezQt - Asynchronous Bluez wrapper library |
3 | * |
4 | * SPDX-FileCopyrightText: 2021 Ivan Podkurkov <podkiva2@gmail.com> |
5 | * |
6 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #ifndef BLUEZQT_GATTDESCRIPTORREMOTE_H |
10 | #define BLUEZQT_GATTDESCRIPTORREMOTE_H |
11 | |
12 | #include <QObject> |
13 | #include <QMap> |
14 | |
15 | #include "types.h" |
16 | #include "bluezqt_export.h" |
17 | |
18 | namespace BluezQt |
19 | { |
20 | |
21 | class GattCharacteristicRemote; |
22 | class PendingCall; |
23 | |
24 | /*! |
25 | * \inmodule BluezQt |
26 | * \class BluezQt::GattDescriptorRemote |
27 | * \inheaderfile BluezQt/GattDescriptorRemote |
28 | * \brief Bluetooth LE GATT descriptor. |
29 | * |
30 | * This class represents a Bluetooth LE GATT descriptor for the clients. |
31 | */ |
32 | class BLUEZQT_EXPORT GattDescriptorRemote : public QObject |
33 | { |
34 | Q_OBJECT |
35 | |
36 | /*! \property BluezQt::GattDescriptorRemote::ubi */ |
37 | Q_PROPERTY(QString ubi READ ubi CONSTANT) |
38 | /*! \property BluezQt::GattDescriptorRemote::uuid */ |
39 | Q_PROPERTY(QString uuid READ uuid NOTIFY uuidChanged) |
40 | /*! \property BluezQt::GattDescriptorRemote::value */ |
41 | Q_PROPERTY(QByteArray value READ value NOTIFY valueChanged) |
42 | /*! \property BluezQt::GattDescriptorRemote::flags */ |
43 | Q_PROPERTY(QStringList flags READ flags NOTIFY flagsChanged) |
44 | /*! \property BluezQt::GattDescriptorRemote::handle */ |
45 | Q_PROPERTY(quint16 handle READ handle NOTIFY handleChanged) |
46 | /*! \property BluezQt::GattDescriptorRemote::characteristic */ |
47 | Q_PROPERTY(GattCharacteristicRemotePtr characteristic READ characteristic CONSTANT) |
48 | |
49 | public: |
50 | ~GattDescriptorRemote() override; |
51 | |
52 | /*! |
53 | * Returns a shared pointer from this. |
54 | */ |
55 | GattDescriptorRemotePtr toSharedPtr() const; |
56 | |
57 | /*! |
58 | * Returns the UBI of the GATT descriptor. |
59 | * |
60 | * Example UBI: "/org/bluez/hci0/dev_40_79_6A_0C_39_75" |
61 | */ |
62 | QString ubi() const; |
63 | |
64 | /*! |
65 | * Returns the uuid of the descriptor. |
66 | */ |
67 | QString uuid() const; |
68 | |
69 | /*! |
70 | * Returns the value of the descriptor. |
71 | */ |
72 | QByteArray value() const; |
73 | |
74 | /*! |
75 | * Returns flags the descriptor. |
76 | */ |
77 | QStringList flags() const; |
78 | |
79 | /*! |
80 | * Returns descriptor handle. |
81 | */ |
82 | quint16 handle() const; |
83 | |
84 | /*! |
85 | * Sets the descriptor \a handle. |
86 | * |
87 | * Returns void pending call. |
88 | */ |
89 | PendingCall *setHandle(quint16 handle); |
90 | |
91 | /*! |
92 | * Returns the characteristic that owns that descriptor. |
93 | */ |
94 | GattCharacteristicRemotePtr characteristic() const; |
95 | |
96 | public Q_SLOTS: |
97 | /*! |
98 | * Read the value of the GATT descriptor. |
99 | * |
100 | * Issues a request to read the value of the descriptor and |
101 | * returns the value if the operation was successful. |
102 | * |
103 | * Possible errors: |
104 | * |
105 | * \list |
106 | * \li PendingCall::NotReady |
107 | * \li PendingCall::Failed |
108 | * \li PendingCall::InProgress |
109 | * \li PendingCall::AlreadyConnected |
110 | * \endlist |
111 | * |
112 | * Returns QByteArray pending call. |
113 | */ |
114 | PendingCall *readValue(const QVariantMap &options); |
115 | |
116 | /*! |
117 | * Write the value of the GATT descriptor. |
118 | * |
119 | * Issues a request to write the value of the descriptor. |
120 | * |
121 | * Possible errors: |
122 | * |
123 | * \list |
124 | * \li PendingCall::NotReady |
125 | * \li PendingCall::Failed |
126 | * \li PendingCall::InProgress |
127 | * \li PendingCall::AlreadyConnected |
128 | * \endlist |
129 | * |
130 | * Returns void pending call. |
131 | */ |
132 | PendingCall *writeValue(const QByteArray &value, const QVariantMap &options); |
133 | |
134 | Q_SIGNALS: |
135 | /*! |
136 | * Indicates that at least one of the descriptors's properties has changed. |
137 | */ |
138 | void descriptorChanged(GattDescriptorRemotePtr descriptor); |
139 | |
140 | /*! |
141 | * Indicates that descriptor's \a uuid has changed. |
142 | */ |
143 | void uuidChanged(const QString &uuid); |
144 | |
145 | /*! |
146 | * Indicates that descriptor's \a value has changed. |
147 | */ |
148 | void valueChanged(const QByteArray value); |
149 | |
150 | /*! |
151 | * Indicates that descriptor's \a flags have changed. |
152 | */ |
153 | void flagsChanged(QStringList flags); |
154 | |
155 | /*! |
156 | * Indicates that descriptor's \a handle has changed. |
157 | */ |
158 | void handleChanged(quint16 handle); |
159 | |
160 | private: |
161 | BLUEZQT_NO_EXPORT explicit GattDescriptorRemote(const QString &path, const QVariantMap &properties, GattCharacteristicRemotePtr characteristic); |
162 | |
163 | const std::unique_ptr<class GattDescriptorRemotePrivate> d; |
164 | |
165 | friend class DevicePrivate; |
166 | friend class GattServiceRemotePrivate; |
167 | friend class GattCharacteristicRemotePrivate; |
168 | friend class GattDescriptorRemotePrivate; |
169 | friend class ManagerPrivate; |
170 | friend class Adapter; |
171 | }; |
172 | |
173 | } // namespace BluezQt |
174 | |
175 | #endif // BLUEZQT_GATTDESCRIPTORREMOTE_H |
176 | |