| 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 |
|
| 19 |
namespace BluezQt |
| 20 |
{ |
| 21 |
|
| 22 |
class GattCharacteristic; |
| 23 |
|
| 24 |
/*! |
| 25 |
* \inmodule BluezQt |
| 26 |
* \class BluezQt::GattDescriptor |
| 27 |
* \inheaderfile BluezQt/GattDescriptor |
| 28 |
* \brief Bluetooth GATT Descriptor. |
| 29 |
* |
| 30 |
* GATT Descriptors contain additional information and attributes of a GATT characteristic. |
| 31 |
* \since 6.0 |
| 32 |
*/ |
| 33 |
class BLUEZQT_EXPORT GattDescriptor : public QObject |
| 34 |
{ |
| 35 |
Q_OBJECT |
| 36 |
|
| 37 |
public: |
| 38 |
/*! |
| 39 |
* Convenience method to create a User Description |
| 40 |
* \a description for the given \a charactersitic. |
| 41 |
* |
| 42 |
* Returns A pointer to the created descriptor. |
| 43 |
*/ |
| 44 |
static GattDescriptor *createUserDescription(const QString &description, GattCharacteristic *characteristic); |
| 45 |
|
| 46 |
/*! |
| 47 |
* Creates a GattDescriptor with the given \a uuid as a child of a \a parent characteristic. |
| 48 |
*/ |
| 49 |
GattDescriptor(const QString &uuid, GattCharacteristic *parent); |
| 50 |
|
| 51 |
/*! |
| 52 |
* Creates a GattDescriptor with the given \a uuid and \a flags as a child of a \a parent characteristic. |
| 53 |
*/ |
| 54 |
GattDescriptor(const QString &uuid, const QStringList &flags, GattCharacteristic *parent); |
| 55 |
|
| 56 |
/*! |
| 57 |
* Creates a GattDescriptor with the given \a uuid, \a flags |
| 58 |
* and \a initialValue as a child of a \a parent characteristic. |
| 59 |
*/ |
| 60 |
GattDescriptor(const QString &uuid, const QStringList &flags, const QByteArray &initialValue, GattCharacteristic *parent); |
| 61 |
|
| 62 |
~GattDescriptor() override; |
| 63 |
|
| 64 |
/*! |
| 65 |
* Reads the current value of the descriptor. |
| 66 |
*/ |
| 67 |
QByteArray readValue(); |
| 68 |
|
| 69 |
/*! |
| 70 |
* Writes the new \a value of the descriptor. |
| 71 |
*/ |
| 72 |
void writeValue(const QByteArray &value); |
| 73 |
|
| 74 |
/*! |
| 75 |
* Returns the UUID of the descriptor. |
| 76 |
*/ |
| 77 |
QString uuid() const; |
| 78 |
|
| 79 |
/*! |
| 80 |
* Return the D-Bus object path of the parent characteristic. |
| 81 |
*/ |
| 82 |
QDBusObjectPath characteristic() const; |
| 83 |
|
| 84 |
/*! |
| 85 |
* Return the flags of the descriptor. |
| 86 |
*/ |
| 87 |
QStringList flags() const; |
| 88 |
|
| 89 |
protected: |
| 90 |
/*! |
| 91 |
*/ |
| 92 |
virtual QDBusObjectPath objectPath() const; |
| 93 |
|
| 94 |
private: |
| 95 |
std::unique_ptr<class GattDescriptorPrivate> const d; |
| 96 |
|
| 97 |
friend class GattManager; |
| 98 |
friend class GattApplicationPrivate; |
| 99 |
}; |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
#endif |