| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2021 Ivan Podkurkov <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "gattdescriptorinterface.h" |
| 8 |
#include "inputinterface.h" |
| 9 |
#include "objectmanager.h" |
| 10 |
|
| 11 |
#include <QDBusArgument> |
| 12 |
#include <QDBusConnection> |
| 13 |
#include <QDBusMessage> |
| 14 |
|
| 15 |
// GattServiceObject |
| 16 |
GattDescriptorObject::GattDescriptorObject(const QDBusObjectPath &path, QObject *parent) |
| 17 |
: QObject(parent) |
| 18 |
{ |
| 19 |
QDBusConnection::sessionBus().registerObject(path.path(), this); |
| 20 |
} |
| 21 |
|
| 22 |
// GattServiceInterface |
| 23 |
GattDescriptorInterface::GattDescriptorInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent) |
| 24 |
: QDBusAbstractAdaptor(parent) |
| 25 |
{ |
| 26 |
setPath(path); |
| 27 |
setObjectParent(parent); |
| 28 |
setProperties(properties); |
| 29 |
setName(QStringLiteral("org.bluez.GattDescriptor1")); |
| 30 |
} |
| 31 |
|
| 32 |
QString GattDescriptorInterface::UUID() const |
| 33 |
{ |
| 34 |
return Object::property(QStringLiteral("UUID")).toString(); |
| 35 |
} |
| 36 |
|
| 37 |
QDBusObjectPath GattDescriptorInterface::characteristic() const |
| 38 |
{ |
| 39 |
return Object::property(QStringLiteral("Characteristic")).value<QDBusObjectPath>(); |
| 40 |
} |
| 41 |
|
| 42 |
QByteArray GattDescriptorInterface::value() const |
| 43 |
{ |
| 44 |
return Object::property(QStringLiteral("Value")).value<QByteArray>(); |
| 45 |
} |
| 46 |
|
| 47 |
QStringList GattDescriptorInterface::flags() const |
| 48 |
{ |
| 49 |
return Object::property(QStringLiteral("Flags")).value<QStringList>(); |
| 50 |
} |
| 51 |
|
| 52 |
quint16 GattDescriptorInterface::handle() const |
| 53 |
{ |
| 54 |
return Object::property(QStringLiteral("Handle")).value<quint16>(); |
| 55 |
} |
| 56 |
|
| 57 |
void GattDescriptorInterface::setHandle(const quint16 handle) |
| 58 |
{ |
| 59 |
Object::changeProperty(QStringLiteral("Handle"), QVariant::fromValue(handle)); |
| 60 |
} |
| 61 |
|
| 62 |
QByteArray GattDescriptorInterface::ReadValue(const QVariantMap& options) |
| 63 |
{ |
| 64 |
Q_UNUSED(options) |
| 65 |
QByteArray value = QByteArray("TEST"); |
| 66 |
Object::changeProperty(QStringLiteral("Value"), value); |
| 67 |
return value; |
| 68 |
} |
| 69 |
|
| 70 |
void GattDescriptorInterface::WriteValue(const QByteArray& value, const QVariantMap& options) |
| 71 |
{ |
| 72 |
Q_UNUSED(options) |
| 73 |
Object::changeProperty(QStringLiteral("Value"), value); |
| 74 |
} |
| 75 |
|
| 76 |
#include "moc_gattdescriptorinterface.cpp" |