From 576cdf8ec66e15efe7e306199442465addd7c9d9 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 17 Jan 2014 13:10:32 +0100 Subject: Improve QBluetoothServiceDiscoveryAgent documentation [ChangeLog][QtBluetooth][QBluetoothServiceDiscoveryAgent] The QBluetoothServiceDiscoveryAgent class documentation has been improved. Change-Id: I5472e9ceda45d9bcf0634b5bf2cecf265986bc10 Reviewed-by: Fabian Bumberger Reviewed-by: Aaron McCarthy --- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 50 +++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) (limited to 'src/bluetooth/qbluetoothservicediscoveryagent.cpp') diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index 2d1c6709..a1a9378c 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE /*! \fn QBluetoothServiceDiscoveryAgent::finished() - This signal is emitted when Bluetooth service discovery completes. This signal will even + This signal is emitted when the Bluetooth service discovery completes. This signal will even be emitted when an error occurred during the service discovery. */ @@ -123,7 +123,7 @@ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(QObject *parent /*! Constructs a new QBluetoothServiceDiscoveryAgent for \a deviceAdapter and with \a parent. - If \a deviceAdapter is null, the default adapter will be used. + If \a deviceAdapter is default constructed, the local default adapter will be used. */ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent) : QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(deviceAdapter)) @@ -144,6 +144,13 @@ QBluetoothServiceDiscoveryAgent::~QBluetoothServiceDiscoveryAgent() /*! Returns the list of all discovered services. + + This list of services accumulates newly discovered services from multiple calls + to \l start(). Unless \l clear() is called the list cannot decrease in size. This implies + that if a remote Bluetooth device moves out of range in between two subsequent calls + to \l start() the list may contain stale entries. + + \sa clear() */ QList QBluetoothServiceDiscoveryAgent::discoveredServices() const { @@ -194,10 +201,15 @@ QList QBluetoothServiceDiscoveryAgent::uuidFilter() const } /*! - Sets remote device address to \a address. If \a address is null, services will be discovered - on all contactable Bluetooth devices. A new remote address can only be set while there is - no service discovery in progress; otherwise this function returns false. + Sets the remote device address to \a address. If \a address is default constructed, + services will be discovered on all contactable Bluetooth devices. A new remote + address can only be set while there is no service discovery in progress; otherwise + this function returns false. + + On some platforms such as Blackberry the service discovery might lead to pairing requests. + Therefore it is not recommended to do service discoveries on all devices. + \sa remoteAddress() */ bool QBluetoothServiceDiscoveryAgent::setRemoteAddress(const QBluetoothAddress &address) { @@ -211,9 +223,10 @@ bool QBluetoothServiceDiscoveryAgent::setRemoteAddress(const QBluetoothAddress & } /*! - Returns the remote device address. If setRemoteAddress is not called, the function - will return default QBluetoothAddress. + Returns the remote device address. If \l setRemoteAddress() is not called, the function + will return a default constructed \l QBluetoothAddress. + \sa setRemoteAddress() */ QBluetoothAddress QBluetoothServiceDiscoveryAgent::remoteAddress() const { @@ -246,7 +259,8 @@ void QBluetoothServiceDiscoveryAgent::start(DiscoveryMode mode) } /*! - Stops service discovery. + Stops the service discovery process. The \l canceled() signal will be emitted once + the search has stopped. */ void QBluetoothServiceDiscoveryAgent::stop() { @@ -266,7 +280,9 @@ void QBluetoothServiceDiscoveryAgent::stop() } /*! - Clears the results of a previous service discovery. + Clears the results of previous service discoveries. + + \sa discoveredServices() */ void QBluetoothServiceDiscoveryAgent::clear() { @@ -278,7 +294,8 @@ void QBluetoothServiceDiscoveryAgent::clear() } /*! - Returns true if service discovery is currently active, otherwise returns false. + Returns \c true if the service discovery is currently active; otherwise returns \c false. + An active discovery can be stopped by calling \l stop(). */ bool QBluetoothServiceDiscoveryAgent::isActive() const { @@ -288,9 +305,9 @@ bool QBluetoothServiceDiscoveryAgent::isActive() const } /*! - Returns the type of error that last occurred. If service discovery is done - on a signle address it will return errors that occured while trying to discover - services on that device. If the alternate constructor is used and devices are + Returns the type of error that last occurred. If the service discovery is done + for a single \l remoteAddress() it will return errors that occurred while trying to discover + services on that device. If the \l remoteAddress() is not set and devices are discovered by a scan, errors during service discovery on individual devices are not saved and no signals are emitted. In this case, errors are fairly normal as some devices may not respond to discovery or @@ -306,8 +323,8 @@ QBluetoothServiceDiscoveryAgent::Error QBluetoothServiceDiscoveryAgent::error() } /*! - Returns a human-readable description of the last error that occurred during - service discovery on a single device. + Returns a human-readable description of the last error that occurred during the + service discovery. */ QString QBluetoothServiceDiscoveryAgent::errorString() const { @@ -318,7 +335,8 @@ QString QBluetoothServiceDiscoveryAgent::errorString() const /*! \fn QBluetoothServiceDiscoveryAgent::canceled() - Signals the cancellation of the service discovery. + + This signal is triggered when the service discovery was canceled via a call to \l stop(). */ -- cgit v1.2.1 From 1f33f347fad40f71fa89110c084880a81db1d15a Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 17 Jan 2014 13:37:35 +0100 Subject: Do not clear result lists while the SDP search is ongoing. Or bad things will happen... Change-Id: I7df3925ff5d15f3f904f4dd38e24b247ec151fd1 Reviewed-by: Fabian Bumberger Reviewed-by: Aaron McCarthy --- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/bluetooth/qbluetoothservicediscoveryagent.cpp') diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index a1a9378c..87ccb108 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -280,7 +280,8 @@ void QBluetoothServiceDiscoveryAgent::stop() } /*! - Clears the results of previous service discoveries. + Clears the results of previous service discoveries and resets \l uuidFilter(). + This function does nothing during an ongoing service discovery (see \l isActive()). \sa discoveredServices() */ @@ -288,6 +289,10 @@ void QBluetoothServiceDiscoveryAgent::clear() { Q_D(QBluetoothServiceDiscoveryAgent); + //don't clear the list while the search is ongoing + if (isActive()) + return; + d->discoveredDevices.clear(); d->discoveredServices.clear(); d->uuidFilter.clear(); -- cgit v1.2.1 From 5254e62e1898cffe397ecd0b0c8be43213e5b4e8 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 21 Jan 2014 16:00:01 +0100 Subject: Stop SDP search if QML Model is turned off So far, we only ever disabled the device search. If a SDP discovery was running and we changed to device discovery the SDP discovery kept running in the background. Change-Id: I5f2cf88ecf7f9b5cfe2608e0ceda366b552982e5 Reviewed-by: Fabian Bumberger --- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/bluetooth/qbluetoothservicediscoveryagent.cpp') diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index 87ccb108..beaa3503 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -266,6 +266,9 @@ void QBluetoothServiceDiscoveryAgent::stop() { Q_D(QBluetoothServiceDiscoveryAgent); + if (!isActive()) + return; + switch (d->discoveryState()) { case QBluetoothServiceDiscoveryAgentPrivate::DeviceDiscovery: d->stopDeviceDiscovery(); -- cgit v1.2.1