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
qlowenergycharacteristicdata.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
7
8#include <QtCore/qbytearray.h>
9#include <QtCore/qloggingcategory.h>
10#include <QtCore/qdebug.h>
11
12#include <climits>
13
15
17
19{
22 , minimumValueLength(0)
23 , maximumValueLength(INT_MAX)
24 {}
25
27 QLowEnergyCharacteristic::PropertyTypes properties;
28 QList<QLowEnergyDescriptorData> descriptors;
30 QBluetooth::AttAccessConstraints readConstraints;
31 QBluetooth::AttAccessConstraints writeConstraints;
34};
35
55
61
66
73
79
85
91
97
99QLowEnergyCharacteristic::PropertyTypes QLowEnergyCharacteristicData::properties() const
100{
101 return d->properties;
102}
103
105void QLowEnergyCharacteristicData::setProperties(QLowEnergyCharacteristic::PropertyTypes properties)
106{
109 qCWarning(QT_BT) << "Both NTF and IND properties set for characteristic" << d->uuid;
111}
112
114QList<QLowEnergyDescriptorData> QLowEnergyCharacteristicData::descriptors() const
115{
116 return d->descriptors;
117}
118
124void QLowEnergyCharacteristicData::setDescriptors(const QList<QLowEnergyDescriptorData> &descriptors)
125{
126 d->descriptors.clear();
127 for (const QLowEnergyDescriptorData &desc : descriptors)
128 addDescriptor(desc);
129}
130
136{
137 if (descriptor.isValid())
138 d->descriptors << descriptor;
139 else
140 qCWarning(QT_BT) << "not adding invalid descriptor to characteristic";
141}
142
146void QLowEnergyCharacteristicData::setReadConstraints(QBluetooth::AttAccessConstraints constraints)
147{
148 d->readConstraints = constraints;
149}
150
156QBluetooth::AttAccessConstraints QLowEnergyCharacteristicData::readConstraints() const
157{
158 return d->readConstraints;
159}
160
164void QLowEnergyCharacteristicData::setWriteConstraints(QBluetooth::AttAccessConstraints constraints)
165{
166 d->writeConstraints = constraints;
167}
168
176QBluetooth::AttAccessConstraints QLowEnergyCharacteristicData::writeConstraints() const
177{
178 return d->writeConstraints;
179}
180
187{
188 d->minimumValueLength = minimum;
189 d->maximumValueLength = qMax(minimum, maximum);
190}
191
200
209
214{
215 return !uuid().isNull();
216}
217
228bool QLowEnergyCharacteristicData::equals(const QLowEnergyCharacteristicData &a,
230{
231 return a.d == b.d
232 || (a.uuid() == b.uuid() && a.properties() == b.properties()
233 && a.descriptors() == b.descriptors() && a.value() == b.value()
234 && a.readConstraints() == b.readConstraints()
235 && a.writeConstraints() == b.writeConstraints()
236 && a.minimumValueLength() == b.maximumValueLength()
237 && a.maximumValueLength() == b.maximumValueLength());
238}
239
\inmodule QtBluetooth
\inmodule QtCore
Definition qbytearray.h:57
void clear()
Definition qlist.h:434
The QLowEnergyCharacteristicData class is used to set up GATT service data. \inmodule QtBluetooth.
QBluetoothUuid uuid() const
Returns the UUID of this characteristic.
void setWriteConstraints(QBluetooth::AttAccessConstraints constraints)
Specifies that clients need to fulfill constraints to write the value of this characteristic.
void setDescriptors(const QList< QLowEnergyDescriptorData > &descriptors)
Sets the descriptors of this characteristic to descriptors.
bool isValid() const
Returns true if and only if this characteristic is valid, that is, it has a non-null UUID.
void setProperties(QLowEnergyCharacteristic::PropertyTypes properties)
Sets the properties of this characteristic to properties.
QBluetooth::AttAccessConstraints writeConstraints() const
Returns the constraints needed for a client to write the value of this characteristic.
int minimumValueLength() const
Returns the minimum length in bytes that the value of this characteristic can have.
QLowEnergyCharacteristic::PropertyTypes properties() const
Returns the properties of this characteristic.
QLowEnergyCharacteristicData & operator=(const QLowEnergyCharacteristicData &other)
Makes this object a copy of other and returns the new value of this object.
QList< QLowEnergyDescriptorData > descriptors() const
Returns the descriptors of this characteristic.
void addDescriptor(const QLowEnergyDescriptorData &descriptor)
Adds descriptor to the list of descriptors of this characteristic, if it is valid.
int maximumValueLength() const
Returns the maximum length in bytes that the value of this characteristic can have.
QByteArray value() const
Returns the value of this characteristic.
QBluetooth::AttAccessConstraints readConstraints() const
Returns the constraints needed for a client to read the value of this characteristic.
~QLowEnergyCharacteristicData()
Destroys this object.
QLowEnergyCharacteristicData()
Creates a new invalid object of this class.
void setUuid(const QBluetoothUuid &uuid)
Sets the UUID of this characteristic to uuid.
void setValueLength(int minimum, int maximum)
Specifies minimum and maximum to be the smallest and largest length, respectively,...
void setReadConstraints(QBluetooth::AttAccessConstraints constraints)
Specifies that clients need to fulfill constraints to read the value of this characteristic.
void setValue(const QByteArray &value)
Sets the value of this characteristic to value.
The QLowEnergyDescriptorData class is used to create GATT service data. \inmodule QtBluetooth.
bool isValid() const
Returns true if and only if this object has a non-null UUID.
\inmodule QtCore
Definition qshareddata.h:19
bool isNull() const noexcept
Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false...
Definition quuid.cpp:818
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCWarning(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
QSharedPointer< T > other(t)
[5]
QBluetooth::AttAccessConstraints writeConstraints
QBluetooth::AttAccessConstraints readConstraints
QList< QLowEnergyDescriptorData > descriptors
QLowEnergyCharacteristic::PropertyTypes properties