BluezQt

gattdescriptor.h
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2022 Pontus Sjögren
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#ifndef GATTDESCRIPTOR_H
10#define GATTDESCRIPTOR_H
11
12#include <QDBusObjectPath>
13#include <QObject>
14
15#include "bluezqt_export.h"
16
17#include <memory>
18
19namespace BluezQt
20{
21
22class GattCharacteristic;
23
24/**
25 * Bluetooth GATT Descriptor
26 *
27 * GATT Descriptors contain additional information and attributes of a GATT characteristic.
28
29 * @since 6.0
30 */
31class BLUEZQT_EXPORT GattDescriptor : public QObject
32{
33 Q_OBJECT
34
35public:
36 /**
37 * Convenience method to create a User Description for the given charactersitic.
38 *
39 * @param description The User Description the characteristic should have
40 * @param characteristic The characteristic to assign the descriptor to
41 * @return A pointer to the created descriptor
42 */
43 static GattDescriptor *createUserDescription(const QString &description, GattCharacteristic *characteristic);
44
45 /**
46 * Creates a GattDescriptor with the given UUID.
47 *
48 * @param uuid UUID of the descriptor
49 * @param parent Parent characteristic
50 */
51 GattDescriptor(const QString &uuid, GattCharacteristic *parent);
52
53 /**
54 * Creates a GattDescriptor with the given UUID and flags.
55 *
56 * @param uuid UUID of the descriptor
57 * @param flags The flags of the descriptor
58 * @param parent Parent characteristic
59 */
60 GattDescriptor(const QString &uuid, const QStringList &flags, GattCharacteristic *parent);
61
62 /**
63 * Creates a GattDescriptor with the given UUID, flags and initial value.
64 *
65 * @param uuid UUID of the descriptor
66 * @param flags The flags of the descriptor
67 * @param initialValue The value of the descriptor
68 * @param parent Parent characteristic
69 */
70 GattDescriptor(const QString &uuid, const QStringList &flags, const QByteArray &initialValue, GattCharacteristic *parent);
71
72 /**
73 * Destroys the GattDescriptor.
74 */
75 ~GattDescriptor() override;
76
77 /**
78 * Reads the current value of the descriptor.
79 *
80 * @return A QByteArray representing the current value
81 */
82 QByteArray readValue();
83
84 /**
85 * Writes the value of the descriptor.
86 *
87 * @param value A QByteArray representing the new value
88 */
89 void writeValue(const QByteArray &value);
90
91 /**
92 * Returns the UUID of the descriptor.
93 *
94 * @return A QString representing the UUID
95 */
96 QString uuid() const;
97
98 /**
99 * Return the DBus object path of the parent characteristic.
100 *
101 * @return A QDBusObjectPath representing the DBus object path
102 */
103 QDBusObjectPath characteristic() const;
104
105 /**
106 * Return the flags of the descriptor.
107 *
108 * @return A QStringList representing the flags
109 */
110 QStringList flags() const;
111
112protected:
113 virtual QDBusObjectPath objectPath() const;
114
115private:
116 std::unique_ptr<class GattDescriptorPrivate> const d;
117
118 friend class GattManager;
119 friend class GattApplicationPrivate;
120};
121
122}
123
124#endif
Bluetooth GATT Descriptor.
~GattDescriptor() override
Destroys the GattDescriptor.
Bluetooth GattManager.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.