| 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 |
#include "gattdescriptor.h" |
| 10 |
#include "gattcharacteristic.h" |
| 11 |
#include "gattdescriptor_p.h" |
| 12 |
|
| 13 |
namespace BluezQt |
| 14 |
{ |
| 15 |
|
| 16 |
GattDescriptor *GattDescriptor::createUserDescription(QString const &description, GattCharacteristic *characteristic) |
| 17 |
{ |
| 18 |
return new GattDescriptor(QLatin1String("2901"), {QLatin1String("read")}, description.toUtf8(), characteristic); |
| 19 |
} |
| 20 |
|
| 21 |
GattDescriptor::GattDescriptor(const QString &uuid, GattCharacteristic *parent) |
| 22 |
: GattDescriptor(uuid, {}, {}, parent) |
| 23 |
{ |
| 24 |
} |
| 25 |
|
| 26 |
GattDescriptor::GattDescriptor(const QString &uuid, const QStringList &flags, GattCharacteristic *parent) |
| 27 |
: GattDescriptor(uuid, flags, {}, parent) |
| 28 |
{ |
| 29 |
} |
| 30 |
|
| 31 |
GattDescriptor::GattDescriptor(const QString &uuid, const QStringList &flags, const QByteArray &initialValue, GattCharacteristic *parent) |
| 32 |
: QObject(parent) |
| 33 |
, d(new GattDescriptorPrivate(uuid, flags, initialValue, parent)) |
| 34 |
{ |
| 35 |
} |
| 36 |
|
| 37 |
GattDescriptor::~GattDescriptor() = default; |
| 38 |
|
| 39 |
QByteArray GattDescriptor::readValue() |
| 40 |
{ |
| 41 |
return d->m_value; |
| 42 |
} |
| 43 |
|
| 44 |
void GattDescriptor::writeValue(const QByteArray &value) |
| 45 |
{ |
| 46 |
d->m_value = value; |
| 47 |
} |
| 48 |
|
| 49 |
QString GattDescriptor::uuid() const |
| 50 |
{ |
| 51 |
return d->m_uuid; |
| 52 |
} |
| 53 |
|
| 54 |
QDBusObjectPath GattDescriptor::characteristic() const |
| 55 |
{ |
| 56 |
return d->m_characteristic->objectPath(); |
| 57 |
} |
| 58 |
|
| 59 |
QStringList GattDescriptor::flags() const |
| 60 |
{ |
| 61 |
return d->m_flags; |
| 62 |
} |
| 63 |
|
| 64 |
QDBusObjectPath GattDescriptor::objectPath() const |
| 65 |
{ |
| 66 |
return d->m_objectPath; |
| 67 |
} |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
#include "moc_gattdescriptor.cpp" |