1 | /* |
2 | * BluezQt - Asynchronous Bluez wrapper library |
3 | * |
4 | * SPDX-FileCopyrightText: 2021 Ivan Podkurkov <podkiva2@gmail.com> |
5 | * |
6 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #include "gattcharacteristicremote.h" |
10 | #include "gattcharacteristicremote_p.h" |
11 | #include "pendingcall.h" |
12 | #include "utils.h" |
13 | |
14 | namespace BluezQt |
15 | { |
16 | |
17 | GattCharacteristicRemote::GattCharacteristicRemote(const QString &path, const QVariantMap &properties, GattServiceRemotePtr service) |
18 | : QObject() |
19 | , d(new GattCharacteristicRemotePrivate(path, properties, service)) |
20 | { |
21 | } |
22 | |
23 | GattCharacteristicRemote::~GattCharacteristicRemote() |
24 | { |
25 | } |
26 | |
27 | GattCharacteristicRemotePtr GattCharacteristicRemote::toSharedPtr() const |
28 | { |
29 | return d->q.toStrongRef(); |
30 | } |
31 | |
32 | QString GattCharacteristicRemote::ubi() const |
33 | { |
34 | return d->m_bluezGattCharacteristic->path(); |
35 | } |
36 | |
37 | QString GattCharacteristicRemote::uuid() const |
38 | { |
39 | return d->m_uuid; |
40 | } |
41 | |
42 | QByteArray GattCharacteristicRemote::value() const |
43 | { |
44 | return d->m_value; |
45 | } |
46 | |
47 | bool GattCharacteristicRemote::isWriteAcquired() const |
48 | { |
49 | return d->m_writeAcquired; |
50 | } |
51 | |
52 | bool GattCharacteristicRemote::isNotifyAcquired() const |
53 | { |
54 | return d->m_notifyAcquired; |
55 | } |
56 | |
57 | bool GattCharacteristicRemote::isNotifying() const |
58 | { |
59 | return d->m_notifying; |
60 | } |
61 | |
62 | QStringList GattCharacteristicRemote::flags() const |
63 | { |
64 | return d->m_flags; |
65 | } |
66 | |
67 | GattServiceRemotePtr GattCharacteristicRemote::service() const |
68 | { |
69 | return d->m_service; |
70 | } |
71 | |
72 | QList<GattDescriptorRemotePtr> GattCharacteristicRemote::descriptors() const |
73 | { |
74 | return d->m_descriptors; |
75 | } |
76 | |
77 | quint16 GattCharacteristicRemote::handle() const |
78 | { |
79 | return d->m_handle; |
80 | } |
81 | |
82 | PendingCall* GattCharacteristicRemote::setHandle(quint16 handle) |
83 | { |
84 | return new PendingCall(d->setDBusProperty(QStringLiteral("Handle" ), value: QVariant::fromValue(value: handle)), PendingCall::ReturnVoid, this); |
85 | } |
86 | |
87 | quint16 GattCharacteristicRemote::MTU() const |
88 | { |
89 | return d->m_MTU; |
90 | } |
91 | |
92 | PendingCall *GattCharacteristicRemote::readValue(const QVariantMap &options) |
93 | { |
94 | return new PendingCall(d->m_bluezGattCharacteristic->ReadValue(options), PendingCall::ReturnByteArray, this); |
95 | } |
96 | |
97 | PendingCall *GattCharacteristicRemote::writeValue(const QByteArray &value, const QVariantMap &options) |
98 | { |
99 | return new PendingCall(d->m_bluezGattCharacteristic->WriteValue(value,options), PendingCall::ReturnVoid, this); |
100 | } |
101 | |
102 | PendingCall *GattCharacteristicRemote::startNotify() |
103 | { |
104 | return new PendingCall(d->m_bluezGattCharacteristic->StartNotify(), PendingCall::ReturnVoid, this); |
105 | } |
106 | |
107 | PendingCall *GattCharacteristicRemote::stopNotify() |
108 | { |
109 | return new PendingCall(d->m_bluezGattCharacteristic->StopNotify(), PendingCall::ReturnVoid, this); |
110 | } |
111 | |
112 | PendingCall *GattCharacteristicRemote::confirm() |
113 | { |
114 | return new PendingCall(d->m_bluezGattCharacteristic->Confirm(), PendingCall::ReturnVoid, this); |
115 | } |
116 | |
117 | } // namespace BluezQt |
118 | |
119 | #include "moc_gattcharacteristicremote.cpp" |
120 | |