BluezQt 5.109.0
Public Types | Properties | Public Member Functions | List of all members
BluezQt::Profileabstract

Bluetooth profile. More...

#include <BluezQt/Profile>

Public Types

enum  LocalRole { ClientRole , ServerRole }
 Local role to identify sides in asymmetric profiles. More...
 

Properties

QString uuid
 

Public Member Functions

 Profile (QObject *parent=nullptr)
 Creates a new Profile object.
 
 ~Profile () override
 Destroys a Profile object.
 
QSharedPointer< QLocalSocket > createSocket (const QDBusUnixFileDescriptor &fd)
 Creates a socket from file descriptor.
 
virtual void newConnection (DevicePtr device, const QDBusUnixFileDescriptor &fd, const QVariantMap &properties, const Request<> &request)
 Requests the new connection.
 
virtual QDBusObjectPath objectPath () const =0
 D-Bus object path of the profile.
 
virtual void release ()
 Indicates that the profile was unregistered.
 
virtual void requestDisconnection (DevicePtr device, const Request<> &request)
 Requests the disconnection of the profile.
 
void setAutoConnect (bool autoConnect)
 Sets whether the profile is automatically connected.
 
void setChannel (quint16 channel)
 Sets the RFCOMM channel number.
 
void setFeatures (quint16 features)
 Sets the profile features.
 
void setLocalRole (LocalRole role)
 Sets the local role to identify side.
 
void setName (const QString &name)
 Sets the human readable name of the profile.
 
void setPsm (quint16 psm)
 Sets the L2CAP port number.
 
void setRequireAuthentication (bool require)
 Sets whether the pairing is required to connect.
 
void setRequireAuthorization (bool require)
 Sets whether the authorization is required to connect.
 
void setService (const QString &service)
 Sets the primary service class UUID (if different from profile UUID).
 
void setServiceRecord (const QString &serviceRecord)
 Sets a SDP record.
 
void setVersion (quint16 version)
 Sets the profile version.
 
virtual QString uuid () const =0
 UUID of the profile.
 

Detailed Description

Bluetooth profile.

This class represents a Bluetooth profile.

It is only needed to reimplement pure virtual functions. You don't need to set any additional properties.

But you may need to specify at least channel number or PSM in case it couldn't be determined from UUID. It is also a good idea to provide name for the profile.

Setting the channel number with setChannel() will make the profile use RFCOMM, while setting the PSM with setPsm() will make the profile use L2CAP.

Note
The return value of requests will be sent asynchronously with Request class. It is also possible to cancel/reject all requests.

Member Enumeration Documentation

◆ LocalRole

Local role to identify sides in asymmetric profiles.

Enumerator
ClientRole 

Indicates that this is a client.

ServerRole 

Indicates that this is a server.

Constructor & Destructor Documentation

◆ Profile()

BluezQt::Profile::Profile ( QObject *  parent = nullptr)
explicit

Creates a new Profile object.

Parameters
parent

◆ ~Profile()

BluezQt::Profile::~Profile ( )
override

Destroys a Profile object.

Member Function Documentation

◆ createSocket()

QSharedPointer< QLocalSocket > BluezQt::Profile::createSocket ( const QDBusUnixFileDescriptor &  fd)

Creates a socket from file descriptor.

Parameters
fdsocket file descriptor
Returns
socket
See also
newConnection()

◆ newConnection()

virtual void BluezQt::Profile::newConnection ( DevicePtr  device,
const QDBusUnixFileDescriptor &  fd,
const QVariantMap &  properties,
const Request<> &  request 
)
virtual

Requests the new connection.

Common properties:

  • quint16 Version - Profile version
  • quint16 Features - Profile features

To create socket from fd, you can use:

QSharedPointer<QLocalSocket> socket = createSocket(fd);
if (!socket->isValid()) {
delete socket;
request.cancel();
return;
}
QSharedPointer< QLocalSocket > createSocket(const QDBusUnixFileDescriptor &fd)
Creates a socket from file descriptor.
Parameters
devicedevice that requested connection
fdsocket file descriptor
propertiesadditional properties
requestrequest to be used for sending reply

◆ objectPath()

virtual QDBusObjectPath BluezQt::Profile::objectPath ( ) const
pure virtual

D-Bus object path of the profile.

The path where the profile will be registered.

Note
You must provide valid object path!
Returns
object path of agent

◆ release()

virtual void BluezQt::Profile::release ( )
virtual

Indicates that the profile was unregistered.

This method gets called when the Bluetooth daemon unregisters the profile.

A profile can use it to do cleanup tasks. There is no need to unregister the profile, because when this method gets called it has already been unregistered.

◆ requestDisconnection()

virtual void BluezQt::Profile::requestDisconnection ( DevicePtr  device,
const Request<> &  request 
)
virtual

Requests the disconnection of the profile.

This method gets called when a profile gets disconnected.

Parameters
devicedevice to be disconnected
requestrequest to be used for sending reply

◆ setAutoConnect()

void BluezQt::Profile::setAutoConnect ( bool  autoConnect)

Sets whether the profile is automatically connected.

In case of a client UUID this will force connection of the RFCOMM or L2CAP channels when a remote device is connected.

Parameters
autoConnectautoconnect the profile

◆ setChannel()

void BluezQt::Profile::setChannel ( quint16  channel)

Sets the RFCOMM channel number.

Available channel number range is 0-31. Setting channel number to 0 will automatically choose correct channel number for profile UUID.

Parameters
channelchannel number

◆ setFeatures()

void BluezQt::Profile::setFeatures ( quint16  features)

Sets the profile features.

Parameters
featuresfeatures of the profile

◆ setLocalRole()

void BluezQt::Profile::setLocalRole ( LocalRole  role)

Sets the local role to identify side.

For asymmetric profiles that do not have UUIDs available to uniquely identify each side this parameter allows specifying the precise local role.

Parameters
rolelocal role

◆ setName()

void BluezQt::Profile::setName ( const QString &  name)

Sets the human readable name of the profile.

Parameters
namename of the profile

◆ setPsm()

void BluezQt::Profile::setPsm ( quint16  psm)

Sets the L2CAP port number.

PSM (Protocol Service Multiplexer) is a port number in L2CAP.

Setting PSM to 0 will automatically choose correct PSM for profile UUID.

Parameters
psmPSM

◆ setRequireAuthentication()

void BluezQt::Profile::setRequireAuthentication ( bool  require)

Sets whether the pairing is required to connect.

Parameters
requirerequire to pair

◆ setRequireAuthorization()

void BluezQt::Profile::setRequireAuthorization ( bool  require)

Sets whether the authorization is required to connect.

Parameters
requirerequire to authorize

◆ setService()

void BluezQt::Profile::setService ( const QString &  service)

Sets the primary service class UUID (if different from profile UUID).

Parameters
serviceservice UUID

◆ setServiceRecord()

void BluezQt::Profile::setServiceRecord ( const QString &  serviceRecord)

Sets a SDP record.

This allows to provide a manual SDP record, otherwise it will be generated automatically.

Parameters
serviceRecordSDP record

◆ setVersion()

void BluezQt::Profile::setVersion ( quint16  version)

Sets the profile version.

Parameters
versionversion of the profile

◆ uuid()

virtual QString BluezQt::Profile::uuid ( ) const
pure virtual

UUID of the profile.

Returns
UUID of the profile