Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
btcentralmanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef BTCENTRALMANAGER_P_H
5#define BTCENTRALMANAGER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
19#include "qbluetoothuuid.h"
20#include "btgcdtimer_p.h"
21#include "btutility_p.h"
22
23#include <QtCore/private/qcore_mac_p.h>
24
25#include <QtCore/qbytearray.h>
26#include <QtCore/qglobal.h>
27#include <QtCore/qqueue.h>
28#include <QtCore/qhash.h>
29
30#include <Foundation/Foundation.h>
31
32#include <CoreBluetooth/CoreBluetooth.h>
33
35
36namespace DarwinBluetooth {
37
38class LECBManagerNotifier;
39
41{
42 // QLowEnergyController already has some of these states,
43 // but it's not enough and we need more special states here.
45 // Required by CBCentralManager to avoid problems with dangled pointers.
50};
51
52// In Qt we work with handles and UUIDs. Core Bluetooth
53// has NSArrays (and nested NSArrays inside servces/characteristics).
54// To simplify a navigation, I need a simple way to map from a handle
55// to a Core Bluetooth object. These are weak pointers,
56// will probably require '__weak' with ARC.
57typedef QHash<QLowEnergyHandle, CBService *> ServiceHash;
58typedef QHash<QLowEnergyHandle, CBCharacteristic *> CharHash;
59typedef QHash<QLowEnergyHandle, CBDescriptor *> DescHash;
60
61// Descriptor/charactesirstic read/write requests
62// - we have to serialize 'concurrent' requests.
83
84typedef QQueue<LERequest> RequestQueue;
85
86// Core Bluetooth's write confirmation does not provide
87// the updated value (characteristic or descriptor).
88// But the Qt's Bluetooth API ('write with response')
89// expects this updated value as a response, so we have
90// to cache this write value and report it back.
91// 'NSObject *' will require '__weak' with ARC.
92typedef QHash<NSObject *, QByteArray> ValueHash;
93
94} // namespace DarwinBluetooth
95
97
98@interface QT_MANGLE_NAMESPACE(DarwinBTCentralManager) : NSObject<CBCentralManagerDelegate,
99 CBPeripheralDelegate,
100 QT_MANGLE_NAMESPACE(GCDTimerDelegate)>
101- (id)initWith:(QT_PREPEND_NAMESPACE(DarwinBluetooth)::LECBManagerNotifier *)notifier;
102- (void)dealloc;
103
104- (CBPeripheral *)peripheral;
105
106// IMPORTANT: _all_ these methods are to be executed on qt_LE_queue,
107// when passing parameters - C++ objects _must_ be copied (see the controller's code).
108- (void)connectToDevice:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)aDeviceUuid;
109
111
113- (void)discoverServiceDetails:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid
114 readValues:(bool)read;
115
116- (int)mtu;
117- (void)readRssi;
118
119- (void)setNotifyValue:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
120 forCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
121 onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
122
123- (void)readCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
124 onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
125
126- (void)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
127 charHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
128 onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid
129 withResponse:(bool)writeWithResponse;
130
131- (void)readDescriptor:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle
132 onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
133
134- (void)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
135 descHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle
136 onService:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
137
138- (void)detach;
139
140@end
141
143
144#endif
\inmodule QtBluetooth
\inmodule QtCore
Definition qbytearray.h:57
QQueue< LERequest > RequestQueue
QHash< NSObject *, QByteArray > ValueHash
QHash< QLowEnergyHandle, CBDescriptor * > DescHash
QHash< QLowEnergyHandle, CBService * > ServiceHash
QHash< QLowEnergyHandle, CBCharacteristic * > CharHash
Combined button and popup list for selecting options.
quint16 QLowEnergyHandle
Definition qbluetooth.h:42
#define QT_NAMESPACE_ALIAS_OBJC_CLASS(__KLASS__)
Definition qcore_mac_p.h:58
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLuint64 GLenum void * handle
GLenum GLuint id
[7]
GLenum type
gzip write("uncompressed data")