BluezQt 5.109.0
|
Bluetooth manager. More...
#include <BluezQt/Manager>
Properties | |
QList< AdapterPtr > | adapters |
bool | bluetoothBlocked |
bool | bluetoothOperational |
QList< DevicePtr > | devices |
bool | initialized |
bool | operational |
Rfkill * | rfkill |
AdapterPtr | usableAdapter |
Signals | |
void | adapterAdded (AdapterPtr adapter) |
Indicates that adapter was added. | |
void | adapterChanged (AdapterPtr adapter) |
Indicates that at least one of the adapter's properties have changed. | |
void | adapterRemoved (AdapterPtr adapter) |
Indicates that adapter was removed. | |
void | allAdaptersRemoved () |
Indicates that all adapters were removed. | |
void | bluetoothBlockedChanged (bool blocked) |
Indicates that Bluetooth blocked state have changed. | |
void | bluetoothOperationalChanged (bool operational) |
Indicates that Bluetooth operational state have changed. | |
void | deviceAdded (DevicePtr device) |
Indicates that a new device was added (eg. | |
void | deviceChanged (DevicePtr device) |
Indicates that at least one of the device's properties have changed. | |
void | deviceRemoved (DevicePtr device) |
Indicates that a device was removed. | |
void | operationalChanged (bool operational) |
Indicates that operational state have changed. | |
void | usableAdapterChanged (AdapterPtr adapter) |
Indicates that usable adapter have changed. | |
Public Member Functions | |
Manager (QObject *parent=nullptr) | |
Creates a new Manager object. | |
~Manager () override | |
Destroys a Manager object. | |
AdapterPtr | adapterForAddress (const QString &address) const |
Returns an adapter for specified address. | |
AdapterPtr | adapterForUbi (const QString &ubi) const |
Returns an adapter for specified UBI. | |
QList< AdapterPtr > | adapters () const |
Returns a list of all adapters. | |
DevicePtr | deviceForAddress (const QString &address) const |
Returns a device for specified address. | |
DevicePtr | deviceForUbi (const QString &ubi) const |
Returns a device for specified UBI. | |
QList< DevicePtr > | devices () const |
Returns a list of all devices. | |
InitManagerJob * | init () |
Creates a new init job. | |
bool | isBluetoothBlocked () const |
Returns whether Bluetooth is blocked. | |
bool | isBluetoothOperational () const |
Returns whether Bluetooth is operational. | |
bool | isInitialized () const |
Returns whether the manager is initialized. | |
bool | isOperational () const |
Returns whether the manager is operational. | |
MediaPtr | media () const |
Returns the media interface. | |
PendingCall * | registerAgent (Agent *agent) |
Registers agent. | |
PendingCall * | registerProfile (Profile *profile) |
Registers profile. | |
PendingCall * | requestDefaultAgent (Agent *agent) |
Requests default agent. | |
Rfkill * | rfkill () const |
bool | setBluetoothBlocked (bool blocked) |
Sets a Bluetooth blocked state. | |
PendingCall * | unregisterAgent (Agent *agent) |
Unregisters agent. | |
PendingCall * | unregisterProfile (Profile *profile) |
Unregisters profile. | |
AdapterPtr | usableAdapter () const |
Returns a usable adapter. | |
Static Public Member Functions | |
static PendingCall * | startService () |
Attempts to start org.bluez service by D-Bus activation. | |
Bluetooth manager.
The entry point to communicate with system BlueZ daemon.
The typical usecase is to work with usableAdapter() (any powered adapter), but it is also possible to use specific adapter.
You must call init() before other functions can be used.
The only functions that can be used before initialization are two rfkill-related functions: isBluetoothBlocked() and setBluetoothBlocked().
Example use in C++ code:
In QML, manager is a singleton and initialization is started when first using the manager. You don't need to track initialized state, just use property binding.
Example use in QML code:
|
explicit |
Creates a new Manager object.
parent |
|
override |
Destroys a Manager object.
|
signal |
Indicates that adapter was added.
|
signal |
Indicates that at least one of the adapter's properties have changed.
AdapterPtr BluezQt::Manager::adapterForAddress | ( | const QString & | address | ) | const |
Returns an adapter for specified address.
address | address of adapter (eg. "1C:E5:C3:BC:94:7E") |
AdapterPtr BluezQt::Manager::adapterForUbi | ( | const QString & | ubi | ) | const |
Returns an adapter for specified UBI.
ubi | UBI of adapter (eg. "/org/bluez/hci0") |
|
signal |
Indicates that adapter was removed.
QList< AdapterPtr > BluezQt::Manager::adapters | ( | ) | const |
Returns a list of all adapters.
|
signal |
Indicates that all adapters were removed.
|
signal |
Indicates that Bluetooth blocked state have changed.
|
signal |
Indicates that Bluetooth operational state have changed.
|
signal |
Indicates that a new device was added (eg.
found by discovery).
|
signal |
Indicates that at least one of the device's properties have changed.
DevicePtr BluezQt::Manager::deviceForAddress | ( | const QString & | address | ) | const |
Returns a device for specified address.
address | address of device (eg. "40:79:6A:0C:39:75") |
DevicePtr BluezQt::Manager::deviceForUbi | ( | const QString & | ubi | ) | const |
Returns a device for specified UBI.
ubi | UBI of device (eg. "/org/bluez/hci0/dev_40_79_6A_0C_39_75") |
|
signal |
Indicates that a device was removed.
QList< DevicePtr > BluezQt::Manager::devices | ( | ) | const |
Returns a list of all devices.
InitManagerJob * BluezQt::Manager::init | ( | ) |
Creates a new init job.
bool BluezQt::Manager::isBluetoothBlocked | ( | ) | const |
Returns whether Bluetooth is blocked.
Bluetooth is blocked if rfkill state for Bluetooth is either SOFT_BLOCKED or HARD_BLOCKED.
bool BluezQt::Manager::isBluetoothOperational | ( | ) | const |
Returns whether Bluetooth is operational.
Bluetooth is operational when manager is operational and there is a valid usable adapter.
bool BluezQt::Manager::isInitialized | ( | ) | const |
Returns whether the manager is initialized.
bool BluezQt::Manager::isOperational | ( | ) | const |
Returns whether the manager is operational.
The manager is operational when initialization was successful and BlueZ system daemon is running.
MediaPtr BluezQt::Manager::media | ( | ) | const |
|
signal |
Indicates that operational state have changed.
PendingCall * BluezQt::Manager::registerAgent | ( | Agent * | agent | ) |
Registers agent.
This agent will be used for for all actions triggered by the application. Eg. show a PIN code in pairing process.
Possible errors: PendingCall::InvalidArguments, PendingCall::AlreadyExists
agent | agent to be registered |
PendingCall * BluezQt::Manager::registerProfile | ( | Profile * | profile | ) |
Registers profile.
Possible errors: PendingCall::InvalidArguments, PendingCall::AlreadyExists
profile | profile to be registered |
PendingCall * BluezQt::Manager::requestDefaultAgent | ( | Agent * | agent | ) |
Requests default agent.
This requests to make the application agent the default agent.
Possible errors: PendingCall::DoesNotExist
agent | registered agent |
bool BluezQt::Manager::setBluetoothBlocked | ( | bool | blocked | ) |
Sets a Bluetooth blocked state.
This may fail either due to insufficient permissions or because rfkill state is HARD_BLOCKED. In that case, this function returns false.
|
static |
Attempts to start org.bluez service by D-Bus activation.
Possible return values are 1 if the service was started, 2 if the service is already running or error if the service could not be started.
PendingCall * BluezQt::Manager::unregisterAgent | ( | Agent * | agent | ) |
Unregisters agent.
Possible errors: PendingCall::DoesNotExist
agent | agent to be unregistered |
PendingCall * BluezQt::Manager::unregisterProfile | ( | Profile * | profile | ) |
Unregisters profile.
Possible errors: PendingCall::DoesNotExist
profile | profile to be unregistered |
AdapterPtr BluezQt::Manager::usableAdapter | ( | ) | const |
Returns a usable adapter.
Usable adapter is any adapter that is currently powered on.
|
signal |
Indicates that usable adapter have changed.