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
qbluetoothdevicediscoveryagent.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QBLUETOOTHDEVICEDISCOVERYAGENT_H
6#define QBLUETOOTHDEVICEDISCOVERYAGENT_H
7
8#include <QtBluetooth/qtbluetoothglobal.h>
9
10#include <QtCore/QObject>
11#include <QtBluetooth/QBluetoothDeviceInfo>
12#include <QtBluetooth/QBluetoothAddress>
13
14QT_BEGIN_NAMESPACE
15
16class QBluetoothDeviceDiscoveryAgentPrivate;
17
18class Q_BLUETOOTH_EXPORT QBluetoothDeviceDiscoveryAgent : public QObject
19{
20 Q_OBJECT
21
22public:
23 // FIXME: add more errors
24 // FIXME: add bluez error handling
25 enum Error {
26 NoError,
27 InputOutputError,
28 PoweredOffError,
29 InvalidBluetoothAdapterError,
30 UnsupportedPlatformError,
31 UnsupportedDiscoveryMethod,
32 LocationServiceTurnedOffError,
33 MissingPermissionsError,
34 UnknownError = 100 // New errors must be added before Unknown error
35 };
36 Q_ENUM(Error)
37
38 enum DiscoveryMethod
39 {
40 NoMethod = 0x0,
41 ClassicMethod = 0x01,
42 LowEnergyMethod = 0x02,
43 };
44 Q_DECLARE_FLAGS(DiscoveryMethods, DiscoveryMethod)
45 Q_FLAG(DiscoveryMethods)
46
47 explicit QBluetoothDeviceDiscoveryAgent(QObject *parent = nullptr);
48 explicit QBluetoothDeviceDiscoveryAgent(const QBluetoothAddress &deviceAdapter,
49 QObject *parent = nullptr);
50 ~QBluetoothDeviceDiscoveryAgent();
51
52 bool isActive() const;
53
54 Error error() const;
55 QString errorString() const;
56
57 QList<QBluetoothDeviceInfo> discoveredDevices() const;
58
59 void setLowEnergyDiscoveryTimeout(int msTimeout);
60 int lowEnergyDiscoveryTimeout() const;
61
62 static DiscoveryMethods supportedDiscoveryMethods();
63public Q_SLOTS:
64 void start();
65 void start(DiscoveryMethods method);
66 void stop();
67
68Q_SIGNALS:
69 void deviceDiscovered(const QBluetoothDeviceInfo &info);
70 void deviceUpdated(const QBluetoothDeviceInfo &info, QBluetoothDeviceInfo::Fields updatedFields);
71 void finished();
72 void errorOccurred(QBluetoothDeviceDiscoveryAgent::Error error);
73 void canceled();
74
75private:
76 Q_DECLARE_PRIVATE(QBluetoothDeviceDiscoveryAgent)
77 QBluetoothDeviceDiscoveryAgentPrivate *d_ptr;
78};
79
80Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods)
81
82QT_END_NAMESPACE
83
84#endif
#define QT_BT_MAC_AUTORELEASEPOOL
Definition btutility_p.h:78
void characteristicUpdated(QLowEnergyHandle charHandle, const QByteArray &value)
void rssiUpdated(qint16 newValue)
void serviceDetailsDiscoveryFinished(QSharedPointer< QLowEnergyServicePrivate > service)
void CBManagerError(const QBluetoothUuid &serviceUuid, QLowEnergyController::Error error)
void characteristicRead(QLowEnergyHandle charHandle, const QByteArray &value)
void descriptorRead(QLowEnergyHandle descHandle, const QByteArray &value)
void characteristicWritten(QLowEnergyHandle charHandle, const QByteArray &value)
void notificationEnabled(QLowEnergyHandle charHandle, bool enabled)
void CBManagerError(QBluetoothDeviceDiscoveryAgent::Error error)
void descriptorWritten(QLowEnergyHandle descHandle, const QByteArray &value)
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
ScopedPointer(void *instance, RetainPolicy policy)
Definition btraii_p.h:85
ObjCType * getAs() const
Definition btraii_p.h:67
StrongReference & operator=(StrongReference &&other) noexcept
Definition btraii.mm:49
StrongReference & operator=(const StrongReference &other) noexcept
Definition btraii.mm:39
StrongReference(void *object, RetainPolicy policy)
Definition btraii.mm:16
void reset(void *newInstance, RetainPolicy policy)
Definition btraii.mm:70
StrongReference(StrongReference &&other)
Definition btraii.mm:29
void swap(StrongReference &other) noexcept
Definition btraii_p.h:56
StrongReference(const StrongReference &other)
Definition btraii.mm:23
\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
quint16 QLowEnergyHandle
Definition qbluetooth.h:42
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