File indexing completed on 2024-04-28 03:52:02

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2022 Pontus Sjögren
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #include "gattdescriptor.h"
0010 #include "gattcharacteristic.h"
0011 #include "gattdescriptor_p.h"
0012 
0013 namespace BluezQt
0014 {
0015 
0016 GattDescriptor *GattDescriptor::createUserDescription(QString const &description, GattCharacteristic *characteristic)
0017 {
0018     return new GattDescriptor(QLatin1String("2901"), {QLatin1String("read")}, description.toUtf8(), characteristic);
0019 }
0020 
0021 GattDescriptor::GattDescriptor(const QString &uuid, GattCharacteristic *parent)
0022     : GattDescriptor(uuid, {}, {}, parent)
0023 {
0024 }
0025 
0026 GattDescriptor::GattDescriptor(const QString &uuid, const QStringList &flags, GattCharacteristic *parent)
0027     : GattDescriptor(uuid, flags, {}, parent)
0028 {
0029 }
0030 
0031 GattDescriptor::GattDescriptor(const QString &uuid, const QStringList &flags, const QByteArray &initialValue, GattCharacteristic *parent)
0032     : QObject(parent)
0033     , d(new GattDescriptorPrivate(uuid, flags, initialValue, parent))
0034 {
0035 }
0036 
0037 GattDescriptor::~GattDescriptor() = default;
0038 
0039 QByteArray GattDescriptor::readValue()
0040 {
0041     return d->m_value;
0042 }
0043 
0044 void GattDescriptor::writeValue(const QByteArray &value)
0045 {
0046     d->m_value = value;
0047 }
0048 
0049 QString GattDescriptor::uuid() const
0050 {
0051     return d->m_uuid;
0052 }
0053 
0054 QDBusObjectPath GattDescriptor::characteristic() const
0055 {
0056     return d->m_characteristic->objectPath();
0057 }
0058 
0059 QStringList GattDescriptor::flags() const
0060 {
0061     return d->m_flags;
0062 }
0063 
0064 QDBusObjectPath GattDescriptor::objectPath() const
0065 {
0066     return d->m_objectPath;
0067 }
0068 
0069 }
0070 
0071 #include "moc_gattdescriptor.cpp"