75class QBluetoothDeviceDiscoveryAgentPrivate
76#if defined(QT_ANDROID_BLUETOOTH) || defined(QT_WINRT_BLUETOOTH)
77 || defined(Q_OS_DARWIN) || defined(QT_HARMONY_BLUETOOTH)
79#if defined(Q_OS_MACOS)
80 ,
public DarwinBluetooth::DeviceInquiryDelegate
87 Q_DECLARE_PUBLIC(QBluetoothDeviceDiscoveryAgent)
89 QBluetoothDeviceDiscoveryAgentPrivate(
90 const QBluetoothAddress &deviceAdapter,
91 QBluetoothDeviceDiscoveryAgent *parent);
92 ~QBluetoothDeviceDiscoveryAgentPrivate();
94 void start(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods methods);
96 bool isActive()
const;
99 void _q_InterfacesAdded(
const QDBusObjectPath &object_path,
100 InterfaceList interfaces_and_properties);
101 void _q_discoveryFinished();
102 void _q_discoveryInterrupted(
const QString &path);
103 void _q_PropertiesChanged(
const QString &interface,
105 const QVariantMap &changed_properties,
106 const QStringList &invalidated_properties);
110 QList<QBluetoothDeviceInfo> discoveredDevices;
112 QBluetoothDeviceDiscoveryAgent::Error lastError = QBluetoothDeviceDiscoveryAgent::NoError;
114 QBluetoothAddress adapterAddress;
116#ifdef QT_ANDROID_BLUETOOTH
118 void processSdpDiscoveryFinished();
119 void processDiscoveredDevices(
const QBluetoothDeviceInfo &info,
bool isLeResult);
120 friend void QtBluetoothLE_leScanResult(JNIEnv *, jobject, jlong, jobject);
121 void stopLowEnergyScan();
124 void startLowEnergyScan();
125 void processLeDiscoveryFinished(
int epoch);
126 void classicDiscoveryStartFail();
127 bool setErrorIfPowerOff();
129 DeviceDiscoveryBroadcastReceiver *receiver =
nullptr;
132 QJniObject leScanner;
133 QTimer *leScanTimeout =
nullptr;
134 QTimer *deviceDiscoveryStartTimeout =
nullptr;
135 short deviceDiscoveryStartAttemptsLeft;
138 bool pendingCancel =
false;
139 bool pendingStart =
false;
140#elif QT_CONFIG(bluez)
141 bool pendingCancel =
false;
142 bool pendingStart =
false;
143 QtBluetoothPrivate::OrgFreedesktopDBusObjectManagerInterface *manager =
nullptr;
144 QtBluetoothPrivate::OrgBluezAdapter1Interface *adapter =
nullptr;
145 QTimer *discoveryTimer =
nullptr;
146 QList<QtBluetoothPrivate::OrgFreedesktopDBusPropertiesInterface *> propertyMonitors;
148 void deviceFound(
const QString &devicePath,
const QVariantMap &properties);
150 QMap<QString, QVariantMap> devicesProperties;
153#ifdef QT_WINRT_BLUETOOTH
155 void registerDevice(
const QBluetoothDeviceInfo &info);
156 void updateDeviceData(
const QBluetoothAddress &address, QBluetoothDeviceInfo::Fields fields,
157 qint16 rssi, ManufacturerData manufacturerData, ServiceData serviceData);
158 void onErrorOccured(QBluetoothDeviceDiscoveryAgent::Error e);
159 void onScanFinished();
162 void disconnectAndClearWorker();
163 std::shared_ptr<QWinRTBluetoothDeviceDiscoveryWorker> worker =
nullptr;
175 void inquiryFinished() override;
176 void error(IOReturn error) override;
177 void classicDeviceFound(
void *device) override;
179 void setError(IOReturn error,
const QString &text = QString());
184 void LEinquiryFinished();
185 void LEinquiryError(QBluetoothDeviceDiscoveryAgent::Error error);
186 void LEnotSupported();
189 void setError(QBluetoothDeviceDiscoveryAgent::Error,
190 const QString &text = QString());
193 void deviceFound(
const QBluetoothDeviceInfo &newDeviceInfo);
201 bool startPending =
false;
202 bool stopPending =
false;
206 DarwinBluetooth::ScopedPointer controller;
207 DarwinBluetooth::ScopedPointer inquiry;
211 DarwinBluetooth::ScopedPointer inquiryLE;
215#ifdef QT_HARMONY_BLUETOOTH
216 enum class DiscoveryStopReason { Finished, BluetoothPoweredOff };
217 void reportDiscoveryStopped(DiscoveryStopReason reason);
218 void clearDiscoveryState();
219 void emitAsyncError();
220 void reportPairedDevicesAsync();
221 void reportDiscoveredDevices(
const std::vector<QBluetoothDeviceInfo> &bluetoothDevicesInfos);
222 std::shared_ptr<QtOhosBluetooth::QOhosBluetoothDeviceDiscoveryAgentProxy> m_discoveryAgentProxy;
223 bool m_discoveryRequested =
false;
224 bool m_pendingStart =
false;
225 bool m_pendingCancel =
false;
228 int lowEnergySearchTimeout = 40000;
229 QBluetoothDeviceDiscoveryAgent::DiscoveryMethods requestedMethods;
230 QBluetoothDeviceDiscoveryAgent *q_ptr;