Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlowenergydescriptor.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 BlackBerry Limited. All rights reserved.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include <QtBluetooth/QLowEnergyService>
8
10
12
13
40
49
57 d_ptr(other.d_ptr)
58{
59 if (other.data) {
61 data->charHandle = other.data->charHandle;
62 data->descHandle = other.data->descHandle;
63 }
64}
65
70QLowEnergyDescriptor::QLowEnergyDescriptor(QSharedPointer<QLowEnergyServicePrivate> p,
71 QLowEnergyHandle charHandle,
72 QLowEnergyHandle descHandle):
73 d_ptr(p)
74{
76 data->charHandle = charHandle;
77 data->descHandle = descHandle;
78
79}
80
88
94{
95 d_ptr = other.d_ptr;
96
97 if (!other.data) {
98 if (data) {
99 delete data;
100 data = nullptr;
101 }
102 } else {
103 if (!data)
105
106 data->charHandle = other.data->charHandle;
107 data->descHandle = other.data->descHandle;
108 }
109
110 return *this;
111}
112
142bool QLowEnergyDescriptor::equals(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)
143{
144 if (a.d_ptr != b.d_ptr)
145 return false;
146
147 if ((a.data && !b.data) || (!a.data && b.data))
148 return false;
149
150 if (!a.data)
151 return true;
152
153 if (a.data->charHandle != b.data->charHandle || a.data->descHandle != b.data->descHandle) {
154 return false;
155 }
156
157 return true;
158}
159
174{
175 if (d_ptr.isNull() || !data)
176 return false;
177
179 return false;
180
181 return true;
182}
183
189{
190 if (d_ptr.isNull() || !data
191 || !d_ptr->characteristicList.contains(data->charHandle)
192 || !d_ptr->characteristicList[data->charHandle].
193 descriptorList.contains(data->descHandle)) {
194 return QBluetoothUuid();
195 }
196
197 return d_ptr->characteristicList[data->charHandle].descriptorList[data->descHandle].uuid;
198}
199
209QLowEnergyHandle QLowEnergyDescriptor::handle() const
210{
211 if (!data)
212 return 0;
213
214 return data->descHandle;
215}
216
224{
225 if (d_ptr.isNull() || !data
226 || !d_ptr->characteristicList.contains(data->charHandle)
227 || !d_ptr->characteristicList[data->charHandle].
228 descriptorList.contains(data->descHandle)) {
229 return QByteArray();
230 }
231
232 return d_ptr->characteristicList[data->charHandle].descriptorList[data->descHandle].value;
233}
234
251
283
289QLowEnergyHandle QLowEnergyDescriptor::characteristicHandle() const
290{
291 if (d_ptr.isNull() || !data)
292 return 0;
293
294 return data->charHandle;
295}
296
\inmodule QtBluetooth
quint16 toUInt16(bool *ok=nullptr) const
Returns the 16 bit representation of this UUID.
static QString descriptorToString(DescriptorType uuid)
Returns a human-readable and translated name for the given descriptor type represented by uuid.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtBluetooth
QLowEnergyDescriptor()
Construct a new QLowEnergyDescriptor.
QBluetoothUuid uuid() const
Returns the UUID of this descriptor if \l isValid() returns true; otherwise a \l {QUuid::isNull()}{nu...
QBluetoothUuid::DescriptorType type() const
Returns the type of the descriptor.
QByteArray value() const
Returns the cached value of the descriptor.
bool isValid() const
Returns true if the QLowEnergyDescriptor object is valid, otherwise returns false.
QLowEnergyDescriptor & operator=(const QLowEnergyDescriptor &other)
Makes a copy of other and assigns it to this QLowEnergyDescriptor object.
QString name() const
Returns the human-readable name of the descriptor.
~QLowEnergyDescriptor()
Destroys the QLowEnergyDescriptor object.
QLowEnergyService::ServiceState state
QHash< QLowEnergyHandle, CharData > characteristicList
bool isNull() const noexcept
Returns true if this object refers to \nullptr.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
quint16 QLowEnergyHandle
Definition qbluetooth.h:42
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat p
[1]
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]