Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtBluetooth module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef LOWENERGYNOTIFICATIONHUB_H |
41 | #define LOWENERGYNOTIFICATIONHUB_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists purely as an |
48 | // implementation detail. This header file may change from version to |
49 | // version without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | |
54 | #include <QtCore/QObject> |
55 | #include <QtCore/QReadWriteLock> |
56 | #include <QtCore/private/qjnihelpers_p.h> |
57 | #include <QtAndroidExtras/QAndroidJniObject> |
58 | #include <QtBluetooth/QBluetoothAddress> |
59 | #include <QtBluetooth/QLowEnergyController> |
60 | #include <QtBluetooth/QLowEnergyService> |
61 | #include <jni.h> |
62 | |
63 | #include <QtBluetooth/QLowEnergyCharacteristic> |
64 | |
65 | QT_BEGIN_NAMESPACE |
66 | |
67 | class LowEnergyNotificationHub : public QObject |
68 | { |
69 | Q_OBJECT |
70 | public: |
71 | explicit LowEnergyNotificationHub(const QBluetoothAddress &remote, bool isPeripheral, |
72 | QObject *parent = nullptr); |
73 | ~LowEnergyNotificationHub(); |
74 | |
75 | static void lowEnergy_connectionChange(JNIEnv*, jobject, jlong qtObject, |
76 | jint errorCode, jint newState); |
77 | static void lowEnergy_servicesDiscovered(JNIEnv*, jobject, jlong qtObject, |
78 | jint errorCode, jobject uuidList); |
79 | static void lowEnergy_serviceDetailsDiscovered(JNIEnv *, jobject, |
80 | jlong qtObject, jobject uuid, |
81 | jint startHandle, jint endHandle); |
82 | static void lowEnergy_characteristicRead(JNIEnv*env, jobject, jlong qtObject, |
83 | jobject serviceUuid, |
84 | jint handle, jobject charUuid, |
85 | jint properties, jbyteArray data); |
86 | static void lowEnergy_descriptorRead(JNIEnv *env, jobject, jlong qtObject, |
87 | jobject sUuid, jobject cUuid, |
88 | jint handle, jobject dUuid, jbyteArray data); |
89 | static void lowEnergy_characteristicWritten(JNIEnv *, jobject, jlong qtObject, |
90 | jint charHandle, jbyteArray data, |
91 | jint errorCode); |
92 | static void lowEnergy_descriptorWritten(JNIEnv *, jobject, jlong qtObject, |
93 | jint descHandle, jbyteArray data, |
94 | jint errorCode); |
95 | static void lowEnergy_serverDescriptorWritten(JNIEnv *, jobject, jlong qtObject, |
96 | jobject descriptor, jbyteArray newValue); |
97 | static void lowEnergy_characteristicChanged(JNIEnv *, jobject, jlong qtObject, |
98 | jint charHandle, jbyteArray data); |
99 | static void lowEnergy_serverCharacteristicChanged(JNIEnv *, jobject, jlong qtObject, |
100 | jobject characteristic, jbyteArray newValue); |
101 | static void lowEnergy_serviceError(JNIEnv *, jobject, jlong qtObject, |
102 | jint attributeHandle, int errorCode); |
103 | static void lowEnergy_advertisementError(JNIEnv *, jobject, jlong qtObject, |
104 | jint status); |
105 | |
106 | QAndroidJniObject javaObject() |
107 | { |
108 | return jBluetoothLe; |
109 | } |
110 | |
111 | signals: |
112 | void connectionUpdated(QLowEnergyController::ControllerState newState, |
113 | QLowEnergyController::Error errorCode); |
114 | void servicesDiscovered(QLowEnergyController::Error errorCode, const QString &uuids); |
115 | void serviceDetailsDiscoveryFinished(const QString& serviceUuid, |
116 | int startHandle, int endHandle); |
117 | void characteristicRead(const QBluetoothUuid &serviceUuid, |
118 | int handle, const QBluetoothUuid &charUuid, |
119 | int properties, const QByteArray &data); |
120 | void descriptorRead(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid, |
121 | int handle, const QBluetoothUuid &descUuid, const QByteArray &data); |
122 | void characteristicWritten(int charHandle, const QByteArray &data, |
123 | QLowEnergyService::ServiceError errorCode); |
124 | void descriptorWritten(int descHandle, const QByteArray &data, |
125 | QLowEnergyService::ServiceError errorCode); |
126 | void serverDescriptorWritten(const QAndroidJniObject &descriptor, const QByteArray &newValue); |
127 | void characteristicChanged(int charHandle, const QByteArray &data); |
128 | void serverCharacteristicChanged(const QAndroidJniObject &characteristic, const QByteArray &newValue); |
129 | void serviceError(int attributeHandle, QLowEnergyService::ServiceError errorCode); |
130 | void advertisementError(int status); |
131 | |
132 | public slots: |
133 | private: |
134 | static QReadWriteLock lock; |
135 | |
136 | QAndroidJniObject jBluetoothLe; |
137 | long javaToCtoken; |
138 | |
139 | }; |
140 | |
141 | QT_END_NAMESPACE |
142 | |
143 | #endif // LOWENERGYNOTIFICATIONHUB_H |
144 | |
145 |
Warning: That file was not part of the compilation database. It may have many parsing errors.