Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2017 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 QLOWENERGYCONTROLLERPRIVATEWINRT_NEW_P_H |
41 | #define QLOWENERGYCONTROLLERPRIVATEWINRT_NEW_P_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 <qglobal.h> |
55 | #include <QtCore/QQueue> |
56 | #include <QtCore/QVector> |
57 | #include <QtBluetooth/qbluetooth.h> |
58 | #include <QtBluetooth/qlowenergycharacteristic.h> |
59 | #include <QtBluetooth/qlowenergyservicedata.h> |
60 | #include "qlowenergycontroller.h" |
61 | #include "qlowenergycontrollerbase_p.h" |
62 | |
63 | namespace ABI { |
64 | namespace Windows { |
65 | namespace Devices { |
66 | namespace Bluetooth { |
67 | struct IBluetoothLEDevice; |
68 | } |
69 | } |
70 | namespace Foundation { |
71 | template <typename T> struct IAsyncOperation; |
72 | enum class AsyncStatus; |
73 | } |
74 | } |
75 | } |
76 | |
77 | #include <wrl.h> |
78 | #include <windows.devices.bluetooth.genericattributeprofile.h> |
79 | |
80 | #include <functional> |
81 | |
82 | QT_BEGIN_NAMESPACE |
83 | |
84 | class QLowEnergyServiceData; |
85 | class QTimer; |
86 | class QWinRTLowEnergyServiceHandler; |
87 | |
88 | extern void registerQLowEnergyControllerMetaType(); |
89 | |
90 | QLowEnergyControllerPrivate *createWinRTLowEnergyController(); |
91 | |
92 | class QLowEnergyControllerPrivateWinRTNew final : public QLowEnergyControllerPrivate |
93 | { |
94 | Q_OBJECT |
95 | public: |
96 | QLowEnergyControllerPrivateWinRTNew(); |
97 | ~QLowEnergyControllerPrivateWinRTNew() override; |
98 | |
99 | void init() override; |
100 | |
101 | void connectToDevice() override; |
102 | void disconnectFromDevice() override; |
103 | |
104 | void discoverServices() override; |
105 | void discoverServiceDetails(const QBluetoothUuid &service) override; |
106 | |
107 | void startAdvertising(const QLowEnergyAdvertisingParameters ¶ms, |
108 | const QLowEnergyAdvertisingData &advertisingData, |
109 | const QLowEnergyAdvertisingData &scanResponseData) override; |
110 | void stopAdvertising() override; |
111 | |
112 | void requestConnectionUpdate(const QLowEnergyConnectionParameters ¶ms) override; |
113 | |
114 | // read data |
115 | void readCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service, |
116 | const QLowEnergyHandle charHandle) override; |
117 | void readDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service, |
118 | const QLowEnergyHandle charHandle, |
119 | const QLowEnergyHandle descriptorHandle) override; |
120 | |
121 | // write data |
122 | void writeCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service, |
123 | const QLowEnergyHandle charHandle, |
124 | const QByteArray &newValue, QLowEnergyService::WriteMode mode) override; |
125 | void writeDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service, |
126 | const QLowEnergyHandle charHandle, |
127 | const QLowEnergyHandle descriptorHandle, |
128 | const QByteArray &newValue) override; |
129 | |
130 | void addToGenericAttributeList(const QLowEnergyServiceData &service, |
131 | QLowEnergyHandle startHandle) override; |
132 | |
133 | signals: |
134 | void characteristicChanged(quint16 charHandle, const QByteArray &data); |
135 | |
136 | private slots: |
137 | void handleCharacteristicChanged(quint16 charHandle, const QByteArray &data); |
138 | void handleServiceHandlerError(const QString &error); |
139 | |
140 | private: |
141 | void connectToPairedDevice(); |
142 | void connectToUnpairedDevice(); |
143 | |
144 | bool mAbortPending = false; |
145 | Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::IBluetoothLEDevice> mDevice; |
146 | EventRegistrationToken mStatusChangedToken; |
147 | struct ValueChangedEntry { |
148 | ValueChangedEntry() {} |
149 | ValueChangedEntry(Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattCharacteristic> c, |
150 | EventRegistrationToken t) |
151 | : characteristic(c) |
152 | , token(t) |
153 | { |
154 | } |
155 | |
156 | Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattCharacteristic> characteristic; |
157 | EventRegistrationToken token; |
158 | }; |
159 | QVector<ValueChangedEntry> mValueChangedTokens; |
160 | |
161 | Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattDeviceService> getNativeService(const QBluetoothUuid &serviceUuid); |
162 | Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattCharacteristic> getNativeCharacteristic(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid); |
163 | |
164 | void registerForValueChanges(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid); |
165 | void unregisterFromValueChanges(); |
166 | HRESULT onValueChange(ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattCharacteristic *characteristic, |
167 | ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattValueChangedEventArgs *args); |
168 | |
169 | bool registerForStatusChanges(); |
170 | void unregisterFromStatusChanges(); |
171 | HRESULT onStatusChange(ABI::Windows::Devices::Bluetooth::IBluetoothLEDevice *dev, IInspectable *); |
172 | |
173 | void obtainIncludedServices(QSharedPointer<QLowEnergyServicePrivate> servicePointer, |
174 | Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattDeviceService> nativeService); |
175 | HRESULT onServiceDiscoveryFinished(ABI::Windows::Foundation::IAsyncOperation<ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::GattDeviceServicesResult *> *op, |
176 | ABI::Windows::Foundation::AsyncStatus status); |
177 | }; |
178 | |
179 | QT_END_NAMESPACE |
180 | |
181 | #endif // QLOWENERGYCONTROLLERPRIVATEWINRT_NEW_P_H |
182 |
Warning: That file was not part of the compilation database. It may have many parsing errors.