1/***************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Copyright (C) 2016 BlackBerry Limited all rights reserved
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtBluetooth module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QLOWENERGYCHARACTERISTIC_H
42#define QLOWENERGYCHARACTERISTIC_H
43#include <QtCore/QSharedPointer>
44#include <QtCore/QObject>
45#include <QtBluetooth/qbluetooth.h>
46#include <QtBluetooth/QBluetoothUuid>
47#include <QtBluetooth/QLowEnergyDescriptor>
48
49QT_BEGIN_NAMESPACE
50
51class QBluetoothUuid;
52class QLowEnergyServicePrivate;
53struct QLowEnergyCharacteristicPrivate;
54class Q_BLUETOOTH_EXPORT QLowEnergyCharacteristic
55{
56public:
57
58 enum PropertyType {
59 Unknown = 0x00,
60 Broadcasting = 0x01,
61 Read = 0x02,
62 WriteNoResponse = 0x04,
63 Write = 0x08,
64 Notify = 0x10,
65 Indicate = 0x20,
66 WriteSigned = 0x40,
67 ExtendedProperty = 0x80
68 };
69 Q_DECLARE_FLAGS(PropertyTypes, PropertyType)
70
71 QLowEnergyCharacteristic();
72 QLowEnergyCharacteristic(const QLowEnergyCharacteristic &other);
73 ~QLowEnergyCharacteristic();
74
75 QLowEnergyCharacteristic &operator=(const QLowEnergyCharacteristic &other);
76 bool operator==(const QLowEnergyCharacteristic &other) const;
77 bool operator!=(const QLowEnergyCharacteristic &other) const;
78
79 QString name() const;
80
81 QBluetoothUuid uuid() const;
82
83 QByteArray value() const;
84
85 QLowEnergyCharacteristic::PropertyTypes properties() const;
86 QLowEnergyHandle handle() const;
87
88 QLowEnergyDescriptor descriptor(const QBluetoothUuid &uuid) const;
89 QList<QLowEnergyDescriptor> descriptors() const;
90
91 bool isValid() const;
92
93protected:
94 QLowEnergyHandle attributeHandle() const;
95
96 QSharedPointer<QLowEnergyServicePrivate> d_ptr;
97
98 friend class QLowEnergyService;
99 friend class QLowEnergyControllerPrivate;
100 friend class QLowEnergyControllerPrivateAndroid;
101 friend class QLowEnergyControllerPrivateBluez;
102 friend class QLowEnergyControllerPrivateBluezDBus;
103 friend class QLowEnergyControllerPrivateCommon;
104 friend class QLowEnergyControllerPrivateDarwin;
105 friend class QLowEnergyControllerPrivateWinRT;
106 friend class QLowEnergyControllerPrivateWinRTNew;
107 QLowEnergyCharacteristicPrivate *data = nullptr;
108 QLowEnergyCharacteristic(QSharedPointer<QLowEnergyServicePrivate> p,
109 QLowEnergyHandle handle);
110};
111
112Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyCharacteristic::PropertyTypes)
113
114QT_END_NAMESPACE
115
116Q_DECLARE_METATYPE(QLowEnergyCharacteristic)
117
118#endif // QLOWENERGYCHARACTERISTIC_H
119