Debian Codegraph @

autotests/fakebluez/gattcharacteristicinterface.cpp

raw
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 "gattcharacteristicinterface.h"
8 #include "inputinterface.h"
9 #include "objectmanager.h"
10
11 #include <QDBusArgument>
12 #include <QDBusConnection>
13 #include <QDBusMessage>
14
15 // GattServiceObject
16 GattCharacteristicObject::GattCharacteristicObject(const QDBusObjectPath &path, QObject *parent)
17 : QObject(parent)
18 {
19 QDBusConnection::sessionBus().registerObject(path.path(), this);
20 }
21
22 // GattServiceInterface
23 GattCharacteristicInterface::GattCharacteristicInterface(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.GattCharacteristic1"));
30 }
31
32 QString GattCharacteristicInterface::UUID() const
33 {
34 return Object::property(QStringLiteral("UUID")).toString();
35 }
36
37 QDBusObjectPath GattCharacteristicInterface::service() const
38 {
39 return Object::property(QStringLiteral("Service")).value<QDBusObjectPath>();
40 }
41
42 QByteArray GattCharacteristicInterface::value() const
43 {
44 return Object::property(QStringLiteral("Value")).value<QByteArray>();
45 }
46
47 bool GattCharacteristicInterface::notifying() const
48 {
49 return Object::property(QStringLiteral("Notifying")).toBool();
50 }
51
52 QStringList GattCharacteristicInterface::flags() const
53 {
54 return Object::property(QStringLiteral("Flags")).value<QStringList>();
55 }
56
57 quint16 GattCharacteristicInterface::handle() const
58 {
59 return Object::property(QStringLiteral("Handle")).value<quint16>();
60 }
61
62 void GattCharacteristicInterface::setHandle(const quint16 handle)
63 {
64 Object::changeProperty(QStringLiteral("Handle"), QVariant::fromValue(handle));
65 }
66
67 quint16 GattCharacteristicInterface::MTU() const
68 {
69 return Object::property(QStringLiteral("MTU")).value<quint16>();
70 }
71
72 QByteArray GattCharacteristicInterface::ReadValue(const QVariantMap& options)
73 {
74 Q_UNUSED(options)
75 QByteArray value = QByteArray("TEST");
76 Object::changeProperty(QStringLiteral("Value"), value);
77 return value;
78 }
79
80 void GattCharacteristicInterface::WriteValue(const QByteArray& value, const QVariantMap& options)
81 {
82 Q_UNUSED(options)
83 Object::changeProperty(QStringLiteral("Value"), value);
84 }
85
86 void GattCharacteristicInterface::StartNotify()
87 {
88 Object::changeProperty(QStringLiteral("Notifying"), true);
89 }
90
91 void GattCharacteristicInterface::StopNotify()
92 {
93 Object::changeProperty(QStringLiteral("Notifying"), false);
94 }
95
96 #include "moc_gattcharacteristicinterface.cpp"