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#ifndef QLOWENERGYCHARACTERISTIC_H
6#define QLOWENERGYCHARACTERISTIC_H
7#include <QtCore/QSharedPointer>
8#include <QtCore/QObject>
9#include <QtBluetooth/qbluetooth.h>
10#include <QtBluetooth/QBluetoothUuid>
11#include <QtBluetooth/QLowEnergyDescriptor>
12
13QT_BEGIN_NAMESPACE
14
15class QBluetoothUuid;
16class QLowEnergyServicePrivate;
17struct QLowEnergyCharacteristicPrivate;
18class Q_BLUETOOTH_EXPORT QLowEnergyCharacteristic
19{
20public:
21
22 enum PropertyType {
23 Unknown = 0x00,
24 Broadcasting = 0x01,
25 Read = 0x02,
26 WriteNoResponse = 0x04,
27 Write = 0x08,
28 Notify = 0x10,
29 Indicate = 0x20,
30 WriteSigned = 0x40,
31 ExtendedProperty = 0x80
32 };
33 Q_DECLARE_FLAGS(PropertyTypes, PropertyType)
34
35 QLowEnergyCharacteristic();
36 QLowEnergyCharacteristic(const QLowEnergyCharacteristic &other);
37 ~QLowEnergyCharacteristic();
38
39 QLowEnergyCharacteristic &operator=(const QLowEnergyCharacteristic &other);
40 friend bool operator==(const QLowEnergyCharacteristic &a, const QLowEnergyCharacteristic &b)
41 {
42 return equals(a, b);
43 }
44 friend bool operator!=(const QLowEnergyCharacteristic &a, const QLowEnergyCharacteristic &b)
45 {
46 return !equals(a, b);
47 }
48
49 QString name() const;
50
51 QBluetoothUuid uuid() const;
52
53 QByteArray value() const;
54
55 QLowEnergyCharacteristic::PropertyTypes properties() const;
56
57 QLowEnergyDescriptor descriptor(const QBluetoothUuid &uuid) const;
58 QList<QLowEnergyDescriptor> descriptors() const;
59
60 QLowEnergyDescriptor clientCharacteristicConfiguration() const;
61
62 bool isValid() const;
63
64 static const QByteArray CCCDDisable;
65 static const QByteArray CCCDEnableNotification;
66 static const QByteArray CCCDEnableIndication;
67
68private:
69 QLowEnergyHandle handle() const;
70 QLowEnergyHandle attributeHandle() const;
71
72 QSharedPointer<QLowEnergyServicePrivate> d_ptr;
73
74 friend class QLowEnergyService;
75 friend class QLowEnergyControllerPrivate;
76 friend class QLowEnergyControllerPrivateAndroid;
77 friend class QLowEnergyControllerPrivateBluez;
78 friend class QLowEnergyControllerPrivateBluezDBus;
79 friend class QLowEnergyControllerPrivateCommon;
80 friend class QLowEnergyControllerPrivateDarwin;
81 friend class QLowEnergyControllerPrivateWinRT;
82 QLowEnergyCharacteristicPrivate *data = nullptr;
83 QLowEnergyCharacteristic(QSharedPointer<QLowEnergyServicePrivate> p,
84 QLowEnergyHandle handle);
85
86 static bool equals(const QLowEnergyCharacteristic &a, const QLowEnergyCharacteristic &b);
87};
88
89Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyCharacteristic::PropertyTypes)
90
91QT_END_NAMESPACE
92
93QT_DECL_METATYPE_EXTERN(QLowEnergyCharacteristic, Q_BLUETOOTH_EXPORT)
94
95#endif // QLOWENERGYCHARACTERISTIC_H
96

source code of qtconnectivity/src/bluetooth/qlowenergycharacteristic.h