QBluetoothDeviceInfo Class

The QBluetoothDeviceInfo class stores information about the Bluetooth device. More...

Header: #include <QBluetoothDeviceInfo>
qmake: QT += bluetooth

Public Types

enum CoreConfiguration { UnknownCoreConfiguration, BaseRateCoreConfiguration, BaseRateAndLowEnergyCoreConfiguration, LowEnergyCoreConfiguration }
flags CoreConfigurations
enum class Field { None, RSSI, ManufacturerData, ServiceData, All }
flags Fields
enum MajorDeviceClass { MiscellaneousDevice, ComputerDevice, PhoneDevice, NetworkDevice, AudioVideoDevice, …, UncategorizedDevice }
enum MinorAudioVideoClass { UncategorizedAudioVideoDevice, WearableHeadsetDevice, HandsFreeDevice, Microphone, Loudspeaker, …, GamingDevice }
enum MinorComputerClass { UncategorizedComputer, DesktopComputer, ServerComputer, LaptopComputer, HandheldClamShellComputer, …, WearableComputer }
enum MinorHealthClass { UncategorizedHealthDevice, HealthBloodPressureMonitor, HealthThermometer, HealthWeightScale, HealthGlucoseMeter, …, HealthStepCounter }
enum MinorImagingClass { UncategorizedImagingDevice, ImageDisplay, ImageCamera, ImageScanner, ImagePrinter }
enum MinorMiscellaneousClass { UncategorizedMiscellaneous }
enum MinorNetworkClass { NetworkFullService, NetworkLoadFactorOne, NetworkLoadFactorTwo, NetworkLoadFactorThree, NetworkLoadFactorFour, …, NetworkNoService }
enum MinorPeripheralClass { UncategorizedPeripheral, KeyboardPeripheral, PointingDevicePeripheral, KeyboardWithPointingDevicePeripheral, JoystickPeripheral, …, CardReaderPeripheral }
enum MinorPhoneClass { UncategorizedPhone, CellularPhone, CordlessPhone, SmartPhone, WiredModemOrVoiceGatewayPhone, CommonIsdnAccessPhone }
enum MinorToyClass { UncategorizedToy, ToyRobot, ToyVehicle, ToyDoll, ToyController, ToyGame }
enum MinorWearableClass { UncategorizedWearableDevice, WearableWristWatch, WearablePager, WearableJacket, WearableHelmet, WearableGlasses }
enum ServiceClass { NoService, PositioningService, NetworkingService, RenderingService, CapturingService, …, AllServices }
flags ServiceClasses

Public Functions

QBluetoothDeviceInfo()
QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name, quint32 classOfDevice)
QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name, quint32 classOfDevice)
QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other)
~QBluetoothDeviceInfo()
QBluetoothAddress address() const
QBluetoothDeviceInfo::CoreConfigurations coreConfigurations() const
QBluetoothUuid deviceUuid() const
bool isCached() const
bool isValid() const
QBluetoothDeviceInfo::MajorDeviceClass majorDeviceClass() const
QMultiHash<quint16, QByteArray> manufacturerData() const
QByteArray manufacturerData(quint16 manufacturerId) const
QList<quint16> manufacturerIds() const
quint8 minorDeviceClass() const
QString name() const
qint16 rssi() const
QBluetoothDeviceInfo::ServiceClasses serviceClasses() const
(since 6.3) QMultiHash<QBluetoothUuid, QByteArray> serviceData() const
(since 6.3) QByteArray serviceData(const QBluetoothUuid &serviceId) const
(since 6.3) QList<QBluetoothUuid> serviceIds() const
(since 6.0) QList<QBluetoothUuid> serviceUuids() const
void setCached(bool cached)
void setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs)
void setDeviceUuid(const QBluetoothUuid &uuid)
bool setManufacturerData(quint16 manufacturerId, const QByteArray &data)
(since 6.2) void setName(const QString &name)
void setRssi(qint16 signal)
(since 6.3) bool setServiceData(const QBluetoothUuid &serviceId, const QByteArray &data)
void setServiceUuids(const QList<QBluetoothUuid> &uuids)
QBluetoothDeviceInfo &operator=(const QBluetoothDeviceInfo &other)
bool operator!=(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)
bool operator==(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)

Detailed Description

QBluetoothDeviceInfo provides information about a Bluetooth device's name, address and class of device.

Member Type Documentation

enum QBluetoothDeviceInfo::CoreConfiguration
flags QBluetoothDeviceInfo::CoreConfigurations

This enum describes the configuration of the device.

ConstantValueDescription
QBluetoothDeviceInfo::UnknownCoreConfiguration0x0The type of the Bluetooth device cannot be determined.
QBluetoothDeviceInfo::BaseRateCoreConfiguration0x02The device is a standard Bluetooth device.
QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration0x03The device is a Bluetooth Smart device with support for standard and Low Energy device.
QBluetoothDeviceInfo::LowEnergyCoreConfiguration0x01The device is a Bluetooth Low Energy device.

The CoreConfigurations type is a typedef for QFlags<CoreConfiguration>. It stores an OR combination of CoreConfiguration values.

enum class QBluetoothDeviceInfo::Field
flags QBluetoothDeviceInfo::Fields

This enum is used in conjuntion with the QBluetoothDeviceDiscoveryAgent::deviceUpdated() signal and indicates the field that changed.

ConstantValueDescription
QBluetoothDeviceInfo::Field::None0x0000None of the values changed.
QBluetoothDeviceInfo::Field::RSSI0x0001The rssi() value of the device changed.
QBluetoothDeviceInfo::Field::ManufacturerData0x0002The manufacturerData() field changed
QBluetoothDeviceInfo::Field::ServiceData0x0004The serviceData() field changed
QBluetoothDeviceInfo::Field::All0x7fffMatches every possible field.

The Fields type is a typedef for QFlags<Field>. It stores an OR combination of Field values.

enum QBluetoothDeviceInfo::MajorDeviceClass

This enum describes a Bluetooth device's major device class.

ConstantValueDescription
QBluetoothDeviceInfo::MiscellaneousDevice0A miscellaneous device.
QBluetoothDeviceInfo::ComputerDevice1A computer device or PDA.
QBluetoothDeviceInfo::PhoneDevice2A telephone device.
QBluetoothDeviceInfo::NetworkDevice3A device that provides access to a local area network (since Qt 5.13).
QBluetoothDeviceInfo::AudioVideoDevice4A device capable of playback or capture of audio and/or video.
QBluetoothDeviceInfo::PeripheralDevice5A peripheral device such as a keyboard, mouse, and so on.
QBluetoothDeviceInfo::ImagingDevice6An imaging device such as a display, printer, scanner or camera.
QBluetoothDeviceInfo::WearableDevice7A wearable device such as a watch or pager.
QBluetoothDeviceInfo::ToyDevice8A toy.
QBluetoothDeviceInfo::HealthDevice9A health reated device such as heart rate or temperature monitor.
QBluetoothDeviceInfo::UncategorizedDevice31A device that does not fit into any of the other device classes.

enum QBluetoothDeviceInfo::MinorAudioVideoClass

This enum describes the minor device classes for audio/video devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedAudioVideoDevice0An uncategorized audio/video device.
QBluetoothDeviceInfo::WearableHeadsetDevice1A wearable headset device.
QBluetoothDeviceInfo::HandsFreeDevice2A handsfree device.
QBluetoothDeviceInfo::Microphone4A microphone.
QBluetoothDeviceInfo::Loudspeaker5A loudspeaker.
QBluetoothDeviceInfo::Headphones6Headphones.
QBluetoothDeviceInfo::PortableAudioDevice7A portable audio device.
QBluetoothDeviceInfo::CarAudio8A car audio device.
QBluetoothDeviceInfo::SetTopBox9A settop box.
QBluetoothDeviceInfo::HiFiAudioDevice10A HiFi audio device.
QBluetoothDeviceInfo::Vcr11A video cassette recorder.
QBluetoothDeviceInfo::VideoCamera12A video camera.
QBluetoothDeviceInfo::Camcorder13A video camera.
QBluetoothDeviceInfo::VideoMonitor14A video monitor.
QBluetoothDeviceInfo::VideoDisplayAndLoudspeaker15A video display with built-in loudspeaker.
QBluetoothDeviceInfo::VideoConferencing16A video conferencing device.
QBluetoothDeviceInfo::GamingDevice18A gaming device.

enum QBluetoothDeviceInfo::MinorComputerClass

This enum describes the minor device classes for computer devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedComputer0An uncategorized computer device.
QBluetoothDeviceInfo::DesktopComputer1A desktop computer.
QBluetoothDeviceInfo::ServerComputer2A server computer.
QBluetoothDeviceInfo::LaptopComputer3A laptop computer.
QBluetoothDeviceInfo::HandheldClamShellComputer4A clamshell handheld computer or PDA.
QBluetoothDeviceInfo::HandheldComputer5A handheld computer or PDA.
QBluetoothDeviceInfo::WearableComputer6A wearable computer.

enum QBluetoothDeviceInfo::MinorHealthClass

This enum describes the minor device classes for health devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedHealthDevice0An uncategorized health device.
QBluetoothDeviceInfo::HealthBloodPressureMonitor0x1A blood pressure monitor.
QBluetoothDeviceInfo::HealthThermometer0x2A Thermometer.
QBluetoothDeviceInfo::HealthWeightScale0x3A scale.
QBluetoothDeviceInfo::HealthGlucoseMeter0x4A glucose meter.
QBluetoothDeviceInfo::HealthPulseOximeter0x5A blood oxygen saturation meter.
QBluetoothDeviceInfo::HealthDataDisplay0x7A data display.
QBluetoothDeviceInfo::HealthStepCounter0x8A pedometer.

enum QBluetoothDeviceInfo::MinorImagingClass

This enum describes the minor device classes for imaging devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedImagingDevice0An uncategorized imaging device.
QBluetoothDeviceInfo::ImageDisplay0x04A device capable of displaying images.
QBluetoothDeviceInfo::ImageCamera0x08A camera.
QBluetoothDeviceInfo::ImageScanner0x10An image scanner.
QBluetoothDeviceInfo::ImagePrinter0x20A printer.

enum QBluetoothDeviceInfo::MinorMiscellaneousClass

This enum describes the minor device classes for miscellaneous Bluetooth devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedMiscellaneous0An uncategorized miscellaneous device.

enum QBluetoothDeviceInfo::MinorNetworkClass

This enum describes the minor device classes for local area network access devices. Local area network access devices use the minor device class to specify the current network utilization.

ConstantValueDescription
QBluetoothDeviceInfo::NetworkFullService0x00100% of the total bandwidth is available.
QBluetoothDeviceInfo::NetworkLoadFactorOne0x080 - 17% of the total bandwidth is currently being used.
QBluetoothDeviceInfo::NetworkLoadFactorTwo0x1017 - 33% of the total bandwidth is currently being used.
QBluetoothDeviceInfo::NetworkLoadFactorThree0x1833 - 50% of the total bandwidth is currently being used.
QBluetoothDeviceInfo::NetworkLoadFactorFour0x2050 - 67% of the total bandwidth is currently being used.
QBluetoothDeviceInfo::NetworkLoadFactorFive0x2867 - 83% of the total bandwidth is currently being used.
QBluetoothDeviceInfo::NetworkLoadFactorSix0x3083 - 99% of the total bandwidth is currently being used.
QBluetoothDeviceInfo::NetworkNoService0x38No network service available.

enum QBluetoothDeviceInfo::MinorPeripheralClass

This enum describes the minor device classes for peripheral devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedPeripheral0An uncategorized peripheral device.
QBluetoothDeviceInfo::KeyboardPeripheral0x10A keyboard.
QBluetoothDeviceInfo::PointingDevicePeripheral0x20A pointing device, for example a mouse.
QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral0x30A keyboard with built-in pointing device.
QBluetoothDeviceInfo::JoystickPeripheral0x01A joystick.
QBluetoothDeviceInfo::GamepadPeripheral0x02A game pad.
QBluetoothDeviceInfo::RemoteControlPeripheral0x03A remote control.
QBluetoothDeviceInfo::SensingDevicePeripheral0x04A sensing device.
QBluetoothDeviceInfo::DigitizerTabletPeripheral0x05A digitizer tablet peripheral.
QBluetoothDeviceInfo::CardReaderPeripheral0x06A card reader peripheral.

enum QBluetoothDeviceInfo::MinorPhoneClass

This enum describes the minor device classes for phone devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedPhone0An uncategorized phone device.
QBluetoothDeviceInfo::CellularPhone1A cellular phone.
QBluetoothDeviceInfo::CordlessPhone2A cordless phone.
QBluetoothDeviceInfo::SmartPhone3A smart phone.
QBluetoothDeviceInfo::WiredModemOrVoiceGatewayPhone4A wired modem or voice gateway.
QBluetoothDeviceInfo::CommonIsdnAccessPhone5A device that provides ISDN access.

enum QBluetoothDeviceInfo::MinorToyClass

This enum describes the minor device classes for toy devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedToy0An uncategorized toy.
QBluetoothDeviceInfo::ToyRobot1A toy robot.
QBluetoothDeviceInfo::ToyVehicle2A toy vehicle.
QBluetoothDeviceInfo::ToyDoll3A toy doll or action figure.
QBluetoothDeviceInfo::ToyController4A controller.
QBluetoothDeviceInfo::ToyGame5A game.

enum QBluetoothDeviceInfo::MinorWearableClass

This enum describes the minor device classes for wearable devices.

ConstantValueDescription
QBluetoothDeviceInfo::UncategorizedWearableDevice0An uncategorized wearable device.
QBluetoothDeviceInfo::WearableWristWatch1A wristwatch.
QBluetoothDeviceInfo::WearablePager2A pager.
QBluetoothDeviceInfo::WearableJacket3A jacket.
QBluetoothDeviceInfo::WearableHelmet4A helmet.
QBluetoothDeviceInfo::WearableGlasses5A pair of glasses.

enum QBluetoothDeviceInfo::ServiceClass
flags QBluetoothDeviceInfo::ServiceClasses

This enum describes the service class of the Bluetooth device. The service class is used as a rudimentary form of service discovery. It is meant to provide a list of the types of services that the device might provide.

ConstantValueDescription
QBluetoothDeviceInfo::NoService0x0000The device does not provide any services.
QBluetoothDeviceInfo::PositioningService0x0001The device provides positioning services.
QBluetoothDeviceInfo::NetworkingService0x0002The device provides networking services.
QBluetoothDeviceInfo::RenderingService0x0004The device provides rendering services.
QBluetoothDeviceInfo::CapturingService0x0008The device provides capturing services.
QBluetoothDeviceInfo::ObjectTransferService0x0010The device provides object transfer services.
QBluetoothDeviceInfo::AudioService0x0020The device provides audio services.
QBluetoothDeviceInfo::TelephonyService0x0040The device provides telephony services.
QBluetoothDeviceInfo::InformationService0x0080The device provides information services.
QBluetoothDeviceInfo::AllServices0x07ffThe device provides services of all types.

The ServiceClasses type is a typedef for QFlags<ServiceClass>. It stores an OR combination of ServiceClass values.

Member Function Documentation

QBluetoothDeviceInfo::QBluetoothDeviceInfo()

Constructs an invalid QBluetoothDeviceInfo object.

QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name, quint32 classOfDevice)

Constructs a QBluetoothDeviceInfo object with Bluetooth address address, device name name and the encoded class of device classOfDevice.

The classOfDevice parameter is encoded in the following format

BitsSizeDescription
0 - 12Unused, set to 0.
2 - 76Minor device class.
8 - 125Major device class.
13 - 2311Service class.

QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name, quint32 classOfDevice)

Constructs a QBluetoothDeviceInfo object with unique uuid, device name name and the encoded class of device classOfDevice.

This constructor is required for Low Energy devices on macOS and iOS. CoreBluetooth API hides addresses and provides unique UUIDs to identify a device. This UUID is not the same thing as a service UUID and is required to work later with CoreBluetooth API and discovered devices.

QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other)

Constructs a QBluetoothDeviceInfo that is a copy of other.

[noexcept] QBluetoothDeviceInfo::~QBluetoothDeviceInfo()

Destroys the QBluetoothDeviceInfo.

QBluetoothAddress QBluetoothDeviceInfo::address() const

Returns the address of the device.

Note: On iOS and macOS this address is invalid. Instead deviceUuid() should be used. Those two platforms do not expose Bluetooth addresses for found Bluetooth devices and utilize unique device identifiers.

See also deviceUuid().

QBluetoothDeviceInfo::CoreConfigurations QBluetoothDeviceInfo::coreConfigurations() const

Returns the configuration of the device. If device configuration is not set, basic rate device configuration will be returned.

See also setCoreConfigurations().

QBluetoothUuid QBluetoothDeviceInfo::deviceUuid() const

Returns a unique identifier for a Bluetooth device without an address.

In general, this uuid is invalid on every platform but macOS and iOS. It is used as a workaround for those two platforms as they do not provide Bluetooth addresses for found Bluetooth Low Energy devices. Every other platform uses address() instead.

See also setDeviceUuid().

bool QBluetoothDeviceInfo::isCached() const

Returns true if the QBluetoothDeviceInfo object is created from cached data.

bool QBluetoothDeviceInfo::isValid() const

Returns true if the QBluetoothDeviceInfo object is valid, otherwise returns false.

QBluetoothDeviceInfo::MajorDeviceClass QBluetoothDeviceInfo::majorDeviceClass() const

Returns the major device class of the device.

QMultiHash<quint16, QByteArray> QBluetoothDeviceInfo::manufacturerData() const

Returns the complete set of all manufacturer data from advertisement packets.

Some devices may provide multiple manufacturer data entries per manufacturer ID. An example might be a Bluetooth Low Energy device that sends a different manufacturer data via advertisement packets and scan response packets respectively. Therefore the returned hash table may have multiple entries per manufacturer ID or hash key.

See also setManufacturerData.

QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const

Returns the data associated with the given manufacturerId.

Manufacturer data is defined by the Supplement to the Bluetooth Core Specification and consists of two segments:

  • Manufacturer specific identifier code from the Assigned Numbers Company Identifiers document
  • Sequence of arbitrary data octets

The interpretation of the data octets is defined by the manufacturer specified by the company identifier.

Note: The remote device may provide multiple data entries per manufacturerId. This function only returns the first entry. If all entries are needed use manufacturerData() which returns a multi hash.

See also manufacturerIds() and setManufacturerData().

QList<quint16> QBluetoothDeviceInfo::manufacturerIds() const

Returns all manufacturer IDs from advertisement packets attached to this device information.

See also manufacturerData() and setManufacturerData().

quint8 QBluetoothDeviceInfo::minorDeviceClass() const

Returns the minor device class of the device. The actual information is context dependent on the value of majorDeviceClass().

See also MinorAudioVideoClass, MinorComputerClass, MinorHealthClass, MinorImagingClass, MinorMiscellaneousClass, MinorNetworkClass, MinorPeripheralClass, MinorPhoneClass, MinorToyClass, and MinorWearableClass.

QString QBluetoothDeviceInfo::name() const

Returns the name assigned to the device.

See also setName().

qint16 QBluetoothDeviceInfo::rssi() const

Returns the signal strength when the device was last scanned

See also setRssi().

QBluetoothDeviceInfo::ServiceClasses QBluetoothDeviceInfo::serviceClasses() const

Returns the service class of the device.

[since 6.3] QMultiHash<QBluetoothUuid, QByteArray> QBluetoothDeviceInfo::serviceData() const

Returns the complete set of all service data from advertisement packets.

Some devices may provide multiple service data entries per service data ID. An example might be a Bluetooth Low Energy device that sends a different service data via advertisement packets and scan response packets respectively. Therefore the returned hash table may have multiple entries per service data ID or hash key.

This function was introduced in Qt 6.3.

See also setServiceData.

[since 6.3] QByteArray QBluetoothDeviceInfo::serviceData(const QBluetoothUuid &serviceId) const

Returns the data associated with the given serviceId.

Service data is defined by the Supplement to the Bluetooth Core Specification and consists of two segments:

  • Service UUID
  • Sequence of arbitrary data octets

Note: The remote device may provide multiple data entries per serviceId. This function only returns the first entry. If all entries are needed use serviceData() which returns a multi hash.

This function was introduced in Qt 6.3.

See also serviceIds() and setServiceData().

[since 6.3] QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceIds() const

Returns all service data IDs from advertisement packets attached to this device information.

This function was introduced in Qt 6.3.

See also serviceData() and setServiceData().

[since 6.0] QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids() const

Returns the list of service UUIDs supported by the device. Most commonly this list of UUIDs represents custom service UUIDs or a service UUID value specified by QBluetoothUuid::ServiceClassUuid.

This function was introduced in Qt 6.0.

See also setServiceUuids() and serviceUuids().

void QBluetoothDeviceInfo::setCached(bool cached)

Used by the system to set the cached flag if the QBluetoothDeviceInfo is created from cached data. Cached information may not be as accurate as data read from an active device.

See also isCached().

void QBluetoothDeviceInfo::setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs)

Sets the CoreConfigurations of the device to coreConfigs. This will help to make a difference between regular and Low Energy devices.

See also coreConfigurations().

void QBluetoothDeviceInfo::setDeviceUuid(const QBluetoothUuid &uuid)

Sets the unique identifier uuid for Bluetooth devices, that do not have addresses. This happens on macOS and iOS, where the CoreBluetooth API hides addresses, but provides UUIDs to identify devices/peripherals.

This uuid is invalid on any other platform.

See also deviceUuid().

bool QBluetoothDeviceInfo::setManufacturerData(quint16 manufacturerId, const QByteArray &data)

Sets the advertised manufacturer data for the given manufacturerId. Returns true if it was inserted, false if it was already known.

Since Qt 5.14, different values for data and the same manufacturerId no longer replace each other but are accumulated for the duration of a device scan.

See also manufacturerData.

[since 6.2] void QBluetoothDeviceInfo::setName(const QString &name)

Sets the name of the device.

This function was introduced in Qt 6.2.

See also name().

void QBluetoothDeviceInfo::setRssi(qint16 signal)

Set the signal strength value, used internally.

See also rssi().

[since 6.3] bool QBluetoothDeviceInfo::setServiceData(const QBluetoothUuid &serviceId, const QByteArray &data)

Sets the advertised service data for the given serviceId. Returns true if it was inserted, false if it was already known.

This function was introduced in Qt 6.3.

See also serviceData.

void QBluetoothDeviceInfo::setServiceUuids(const QList<QBluetoothUuid> &uuids)

Sets the list of service UUIDs to uuids.

See also serviceUuids().

QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo &other)

Makes a copy of the other and assigns it to this QBluetoothDeviceInfo object.

Related Non-Members

bool operator!=(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)

Returns true if the two QBluetoothDeviceInfo objects a and b are not equal.

bool operator==(const QBluetoothDeviceInfo &a, const QBluetoothDeviceInfo &b)

Returns true if the two QBluetoothDeviceInfo objects a and b are equal.