The QBluetoothServiceDiscoveryAgent class provides an API for querying the services provided by a Bluetooth device. More...
#include <QBluetoothServiceDiscoveryAgent>
Inherits QObject.
enum | DiscoveryMode { MinimalDiscovery, FullDiscovery } |
enum | Error { NoError, Canceled, DeviceDiscoveryError, UnknownError } |
QBluetoothServiceDiscoveryAgent ( QObject * parent = 0 ) | |
QBluetoothServiceDiscoveryAgent ( const QBluetoothAddress & remoteAddress, QObject * parent = 0 ) | |
QList<QBluetoothServiceInfo> | discoveredServices () const |
Error | error () const |
QString | errorString () const |
bool | isActive () const |
void | setUuidFilter ( const QList<QBluetoothUuid> & uuids ) |
void | setUuidFilter ( const QBluetoothUuid & uuid ) |
QList<QBluetoothUuid> | uuidFilter () const |
void | clear () |
void | start ( DiscoveryMode mode = MinimalDiscovery ) |
void | stop () |
void | error ( QBluetoothServiceDiscoveryAgent::Error error ) |
void | finished () |
void | serviceDiscovered ( const QBluetoothServiceInfo & info ) |
The QBluetoothServiceDiscoveryAgent class provides an API for querying the services provided by a Bluetooth device.
To query the services provided by all contactable Bluetooth devices create an instance of QBluetoothServiceDiscoveryAgent, connect to either the serviceDiscovered() or finished() signals and call start().
QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
connect(discoveryAgent, SIGNAL(serviceDiscovered(const QBluetoothServiceInfo&)),
this, SLOT(serviceDiscovered(const QBluetoothServiceInfo&)));
// Automatically delete agent when service discovery finishes.
connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deleteLater()));
discoveryAgent->start();
By default a minimal service discovery is performed. In this mode the QBluetotohServiceInfo objects returned are guaranteed to contain only device and service UUID information. Depending on platform and device capabilities other service information may also be available. For most use cases this is adequate as QBluetoothSocket::connectToService() will perform additional discovery if required. If full service information is required pass FullDiscovery as the discoveryMode parameter to start().
This enum describes the service discovery mode.
Constant | Value | Description |
---|---|---|
QBluetoothServiceDiscoveryAgent::MinimalDiscovery | 0 | Performs a minimal service discovery. The QBluetoothServiceInfo objects returned may be incomplete and are only guaranteed to contain device and service UUID information. |
QBluetoothServiceDiscoveryAgent::FullDiscovery | 1 | Performs a full service discovery. |
This enum describes errors that can occur during service discovery.
Constant | Value | Description |
---|---|---|
QBluetoothServiceDiscoveryAgent::NoError | 0 | No error. |
QBluetoothServiceDiscoveryAgent::Canceled | 1 | Service discovery was canceled. |
QBluetoothServiceDiscoveryAgent::DeviceDiscoveryError | 2 | Error occurred during device discovery. |
QBluetoothServiceDiscoveryAgent::UnknownError | 100 | An unidentified error occurred. |
Constructs a new QBluetoothServiceDiscoveryAgent with parent.
Constructs a new QBluetoothServiceDiscoveryAgent for remoteAddress and with parent.
If remoteAddress is invalid the agent will discover services on all contactable Bluetooth devices.
Clears the results of a previous service discovery.
Returns the list of all discovered services.
Returns the type of error that last occurred.
This signal is emitted when an error occurs. The error parameter describes the error that occurred.
Returns a human-readable description of the last error that occurred.
This signal is emitted when Bluetooth service discovery completes.
Returns true if service discovery is currently active, otherwise returns false.
This signal is emitted when the Bluetooth service described by info is discovered.
Sets the UUID filter to uuids. Only services matching the UUIDs in uuids will be returned.
An empty UUID list is equivalent to a list containing only QBluetoothUuid::PublicBrowseGroup.
See also uuidFilter().
This is an overloaded member function, provided for convenience.
Sets the UUID filter to a list containing the single element uuid.
See also uuidFilter().
Starts service discovery. mode specifies the type of service discovery to perform.
Stops service discovery.
Returns the UUID filter.
See also setUuidFilter().