File indexing completed on 2024-10-13 03:35:34
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Ivan Podkurkov <podkiva2@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "gattdescriptorinterface.h" 0008 #include "inputinterface.h" 0009 #include "objectmanager.h" 0010 0011 #include <QDBusArgument> 0012 #include <QDBusConnection> 0013 #include <QDBusMessage> 0014 0015 // GattServiceObject 0016 GattDescriptorObject::GattDescriptorObject(const QDBusObjectPath &path, QObject *parent) 0017 : QObject(parent) 0018 { 0019 QDBusConnection::sessionBus().registerObject(path.path(), this); 0020 } 0021 0022 // GattServiceInterface 0023 GattDescriptorInterface::GattDescriptorInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent) 0024 : QDBusAbstractAdaptor(parent) 0025 { 0026 setPath(path); 0027 setObjectParent(parent); 0028 setProperties(properties); 0029 setName(QStringLiteral("org.bluez.GattDescriptor1")); 0030 } 0031 0032 QString GattDescriptorInterface::UUID() const 0033 { 0034 return Object::property(QStringLiteral("UUID")).toString(); 0035 } 0036 0037 QDBusObjectPath GattDescriptorInterface::characteristic() const 0038 { 0039 return Object::property(QStringLiteral("Characteristic")).value<QDBusObjectPath>(); 0040 } 0041 0042 QByteArray GattDescriptorInterface::value() const 0043 { 0044 return Object::property(QStringLiteral("Value")).value<QByteArray>(); 0045 } 0046 0047 QStringList GattDescriptorInterface::flags() const 0048 { 0049 return Object::property(QStringLiteral("Flags")).value<QStringList>(); 0050 } 0051 0052 quint16 GattDescriptorInterface::handle() const 0053 { 0054 return Object::property(QStringLiteral("Handle")).value<quint16>(); 0055 } 0056 0057 void GattDescriptorInterface::setHandle(const quint16 handle) 0058 { 0059 Object::changeProperty(QStringLiteral("Handle"), QVariant::fromValue(handle)); 0060 } 0061 0062 QByteArray GattDescriptorInterface::ReadValue(const QVariantMap& options) 0063 { 0064 Q_UNUSED(options) 0065 QByteArray value = QByteArray("TEST"); 0066 Object::changeProperty(QStringLiteral("Value"), value); 0067 return value; 0068 } 0069 0070 void GattDescriptorInterface::WriteValue(const QByteArray& value, const QVariantMap& options) 0071 { 0072 Q_UNUSED(options) 0073 Object::changeProperty(QStringLiteral("Value"), value); 0074 } 0075 0076 #include "moc_gattdescriptorinterface.cpp"