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
btutility_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 BTUTILITY_P_H
5#define BTUTILITY_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
18#include "btraii_p.h"
19
20#include <QtCore/qloggingcategory.h>
21#include <QtCore/qglobal.h>
22
23#include <QtCore/private/qcore_mac_p.h>
24
25#include <Foundation/Foundation.h>
26
27#include <CoreBluetooth/CoreBluetooth.h>
28
29#ifdef Q_OS_MACOS
30#include <IOBluetooth/IOBluetooth.h>
31#endif // Q_OS_MACOS
32
34
35class QLowEnergyCharacteristicData;
36class QBluetoothAddress;
37class QBluetoothUuid;
38class QString;
39
40namespace DarwinBluetooth {
41
42template<class T>
44{
45public:
46 ObjCScopedPointer() = default;
48 : m_ptr(ptr, policy)
49 {
50 }
52 {
53 m_ptr.swap(other.m_ptr);
54 }
55 void reset()
56 {
57 m_ptr.reset();
58 }
59 void reset(T *ptr, RetainPolicy policy)
60 {
61 m_ptr.reset(ptr, policy);
62 }
63 operator T*() const
64 {
65 return m_ptr.getAs<T>();
66 }
67 T *get() const
68 {
69 // operator T * above does not work when accessing
70 // properties using '.' syntax.
71 return m_ptr.getAs<T>();
72 }
73private:
74 // Copy and move disabled by m_ptr:
75 ScopedPointer m_ptr;
76};
77
78#define QT_BT_MAC_AUTORELEASEPOOL const QMacAutoReleasePool pool;
79
80template<class T>
81class ObjCStrongReference final : public StrongReference {
82public:
83 using StrongReference::StrongReference;
84
85 operator T *() const
86 {
87 return this->getAs<T>();
88 }
89
90 T *data() const
91 {
92 return this->getAs<T>();
93 }
94};
95
96QString qt_address(NSString *address);
97
98#ifndef QT_IOS_BLUETOOTH
99
100QBluetoothAddress qt_address(const BluetoothDeviceAddress *address);
101BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &address);
102
103ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &uuid);
104QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid);
105QString qt_error_string(IOReturn errorCode);
107
108#endif // !QT_IOS_BLUETOOTH
109
110QBluetoothUuid qt_uuid(CBUUID *uuid);
111ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid);
112bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid);
113bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid);
114QByteArray qt_bytearray(NSData *data);
115QByteArray qt_bytearray(NSObject *data);
116
117ObjCStrongReference<NSData> data_from_bytearray(const QByteArray &qtData);
119
121
122extern const int defaultLEScanTimeoutMS;
123extern const int maxValueLength;
124extern const int defaultMtu;
125
126} // namespace DarwinBluetooth
127
128Q_DECLARE_LOGGING_CATEGORY(QT_BT_DARWIN)
129
130QT_END_NAMESPACE
131
132#endif // BTUTILITY_P_H
#define QT_BT_MAC_AUTORELEASEPOOL
Definition btutility_p.h:78
ObjCScopedPointer(T *ptr, RetainPolicy policy)
Definition btutility_p.h:47
void reset(T *ptr, RetainPolicy policy)
Definition btutility_p.h:59
void swap(ObjCScopedPointer &other)
Definition btutility_p.h:51
\inmodule QtBluetooth
\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
ObjCStrongReference< CBUUID > cb_uuid(const QBluetoothUuid &qtUuid)
Definition btutility.mm:174
QHash< NSObject *, QByteArray > ValueHash
const int defaultLEScanTimeoutMS
Definition btutility.mm:30
bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid)
Definition btutility.mm:190
ObjCStrongReference< NSMutableData > mutable_data_from_bytearray(const QByteArray &qtData)
Definition btutility.mm:281
auto qt_find_watchdog(const std::vector< GCDTimer > &watchdogs, id object, OperationTimeout type)
QByteArray qt_bytearray(NSData *data)
Definition btutility.mm:201
QHash< QLowEnergyHandle, CBDescriptor * > DescHash
QString qt_address(NSString *address)
Definition btutility.mm:36
QHash< QLowEnergyHandle, CBService * > ServiceHash
void qt_test_iobluetooth_runloop()
Definition btutility.mm:125
BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &address)
Definition btutility.mm:65
NSUInteger qt_countGATTEntries(CBService *service)
QString qt_error_string(IOReturn errorCode)
Definition btutility.mm:104
const int maxValueLength
Definition btutility.mm:32
ObjCStrongReference< NSData > data_from_bytearray(const QByteArray &qtData)
Definition btutility.mm:272
QBluetoothAddress qt_address(const BluetoothDeviceAddress *address)
Definition btutility.mm:49
ObjCStrongReference< IOBluetoothSDPUUID > iobluetooth_uuid(const QBluetoothUuid &uuid)
Definition btutility.mm:81
dispatch_queue_t qt_LE_queue()
Definition btutility.mm:324
QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid)
Definition btutility.mm:91
const int defaultMtu
Definition btutility.mm:34
QHash< QLowEnergyHandle, CBCharacteristic * > CharHash
bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid)
Definition btutility.mm:196
QHash< QLowEnergyHandle, QLowEnergyServicePrivate::CharData > CharacteristicDataMap
QHash< QLowEnergyHandle, QLowEnergyServicePrivate::DescData > DescriptorDataMap
QDataStream & operator<<(QDataStream &stream, const QImage &image)
[0]
Definition qimage.cpp:4006
QDataStream & operator>>(QDataStream &stream, QImage &image)
Definition qimage.cpp:4032
QHash< QLowEnergyHandle, DescData > descriptorList
QLowEnergyCharacteristic::PropertyTypes properties