File indexing completed on 2024-12-08 12:15:33

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 "gattcharacteristicremote.h"
0010 #include "gattcharacteristicremote_p.h"
0011 #include "pendingcall.h"
0012 #include "utils.h"
0013 
0014 namespace BluezQt
0015 {
0016 
0017 GattCharacteristicRemote::GattCharacteristicRemote(const QString &path, const QVariantMap &properties, GattServiceRemotePtr service)
0018     : QObject()
0019     , d(new GattCharacteristicRemotePrivate(path, properties, service))
0020 {
0021 }
0022 
0023 GattCharacteristicRemote::~GattCharacteristicRemote()
0024 {
0025 }
0026 
0027 GattCharacteristicRemotePtr GattCharacteristicRemote::toSharedPtr() const
0028 {
0029     return d->q.toStrongRef();
0030 }
0031 
0032 QString GattCharacteristicRemote::ubi() const
0033 {
0034     return d->m_bluezGattCharacteristic->path();
0035 }
0036 
0037 QString GattCharacteristicRemote::uuid() const
0038 {
0039     return d->m_uuid;
0040 }
0041 
0042 QByteArray GattCharacteristicRemote::value() const
0043 {
0044     return d->m_value;
0045 }
0046 
0047 bool GattCharacteristicRemote::isWriteAcquired() const
0048 {
0049     return d->m_writeAcquired;
0050 }
0051 
0052 bool GattCharacteristicRemote::isNotifyAcquired() const
0053 {
0054     return d->m_notifyAcquired;
0055 }
0056 
0057 bool GattCharacteristicRemote::isNotifying() const
0058 {
0059     return d->m_notifying;
0060 }
0061 
0062 QStringList GattCharacteristicRemote::flags() const
0063 {
0064     return d->m_flags;
0065 }
0066 
0067 GattServiceRemotePtr GattCharacteristicRemote::service() const
0068 {
0069     return d->m_service;
0070 }
0071 
0072 QList<GattDescriptorRemotePtr> GattCharacteristicRemote::descriptors() const
0073 {
0074     return d->m_descriptors;
0075 }
0076 
0077 quint16 GattCharacteristicRemote::handle() const
0078 {
0079     return d->m_handle;
0080 }
0081 
0082 PendingCall* GattCharacteristicRemote::setHandle(quint16 handle)
0083 {
0084     return new PendingCall(d->setDBusProperty(QStringLiteral("Handle"), QVariant::fromValue(handle)), PendingCall::ReturnVoid, this);
0085 }
0086 
0087 quint16 GattCharacteristicRemote::MTU() const
0088 {
0089     return d->m_MTU;
0090 }
0091 
0092 PendingCall *GattCharacteristicRemote::readValue(const QVariantMap &options)
0093 {
0094     return new PendingCall(d->m_bluezGattCharacteristic->ReadValue(options), PendingCall::ReturnByteArray, this);
0095 }
0096 
0097 PendingCall *GattCharacteristicRemote::writeValue(const QByteArray &value, const QVariantMap &options)
0098 {
0099     return new PendingCall(d->m_bluezGattCharacteristic->WriteValue(value,options), PendingCall::ReturnVoid, this);
0100 }
0101 
0102 PendingCall *GattCharacteristicRemote::startNotify()
0103 {
0104     return new PendingCall(d->m_bluezGattCharacteristic->StartNotify(), PendingCall::ReturnVoid, this);
0105 }
0106 
0107 PendingCall *GattCharacteristicRemote::stopNotify()
0108 {
0109     return new PendingCall(d->m_bluezGattCharacteristic->StopNotify(), PendingCall::ReturnVoid, this);
0110 }
0111 
0112 PendingCall *GattCharacteristicRemote::confirm()
0113 {
0114     return new PendingCall(d->m_bluezGattCharacteristic->Confirm(), PendingCall::ReturnVoid, this);
0115 }
0116 
0117 } // namespace BluezQt
0118 
0119 #include "moc_gattcharacteristicremote.cpp"