The QBluetoothDeviceDiscoveryAgent class provides an API for discovering nearby Bluetooth devices. More...
#include <QBluetoothDeviceDiscoveryAgent>
Inherits: QObject.
This class was introduced in Qt Mobility 1.2.
enum | Error { NoError, PoweredOff, IOFailure, UnknownError } |
enum | InquiryType { GeneralUnlimitedInquiry, LimitedInquiry } |
QBluetoothDeviceDiscoveryAgent ( QObject * parent = 0 ) | |
~QBluetoothDeviceDiscoveryAgent () | |
QList<QBluetoothDeviceInfo> | discoveredDevices () const |
Error | error () const |
QString | errorString () const |
QBluetoothDeviceDiscoveryAgent::InquiryType | inquiryType () const |
bool | isActive () const |
void | setInquiryType ( QBluetoothDeviceDiscoveryAgent::InquiryType type ) |
void | start () |
void | stop () |
void | canceled () |
void | deviceDiscovered ( const QBluetoothDeviceInfo & info ) |
void | error ( QBluetoothDeviceDiscoveryAgent::Error error ) |
void | finished () |
The QBluetoothDeviceDiscoveryAgent class provides an API for discovering nearby Bluetooth devices.
To discovery nearby Bluetooth devices create an instance of QBluetoothDeviceDiscoveryAgent, connect to either the deviceDiscovered() or finished() signals and call start().
QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), this, SLOT(deviceDiscovered(const QBluetoothDeviceInfo&))); // Automatically delete agent when device discovery finishes. connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deleteLater())); discoveryAgent->start();
To retrieve results asynchronously connect to the deviceDiscovered() signal. To get a list of all discovered devices call discoveredDevices() after the finished() signal is emitted.
Indicates all possible error conditions found during Bluetooth device discovery.
Constant | Value | Description |
---|---|---|
QBluetoothDeviceDiscoveryAgent::NoError | 0 | No error has occurred. |
QBluetoothDeviceDiscoveryAgent::PoweredOff | 2 | Bluetooth adaptor is powered off, power it on before doing discovery. |
QBluetoothDeviceDiscoveryAgent::IOFailure | 1 | Writing or reading from device resulted in an error. |
QBluetoothDeviceDiscoveryAgent::UnknownError | 100 | An unknown error has occurred. |
This enum describes the inquiry type used when discovering Bluetooth devices.
Constant | Value | Description |
---|---|---|
QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry | 0 | A general unlimited inquiry. Discovers all visible Bluetooth devices in the local vicinity. |
QBluetoothDeviceDiscoveryAgent::LimitedInquiry | 1 | A limited inquiry. Only discovers devices that are in limited inquiry mode. Not all platforms support limited inquiry. If limited inquiry is requested on a platform that does not support it general unlimited inquiry we be used instead. Setting LimitedInquiry is useful for 2 games that wish to find each other quickly. The phone scans for devices in LimitedInquiry and Service Discovery is only done on one or two devices speeding up the service scan. After the game has connected the device returns to GeneralUnilimitedInquiry |
This property holds type of inquiry scan to use when discovering devices.
This property affects the type of inquiry scan which is performed when discovering devices.
By default, this property is set to GeneralUnlimitedInquiry.
Not all platforms support LimitedInquiry.
Access functions:
QBluetoothDeviceDiscoveryAgent::InquiryType | inquiryType () const |
void | setInquiryType ( QBluetoothDeviceDiscoveryAgent::InquiryType type ) |
See also InquiryType.
Constructs a new Bluetooth device discovery agent with parent parent.
Destructor for ~QBluetoothDeviceDiscoveryAgent()
This signal is emitted when device discovery is aborted by a call to stop().
This signal is emitted when the Bluetooth device described by info is discovered.
Returns a list of all discovered Bluetooth devices.
Returns the last error which has occurred.
This signal is emitted when an error occurs during Bluetooth device discovery.
See also error() and errorString().
Returns a human-readable description of the last error that occurred.
This signal is emitted when Bluetooth device discovery completes.
Returns true if the agent is currently discovering Bluetooth devices, other returns false.
Starts Bluetooth device discovery, if it is not already started.
The deviceDiscovered() signal is emitted as each device is discovered. The finished() signal is emitted once device discovery is complete.
Stops Bluetooth device discovery. The cancel() signal is emitted once the device discovery is canceled. start() maybe called before the cancel signal is received. Once start() has been called the cancel signal from the prior discovery will be silently discarded.