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

source code of bluez-qt/src/gattdescriptorremote.h