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 OSXBTCENTRALMANAGER_P_H |
41 | #define OSXBTCENTRALMANAGER_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 "qlowenergycontroller.h" |
55 | #include "qlowenergyservice.h" |
56 | #include "osxbtgcdtimer_p.h" |
57 | #include "qbluetoothuuid.h" |
58 | #include "osxbtutility_p.h" |
59 | #include "osxbluetooth_p.h" |
60 | |
61 | #include <QtCore/qbytearray.h> |
62 | #include <QtCore/qglobal.h> |
63 | #include <QtCore/qqueue.h> |
64 | #include <QtCore/qhash.h> |
65 | |
66 | #include <Foundation/Foundation.h> |
67 | |
68 | @class QT_MANGLE_NAMESPACE(OSXBTCentralManager); |
69 | |
70 | QT_BEGIN_NAMESPACE |
71 | |
72 | class QLowEnergyServicePrivate; |
73 | |
74 | namespace OSXBluetooth { |
75 | |
76 | class LECBManagerNotifier; |
77 | |
78 | enum CentralManagerState |
79 | { |
80 | // QLowEnergyController already has some of these states, |
81 | // but it's not enough and we need more special states here. |
82 | CentralManagerIdle, |
83 | // Required by CBCentralManager to avoid problems with dangled pointers. |
84 | CentralManagerUpdating, |
85 | CentralManagerConnecting, |
86 | CentralManagerDiscovering, |
87 | CentralManagerDisconnecting |
88 | }; |
89 | |
90 | // In Qt we work with handles and UUIDs. Core Bluetooth |
91 | // has NSArrays (and nested NSArrays inside servces/characteristics). |
92 | // To simplify a navigation, I need a simple way to map from a handle |
93 | // to a Core Bluetooth object. These are weak pointers, |
94 | // will probably require '__weak' with ARC. |
95 | typedef QHash<QLowEnergyHandle, CBService *> ServiceHash; |
96 | typedef QHash<QLowEnergyHandle, CBCharacteristic *> CharHash; |
97 | typedef QHash<QLowEnergyHandle, CBDescriptor *> DescHash; |
98 | |
99 | // Descriptor/charactesirstic read/write requests |
100 | // - we have to serialize 'concurrent' requests. |
101 | struct LERequest { |
102 | enum RequestType { |
103 | CharRead, |
104 | CharWrite, |
105 | DescRead, |
106 | DescWrite, |
107 | ClientConfiguration, |
108 | Invalid |
109 | }; |
110 | |
111 | LERequest() : type(Invalid), |
112 | withResponse(false), |
113 | handle(0) |
114 | {} |
115 | |
116 | RequestType type; |
117 | bool withResponse; |
118 | QLowEnergyHandle handle; |
119 | QByteArray value; |
120 | }; |
121 | |
122 | typedef QQueue<LERequest> RequestQueue; |
123 | |
124 | // Core Bluetooth's write confirmation does not provide |
125 | // the updated value (characteristic or descriptor). |
126 | // But the Qt's Bluetooth API ('write with response') |
127 | // expects this updated value as a response, so we have |
128 | // to cache this write value and report it back. |
129 | // 'NSObject *' will require '__weak' with ARC. |
130 | typedef QHash<NSObject *, QByteArray> ValueHash; |
131 | |
132 | } |
133 | |
134 | QT_END_NAMESPACE |
135 | |
136 | @interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) : NSObject<CBCentralManagerDelegate, |
137 | CBPeripheralDelegate, |
138 | QT_MANGLE_NAMESPACE(GCDTimerDelegate)> |
139 | - (id)initWith:(QT_PREPEND_NAMESPACE(OSXBluetooth)::LECBManagerNotifier *)notifier; |
140 | - (void)dealloc; |
141 | |
142 | - (CBPeripheral *)peripheral; |
143 | |
144 | // IMPORTANT: _all_ these methods are to be executed on qt_LE_queue, |
145 | // when passing parameters - C++ objects _must_ be copied (see the controller's code). |
146 | - (void)connectToDevice:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)aDeviceUuid; |
147 | |
148 | - (void)disconnectFromDevice; |
149 | |
150 | - (void)discoverServices; |
151 | - (void)discoverServiceDetails:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid; |
152 | |
153 | - (void)setNotifyValue:(const QT_PREPEND_NAMESPACE(QByteArray) &)value |
154 | forCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle |
155 | onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid; |
156 | |
157 | - (void)readCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle |
158 | onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid; |
159 | |
160 | - (void)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value |
161 | charHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle |
162 | onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid |
163 | withResponse:(bool)writeWithResponse; |
164 | |
165 | - (void)readDescriptor:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle |
166 | onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid; |
167 | |
168 | - (void)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value |
169 | descHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle |
170 | onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid; |
171 | |
172 | - (void)detach; |
173 | |
174 | @end |
175 | |
176 | #endif |
177 |
Warning: That file was not part of the compilation database. It may have many parsing errors.