Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
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.
60
61// Descriptor/charactesirstic read/write requests
62// - we have to serialize 'concurrent' requests.
83
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.
93
94} // namespace DarwinBluetooth
95
96QT_END_NAMESPACE
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
110- (void)disconnectFromDevice;
111
112- (void)discoverServices;
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
142QT_NAMESPACE_ALIAS_OBJC_CLASS(DarwinBTCentralManager);
143
144#endif
#define QT_BT_MAC_AUTORELEASEPOOL
Definition btutility_p.h:78
\inmodule QtBluetooth
void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
QList< QBluetoothUuid > includedServices
void setController(QLowEnergyControllerPrivate *control)
void characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
void characteristicRead(const QLowEnergyCharacteristic &info, const QByteArray &value)
QLowEnergyService::DiscoveryMode mode
void descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue)
void descriptorRead(const QLowEnergyDescriptor &info, const QByteArray &value)
QLowEnergyService::ServiceError lastError
void setError(QLowEnergyService::ServiceError newError)
QLowEnergyService::ServiceTypes type
QPointer< QLowEnergyControllerPrivate > controller
void errorOccurred(QLowEnergyService::ServiceError error)
void setState(QLowEnergyService::ServiceState newState)
QLowEnergyService::ServiceState state
QHash< QLowEnergyHandle, CharData > characteristicList
ObjCStrongReference< NSError > qt_timeoutNSError(OperationTimeout type)
QQueue< LERequest > RequestQueue
QHash< NSObject *, QByteArray > ValueHash
auto qt_find_watchdog(const std::vector< GCDTimer > &watchdogs, id object, OperationTimeout type)
QHash< QLowEnergyHandle, CBDescriptor * > DescHash
QHash< QLowEnergyHandle, CBService * > ServiceHash
NSUInteger qt_countGATTEntries(CBService *service)
QHash< QLowEnergyHandle, CBCharacteristic * > CharHash
QHash< QLowEnergyHandle, QLowEnergyServicePrivate::CharData > CharacteristicDataMap
QHash< QLowEnergyHandle, QLowEnergyServicePrivate::DescData > DescriptorDataMap
QHash< QLowEnergyHandle, DescData > descriptorList
QLowEnergyCharacteristic::PropertyTypes properties