File indexing completed on 2024-04-28 15:17:52

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2021 Ivan Podkurkov <podkiva2@gmail.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #include "gattdescriptorremote.h"
0010 #include "gattdescriptorremote_p.h"
0011 #include "pendingcall.h"
0012 #include "utils.h"
0013 
0014 namespace BluezQt {
0015 
0016 GattDescriptorRemote::GattDescriptorRemote(const QString &path, const QVariantMap &properties, GattCharacteristicRemotePtr characteristic)
0017     : QObject()
0018     , d(new GattDescriptorRemotePrivate(path, properties, characteristic))
0019 {
0020 }
0021 
0022 GattDescriptorRemote::~GattDescriptorRemote()
0023 {
0024 }
0025 
0026 GattDescriptorRemotePtr GattDescriptorRemote::toSharedPtr() const
0027 {
0028     return d->q.toStrongRef();
0029 }
0030 
0031 QString GattDescriptorRemote::ubi() const
0032 {
0033     return d->m_bluezGattDescriptor->path();
0034 }
0035 
0036 QString GattDescriptorRemote::uuid() const
0037 {
0038     return d->m_uuid;
0039 }
0040 
0041 QByteArray GattDescriptorRemote::value() const
0042 {
0043     return d->m_value;
0044 }
0045 
0046 QStringList GattDescriptorRemote::flags() const
0047 {
0048     return d->m_flags;
0049 }
0050 
0051 quint16 GattDescriptorRemote::handle() const
0052 {
0053     return d->m_handle;
0054 }
0055 
0056 PendingCall* GattDescriptorRemote::setHandle(quint16 handle)
0057 {
0058     return new PendingCall(d->setDBusProperty(QStringLiteral("Handle"), QVariant::fromValue(handle)), PendingCall::ReturnVoid, this);
0059 }
0060 
0061 GattCharacteristicRemotePtr GattDescriptorRemote::characteristic() const
0062 {
0063     return d->m_characteristic;
0064 }
0065 
0066 PendingCall *GattDescriptorRemote::readValue(const QVariantMap &options)
0067 {
0068     return new PendingCall(d->m_bluezGattDescriptor->ReadValue(options), PendingCall::ReturnByteArray, this);
0069 }
0070 
0071 PendingCall *GattDescriptorRemote::writeValue(const QByteArray &value, const QVariantMap &options)
0072 {
0073     return new PendingCall(d->m_bluezGattDescriptor->WriteValue(value,options), PendingCall::ReturnVoid, this);
0074 }
0075 
0076 }  // namespace BluezQt
0077 
0078 #include "moc_gattdescriptorremote.cpp"