Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QBluetoothServiceInfo Class Reference

\inmodule QtBluetooth More...

#include <qbluetoothserviceinfo.h>

+ Collaboration diagram for QBluetoothServiceInfo:

Classes

class  Alternative
 \inmodule QtBluetooth More...
 
class  Sequence
 \inmodule QtBluetooth More...
 

Public Types

enum  AttributeId {
  ServiceRecordHandle = 0x0000 , ServiceClassIds = 0x0001 , ServiceRecordState = 0x0002 , ServiceId = 0x0003 ,
  ProtocolDescriptorList = 0x0004 , BrowseGroupList = 0x0005 , LanguageBaseAttributeIdList = 0x0006 , ServiceInfoTimeToLive = 0x0007 ,
  ServiceAvailability = 0x0008 , BluetoothProfileDescriptorList = 0x0009 , DocumentationUrl = 0x000A , ClientExecutableUrl = 0x000B ,
  IconUrl = 0x000C , AdditionalProtocolDescriptorList = 0x000D , PrimaryLanguageBase = 0x0100 , ServiceName = PrimaryLanguageBase + 0x0000 ,
  ServiceDescription = PrimaryLanguageBase + 0x0001 , ServiceProvider = PrimaryLanguageBase + 0x0002
}
 Bluetooth service attributes. More...
 
enum  Protocol { UnknownProtocol , L2capProtocol , RfcommProtocol }
 This enum describes the socket protocol used by the service. More...
 

Public Member Functions

 QBluetoothServiceInfo ()
 Construct a new invalid QBluetoothServiceInfo;.
 
 QBluetoothServiceInfo (const QBluetoothServiceInfo &other)
 Construct a new QBluetoothServiceInfo that is a copy of other.
 
 ~QBluetoothServiceInfo ()
 Destroys the QBluetoothServiceInfo object.
 
bool isValid () const
 Returns true if the QBluetoothServiceInfo object is valid, otherwise returns false.
 
bool isComplete () const
 Returns true if the QBluetoothServiceInfo object is considered complete, otherwise returns false.
 
void setDevice (const QBluetoothDeviceInfo &info)
 Sets the Bluetooth device that provides this service to device.
 
QBluetoothDeviceInfo device () const
 Returns the address of the Bluetooth device that provides this service.
 
void setAttribute (quint16 attributeId, const QVariant &value)
 Sets the attribute identified by attributeId to value.
 
void setAttribute (quint16 attributeId, const QBluetoothUuid &value)
 This is a convenience function.
 
void setAttribute (quint16 attributeId, const QBluetoothServiceInfo::Sequence &value)
 This is a convenience function.
 
void setAttribute (quint16 attributeId, const QBluetoothServiceInfo::Alternative &value)
 This is a convenience function.
 
QVariant attribute (quint16 attributeId) const
 Returns the value of the attribute attributeId.
 
QList< quint16attributes () const
 Returns a list of all attribute ids that the QBluetoothServiceInfo object has.
 
bool contains (quint16 attributeId) const
 Returns true if the QBluetoothServiceInfo object contains the attribute attributeId, otherwise returns false.
 
void removeAttribute (quint16 attributeId)
 Removes the attribute attributeId from the QBluetoothServiceInfo object.
 
void setServiceName (const QString &name)
 This is a convenience function.
 
QString serviceName () const
 This is a convenience function.
 
void setServiceDescription (const QString &description)
 This is a convenience function.
 
QString serviceDescription () const
 This is a convenience function.
 
void setServiceProvider (const QString &provider)
 This is a convenience function.
 
QString serviceProvider () const
 This is a convenience function.
 
QBluetoothServiceInfo::Protocol socketProtocol () const
 Returns the protocol that the QBluetoothServiceInfo object uses.
 
int protocolServiceMultiplexer () const
 This is a convenience function.
 
int serverChannel () const
 This is a convenience function.
 
QBluetoothServiceInfo::Sequence protocolDescriptor (QBluetoothUuid::ProtocolUuid protocol) const
 Returns the protocol parameters as a QBluetoothServiceInfo::Sequence for protocol protocol.
 
void setServiceAvailability (quint8 availability)
 This is a convenience function.
 
quint8 serviceAvailability () const
 This is a convenience function.
 
void setServiceUuid (const QBluetoothUuid &uuid)
 This is a convenience function.
 
QBluetoothUuid serviceUuid () const
 This is a convenience function.
 
QList< QBluetoothUuidserviceClassUuids () const
 Returns a list of UUIDs describing the service classes that this service conforms to.
 
QBluetoothServiceInfooperator= (const QBluetoothServiceInfo &other)
 Makes a copy of the other and assigns it to this QBluetoothServiceInfo object.
 
bool isRegistered () const
 Returns true if the service information is registered with the platform's Service Discovery Protocol (SDP) implementation, otherwise returns false.
 
bool registerService (const QBluetoothAddress &localAdapter=QBluetoothAddress())
 
bool unregisterService ()
 Unregisters this service with the platform's Service Discovery Protocol (SDP) implementation.
 

Protected Attributes

QSharedPointer< QBluetoothServiceInfoPrivated_ptr
 

Friends

QDebug operator<< (QDebug d, const QBluetoothServiceInfo &i)
 

Detailed Description

\inmodule QtBluetooth

The QBluetoothServiceInfo class enables access to the attributes of a Bluetooth service.

Since
5.2

QBluetoothServiceInfo provides information about a service offered by a Bluetooth device. In addition it can be used to register new services on the local device. Note that such a registration only affects the Bluetooth SDP entries. Any server listening for incoming connections (e.g an RFCOMM server) must be started before registerService() is called. Deregistration must happen in the reverse order.

QBluetoothServiceInfo is not a value type in the traditional sense. All copies of the same service info object share the same data as they do not detach upon changing them. This ensures that two copies can (de)register the same Bluetooth service.

On iOS, this class cannot be used because the platform does not expose an API which may permit access to QBluetoothServiceInfo related features.

Definition at line 24 of file qbluetoothserviceinfo.h.

Member Enumeration Documentation

◆ AttributeId

Bluetooth service attributes.

Please check the Bluetooth Core Specification for a more detailed description of these attributes.

\value ServiceRecordHandle Specifies a service record from which attributes can be retrieved. \value ServiceClassIds UUIDs of service classes that the service conforms to. The most common service classes are defined in (\l QBluetoothUuid::ServiceClassUuid) \value ServiceRecordState Attibute changes when any other service attribute is added, deleted or modified. \value ServiceId UUID that uniquely identifies the service. \value ProtocolDescriptorList List of protocols used by the service. The most common protocol Uuids are defined in \l QBluetoothUuid::ProtocolUuid \value BrowseGroupList List of browse groups the service is in. \value LanguageBaseAttributeIdList List of language base attribute IDs to support human-readable attributes. \value ServiceInfoTimeToLive Number of seconds for which the service record is expected to remain valid and unchanged. \value ServiceAvailability Value indicating the availability of the service. \value BluetoothProfileDescriptorList List of profiles to which the service conforms. \value DocumentationUrl URL that points to the documentation on the service.. \value ClientExecutableUrl URL that refers to the location of an application that can be used to utilize the service. \value IconUrl URL to the location of the icon representing the service. \value AdditionalProtocolDescriptorList Additional protocols used by the service. This attribute extends ProtocolDescriptorList. \value PrimaryLanguageBase Base index for primary language text descriptors. \value ServiceName Name of the Bluetooth service in the primary language. \value ServiceDescription Description of the Bluetooth service in the primary language. \value ServiceProvider Name of the company / entity that provides the Bluetooth service primary language.

Note
On Windows ServiceClassIds and ProtocolDescriptorList are automatically set to default values when a service is created. Manually setting values for these attributes will not work and might lead to unexpected results on this platform.
Enumerator
ServiceRecordHandle 
ServiceClassIds 
ServiceRecordState 
ServiceId 
ProtocolDescriptorList 
BrowseGroupList 
LanguageBaseAttributeIdList 
ServiceInfoTimeToLive 
ServiceAvailability 
BluetoothProfileDescriptorList 
DocumentationUrl 
ClientExecutableUrl 
IconUrl 
AdditionalProtocolDescriptorList 
PrimaryLanguageBase 
ServiceName 
ServiceDescription 
ServiceProvider 

Definition at line 27 of file qbluetoothserviceinfo.h.

◆ Protocol

This enum describes the socket protocol used by the service.

\value UnknownProtocol The service uses an unknown socket protocol. \value L2capProtocol The service uses the L2CAP socket protocol. This protocol is not supported for direct socket connections on Android. \value RfcommProtocol The service uses the RFCOMM socket protocol.

Enumerator
UnknownProtocol 
L2capProtocol 
RfcommProtocol 

Definition at line 48 of file qbluetoothserviceinfo.h.

Constructor & Destructor Documentation

◆ QBluetoothServiceInfo() [1/2]

QBluetoothServiceInfo::QBluetoothServiceInfo ( )

Construct a new invalid QBluetoothServiceInfo;.

Definition at line 324 of file qbluetoothserviceinfo.cpp.

◆ QBluetoothServiceInfo() [2/2]

QBluetoothServiceInfo::QBluetoothServiceInfo ( const QBluetoothServiceInfo & other)

Construct a new QBluetoothServiceInfo that is a copy of other.

The two copies continue to share the same underlying data which does not detach upon write.

Definition at line 336 of file qbluetoothserviceinfo.cpp.

◆ ~QBluetoothServiceInfo()

QBluetoothServiceInfo::~QBluetoothServiceInfo ( )

Destroys the QBluetoothServiceInfo object.

Definition at line 344 of file qbluetoothserviceinfo.cpp.

Member Function Documentation

◆ attribute()

QVariant QBluetoothServiceInfo::attribute ( quint16 attributeId) const

Returns the value of the attribute attributeId.

Definition at line 403 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, d_ptr, and QMap< Key, T >::value().

+ Here is the call graph for this function:

◆ attributes()

QList< quint16 > QBluetoothServiceInfo::attributes ( ) const

Returns a list of all attribute ids that the QBluetoothServiceInfo object has.

Definition at line 411 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, d_ptr, and QMap< Key, T >::keys().

+ Here is the call graph for this function:

◆ contains()

bool QBluetoothServiceInfo::contains ( quint16 attributeId) const

Returns true if the QBluetoothServiceInfo object contains the attribute attributeId, otherwise returns false.

Definition at line 420 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, QMap< Key, T >::contains(), and d_ptr.

+ Here is the call graph for this function:

◆ device()

QBluetoothDeviceInfo QBluetoothServiceInfo::device ( ) const

Returns the address of the Bluetooth device that provides this service.

Definition at line 371 of file qbluetoothserviceinfo.cpp.

References d_ptr, and QBluetoothServiceInfoPrivate::deviceInfo.

Referenced by setDevice().

+ Here is the caller graph for this function:

◆ isComplete()

bool QBluetoothServiceInfo::isComplete ( ) const

Returns true if the QBluetoothServiceInfo object is considered complete, otherwise returns false.

A complete QBluetoothServiceInfo object contains a ProtocolDescriptorList attribute.

Definition at line 363 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, QMap< Key, T >::contains(), d_ptr, and ProtocolDescriptorList.

+ Here is the call graph for this function:

◆ isRegistered()

bool QBluetoothServiceInfo::isRegistered ( ) const

Returns true if the service information is registered with the platform's Service Discovery Protocol (SDP) implementation, otherwise returns false.

◆ isValid()

bool QBluetoothServiceInfo::isValid ( ) const

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

An invalid QBluetoothServiceInfo object will have no attributes.

Definition at line 353 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, d_ptr, and QMap< Key, T >::isEmpty().

+ Here is the call graph for this function:

◆ operator=()

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

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

The two copies continue to share the same service and registration details.

Definition at line 523 of file qbluetoothserviceinfo.cpp.

References d_ptr, and other().

+ Here is the call graph for this function:

◆ protocolDescriptor()

QBluetoothServiceInfo::Sequence QBluetoothServiceInfo::protocolDescriptor ( QBluetoothUuid::ProtocolUuid protocol) const

Returns the protocol parameters as a QBluetoothServiceInfo::Sequence for protocol protocol.

An empty QBluetoothServiceInfo::Sequence is returned if protocol is not supported.

Definition at line 490 of file qbluetoothserviceinfo.cpp.

References d_ptr, and QBluetoothServiceInfoPrivate::protocolDescriptor().

Referenced by protocolServiceMultiplexer(), and socketProtocol().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ protocolServiceMultiplexer()

int QBluetoothServiceInfo::protocolServiceMultiplexer ( ) const

This is a convenience function.

Returns the protocol/service multiplexer for services which support the L2CAP protocol, otherwise returns -1.

This function is equivalent to extracting the information from QBluetoothServiceInfo::Sequence returned by QBluetoothServiceInfo::attribute(QBluetoothServiceInfo::ProtocolDescriptorList).

Definition at line 460 of file qbluetoothserviceinfo.cpp.

References QList< T >::at(), QList< T >::isEmpty(), QBluetoothUuid::L2cap, protocolDescriptor(), QList< T >::size(), and QVariant::toUInt().

+ Here is the call graph for this function:

◆ registerService()

bool QBluetoothServiceInfo::registerService ( const QBluetoothAddress & localAdapter = QBluetoothAddress())

◆ removeAttribute()

void QBluetoothServiceInfo::removeAttribute ( quint16 attributeId)

Removes the attribute attributeId from the QBluetoothServiceInfo object.

If the service information is already registered with the platforms SDP database, the database entry will not be updated until \l registerService() was called again.

Definition at line 431 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, d_ptr, and QMap< Key, T >::remove().

+ Here is the call graph for this function:

◆ serverChannel()

int QBluetoothServiceInfo::serverChannel ( ) const

This is a convenience function.

Returns the server channel for services which support the RFCOMM protocol, otherwise returns -1.

This function is equivalent to extracting the information from QBluetoothServiceInfo::Sequence returned by QBluetoothServiceInfo::attribute(QBluetootherServiceInfo::ProtocolDescriptorList).

Definition at line 480 of file qbluetoothserviceinfo.cpp.

References d_ptr, and QBluetoothServiceInfoPrivate::serverChannel().

+ Here is the call graph for this function:

◆ serviceAvailability()

quint8 QBluetoothServiceInfo::serviceAvailability ( ) const
inline

This is a convenience function.

It is equivalent to calling attribute(QBluetoothServiceInfo::ServiceAvailability).toUInt().

Returns the availability of the service.

See also
setServiceAvailability(), attribute()

Definition at line 187 of file qbluetoothserviceinfo.h.

References ServiceAvailability.

◆ serviceClassUuids()

QList< QBluetoothUuid > QBluetoothServiceInfo::serviceClassUuids ( ) const

Returns a list of UUIDs describing the service classes that this service conforms to.

This is a convenience function. It is equivalent to calling attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>() and subsequently iterating over its QBluetoothUuid entries.

See also
attribute()

Definition at line 504 of file qbluetoothserviceinfo.cpp.

References QList< T >::append(), QList< T >::at(), i, QVariant::isValid(), results, ServiceClassIds, QList< T >::size(), QVariant::value(), and var.

+ Here is the call graph for this function:

◆ serviceDescription()

QString QBluetoothServiceInfo::serviceDescription ( ) const
inline

This is a convenience function.

It is equivalent to calling attribute(QBluetoothServiceInfo::ServiceDescription).toString().

Returns the service description in the primary language.

See also
setServiceDescription(), attribute()

Definition at line 167 of file qbluetoothserviceinfo.h.

References ServiceDescription.

◆ serviceName()

QString QBluetoothServiceInfo::serviceName ( ) const
inline

This is a convenience function.

It is equivalent to calling attribute(QBluetoothServiceInfo::ServiceName).toString().

Returns the service name in the primary language.

See also
setServiceName(), attribute()

Definition at line 157 of file qbluetoothserviceinfo.h.

References ServiceName.

◆ serviceProvider()

QString QBluetoothServiceInfo::serviceProvider ( ) const
inline

This is a convenience function.

It is equivalent to calling attribute(QBluetoothServiceInfo::ServiceProvider).toString().

Returns the service provider in the primary language.

See also
setServiceProvider(), attribute()

Definition at line 177 of file qbluetoothserviceinfo.h.

References ServiceProvider.

◆ serviceUuid()

QBluetoothUuid QBluetoothServiceInfo::serviceUuid ( ) const
inline

This is a convenience function.

It is equivalent to calling attribute(QBluetoothServiceInfo::ServiceId).value<QBluetoothUuid>().

Returns the custom UUID of the service. This UUID may be null. UUIDs based on \l{https://bluetooth.org}{Bluetooth SIG standards} should be retrieved via \l serviceClassUuids().

See also
setServiceUuid(), attribute()

Definition at line 197 of file qbluetoothserviceinfo.h.

References ServiceId.

◆ setAttribute() [1/4]

void QBluetoothServiceInfo::setAttribute ( quint16 attributeId,
const QBluetoothServiceInfo::Alternative & value )
inline

This is a convenience function.

Sets the attribute identified by attributeId to value.

If the service information is already registered with the platform's SDP database, the database entry will not be updated until \l registerService() was called again.

Definition at line 147 of file qbluetoothserviceinfo.h.

References QVariant::fromValue(), and setAttribute().

+ Here is the call graph for this function:

◆ setAttribute() [2/4]

void QBluetoothServiceInfo::setAttribute ( quint16 attributeId,
const QBluetoothServiceInfo::Sequence & value )
inline

This is a convenience function.

Sets the attribute identified by attributeId to value.

If the service information is already registered with the platform's SDP database, the database entry will not be updated until \l registerService() was called again.

Definition at line 142 of file qbluetoothserviceinfo.h.

References QVariant::fromValue(), and setAttribute().

+ Here is the call graph for this function:

◆ setAttribute() [3/4]

void QBluetoothServiceInfo::setAttribute ( quint16 attributeId,
const QBluetoothUuid & value )

This is a convenience function.

Sets the attribute identified by attributeId to value.

If the service information is already registered with the platform's SDP database, the database entry will not be updated until \l registerService() was called again.

◆ setAttribute() [4/4]

void QBluetoothServiceInfo::setAttribute ( quint16 attributeId,
const QVariant & value )

Sets the attribute identified by attributeId to value.

If the service information is already registered with the platform's SDP database, the database entry will not be updated until \l registerService() was called again.

Note
If an attribute expectes a byte-encoded value (e.g. Bluetooth HID services), it should be set as QByteArray.
See also
isRegistered(), registerService()

Definition at line 395 of file qbluetoothserviceinfo.cpp.

References QBluetoothServiceInfoPrivate::attributes, and d_ptr.

Referenced by QBluetoothServer::listen(), setAttribute(), setAttribute(), setServiceAvailability(), setServiceDescription(), setServiceName(), setServiceProvider(), and setServiceUuid().

+ Here is the caller graph for this function:

◆ setDevice()

void QBluetoothServiceInfo::setDevice ( const QBluetoothDeviceInfo & info)

Sets the Bluetooth device that provides this service to device.

Definition at line 379 of file qbluetoothserviceinfo.cpp.

References d_ptr, device(), and QBluetoothServiceInfoPrivate::deviceInfo.

+ Here is the call graph for this function:

◆ setServiceAvailability()

void QBluetoothServiceInfo::setServiceAvailability ( quint8 availability)
inline

This is a convenience function.

It is equivalent to calling setAttribute(QBluetoothServiceInfo::ServiceAvailability, availability).

Sets the availabiltiy of the service to availability.

See also
serviceAvailability(), setAttribute()

Definition at line 182 of file qbluetoothserviceinfo.h.

References QVariant::fromValue(), ServiceAvailability, and setAttribute().

+ Here is the call graph for this function:

◆ setServiceDescription()

void QBluetoothServiceInfo::setServiceDescription ( const QString & description)
inline

This is a convenience function.

It is equivalent to calling setAttribute(QBluetoothServiceInfo::ServiceDescription, description).

Sets the service description in the primary language to description.

See also
serviceDescription(), setAttribute()

Definition at line 162 of file qbluetoothserviceinfo.h.

References QVariant::fromValue(), ServiceDescription, and setAttribute().

+ Here is the call graph for this function:

◆ setServiceName()

void QBluetoothServiceInfo::setServiceName ( const QString & name)
inline

This is a convenience function.

It is equivalent to calling setAttribute(QBluetoothServiceInfo::ServiceName, name).

Sets the service name in the primary language to name.

See also
serviceName(), setAttribute()

Definition at line 152 of file qbluetoothserviceinfo.h.

References QVariant::fromValue(), ServiceName, and setAttribute().

+ Here is the call graph for this function:

◆ setServiceProvider()

void QBluetoothServiceInfo::setServiceProvider ( const QString & provider)
inline

This is a convenience function.

It is equivalent to calling setAttribute(QBluetoothServiceInfo::ServiceProvider, provider).

Sets the service provider in the primary language to provider.

See also
serviceProvider(), setAttribute()

Definition at line 172 of file qbluetoothserviceinfo.h.

References QVariant::fromValue(), ServiceProvider, and setAttribute().

+ Here is the call graph for this function:

◆ setServiceUuid()

void QBluetoothServiceInfo::setServiceUuid ( const QBluetoothUuid & uuid)
inline

This is a convenience function.

It is equivalent to calling setAttribute(QBluetoothServiceInfo::ServiceId, uuid).

Sets the custom service UUID to uuid. This function should not be used to set a standardized service UUID.

See also
serviceUuid(), setAttribute()

Definition at line 192 of file qbluetoothserviceinfo.h.

References ServiceId, and setAttribute().

+ Here is the call graph for this function:

◆ socketProtocol()

QBluetoothServiceInfo::Protocol QBluetoothServiceInfo::socketProtocol ( ) const

Returns the protocol that the QBluetoothServiceInfo object uses.

Definition at line 439 of file qbluetoothserviceinfo.cpp.

References QList< T >::isEmpty(), QBluetoothUuid::L2cap, L2capProtocol, protocolDescriptor(), QBluetoothUuid::Rfcomm, RfcommProtocol, and UnknownProtocol.

+ Here is the call graph for this function:

◆ unregisterService()

bool QBluetoothServiceInfo::unregisterService ( )

Unregisters this service with the platform's Service Discovery Protocol (SDP) implementation.

After this, the service will no longer be findable by other devices through service discovery.

Returns true if the service is successfully unregistered, otherwise returns false.

Definition at line 169 of file qbluetoothserviceinfo.cpp.

References d_ptr, and QBluetoothServiceInfoPrivate::unregisterService().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

QDebug operator<< ( QDebug d,
const QBluetoothServiceInfo & i )
friend

Definition at line 116 of file qbluetoothserviceinfo.h.

Member Data Documentation

◆ d_ptr


The documentation for this class was generated from the following files: