BluezQt 5.109.0
device.h
1/*
2 * BluezQt - Asynchronous BlueZ wrapper library
3 *
4 * SPDX-FileCopyrightText: 2014-2015 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#ifndef BLUEZQT_DEVICE_H
10#define BLUEZQT_DEVICE_H
11
12#include <QObject>
13
14#include "bluezqt_export.h"
15#include "gattserviceremote.h"
16#include "input.h"
17#include "mediaplayer.h"
18#include "mediatransport.h"
19namespace BluezQt
20{
21class Adapter;
22class PendingCall;
23
31class BLUEZQT_EXPORT Device : public QObject
32{
33 Q_OBJECT
34
35 Q_PROPERTY(QString ubi READ ubi)
36 Q_PROPERTY(QString address READ address NOTIFY addressChanged)
37 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
38 Q_PROPERTY(QString friendlyName READ friendlyName NOTIFY friendlyNameChanged)
39 Q_PROPERTY(QString remoteName READ remoteName NOTIFY remoteNameChanged)
40 Q_PROPERTY(quint32 deviceClass READ deviceClass NOTIFY deviceClassChanged)
41 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
42 Q_PROPERTY(quint16 appearance READ appearance NOTIFY appearanceChanged)
43 Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
44 Q_PROPERTY(bool paired READ isPaired NOTIFY pairedChanged)
45 Q_PROPERTY(bool trusted READ isTrusted WRITE setTrusted NOTIFY trustedChanged)
46 Q_PROPERTY(bool blocked READ isBlocked WRITE setBlocked NOTIFY blockedChanged)
47 Q_PROPERTY(bool legacyPairing READ hasLegacyPairing NOTIFY legacyPairingChanged)
48 Q_PROPERTY(qint16 rssi READ rssi NOTIFY rssiChanged)
49 Q_PROPERTY(ManData manufacturerData READ manufacturerData NOTIFY manufacturerDataChanged)
50 Q_PROPERTY(bool servicesResolved READ isServicesResolved NOTIFY servicesResolvedChanged)
51 Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged)
52 Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged)
53 Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged)
54 Q_PROPERTY(BatteryPtr battery READ battery NOTIFY batteryChanged)
55 Q_PROPERTY(InputPtr input READ input NOTIFY inputChanged)
56 Q_PROPERTY(MediaPlayerPtr mediaPlayer READ mediaPlayer NOTIFY mediaPlayerChanged)
57 Q_PROPERTY(MediaTransportPtr mediaTransport READ mediaTransport NOTIFY mediaTransportChanged)
58 Q_PROPERTY(AdapterPtr adapter READ adapter)
59 Q_PROPERTY(QList<GattServiceRemotePtr> gattServices READ gattServices NOTIFY gattServicesChanged)
60
61public:
65 enum Type {
104 };
105 Q_ENUM(Type)
106
107
110 ~Device() override;
111
117 DevicePtr toSharedPtr() const;
118
126 QString ubi() const;
127
135 QString address() const;
136
145 QString name() const;
146
153 PendingCall *setName(const QString &name);
154
163 QString friendlyName() const;
164
170 QString remoteName() const;
171
182 quint32 deviceClass() const;
183
196
202 quint16 appearance() const;
203
211 QString icon() const;
212
218 bool isPaired() const;
219
225 bool isTrusted() const;
226
233 PendingCall *setTrusted(bool trusted);
234
240 bool isBlocked() const;
241
248 PendingCall *setBlocked(bool blocked);
249
255 bool hasLegacyPairing() const;
256
266 qint16 rssi() const;
267
276 ManData manufacturerData() const;
277
283 bool isServicesResolved() const;
284
290 bool isConnected() const;
291
299 QStringList uuids() const;
300
306 QString modalias() const;
307
314 QHash<QString, QByteArray> serviceData() const;
315
322 BatteryPtr battery() const;
323
331 InputPtr input() const;
332
341 MediaPlayerPtr mediaPlayer() const;
342
351 MediaTransportPtr mediaTransport() const;
352
358 AdapterPtr adapter() const;
359
365 QList<GattServiceRemotePtr> gattServices() const;
372 static QString typeToString(Device::Type type);
373
380 static Device::Type stringToType(const QString &typeString);
381
382public Q_SLOTS:
394
405
415 PendingCall *connectProfile(const QString &uuid);
416
426 PendingCall *disconnectProfile(const QString &uuid);
427
439
450
451Q_SIGNALS:
455 void deviceRemoved(DevicePtr device);
456
460 void deviceChanged(DevicePtr device);
461
465 void gattServiceAdded(GattServiceRemotePtr service);
466
470 void gattServicesChanged(QList<GattServiceRemotePtr> services);
471
475 void gattServiceRemoved(GattServiceRemotePtr service);
476
480 void gattServiceChanged(GattServiceRemotePtr service);
481
485 void nameChanged(const QString &name);
486
490 void addressChanged(const QString &address);
491
495 void friendlyNameChanged(const QString &friendlyName);
496
500 void remoteNameChanged(const QString &remoteName);
501
505 void deviceClassChanged(quint32 deviceClass);
506
510 void typeChanged(Type type);
511
515 void appearanceChanged(quint16 appearance);
516
520 void iconChanged(const QString &icon);
521
525 void pairedChanged(bool paired);
526
530 void trustedChanged(bool trusted);
531
535 void blockedChanged(bool blocked);
536
540 void legacyPairingChanged(bool legacyPairing);
541
545 void rssiChanged(qint16 rssi);
546
550 void manufacturerDataChanged(ManData man);
551
555 void servicesResolvedChanged(bool servicesResolved);
556
560 void connectedChanged(bool connected);
561
565 void uuidsChanged(const QStringList &uuids);
566
570 void modaliasChanged(const QString &modalias);
571
576 void serviceDataChanged(const QHash<QString, QByteArray> &serviceData);
577
581 void batteryChanged(BatteryPtr battery);
582
586 void inputChanged(InputPtr input);
587
591 void mediaPlayerChanged(MediaPlayerPtr mediaPlayer);
592
596 void mediaTransportChanged(MediaTransportPtr mediaTransport);
597
598private:
599 BLUEZQT_NO_EXPORT explicit Device(const QString &path, const QVariantMap &properties, AdapterPtr adapter);
600
601 class DevicePrivate *const d;
602
603 friend class DevicePrivate;
604 friend class ManagerPrivate;
605 friend class Adapter;
606};
607
608} // namespace BluezQt
609
610Q_DECLARE_METATYPE(BluezQt::ManData)
611
612#endif // BLUEZQT_DEVICE_H
Bluetooth adapter.
Definition adapter.h:33
Bluetooth device.
Definition device.h:32
PendingCall * connectProfile(const QString &uuid)
Connects a specific profile of the device.
bool isTrusted() const
Returns whether the device is trusted.
void nameChanged(const QString &name)
Indicates that device's name have changed.
QString icon() const
Returns an icon name of the device.
bool isConnected() const
Returns whether the device is connected.
bool hasLegacyPairing() const
Returns whether the device has legacy pairing.
PendingCall * pair()
Initiates a pairing with the device.
PendingCall * setTrusted(bool trusted)
Sets the trusted state of the device.
InputPtr input() const
Returns the input interface for the device.
void modaliasChanged(const QString &modalias)
Indicates that device's modalias have changed.
QList< GattServiceRemotePtr > gattServices() const
Returns list of services known by the device.
QString remoteName() const
Returns a remote name of the device.
QHash< QString, QByteArray > serviceData() const
Returns the service advertisement data.
QString name() const
Returns a name of the device.
Type
Device types.
Definition device.h:65
@ Modem
The device is a modem.
Definition device.h:69
@ Wearable
The device is a wearable device.
Definition device.h:97
@ Uncategorized
The device is not of any of the known types.
Definition device.h:103
@ Headset
The device is a headset.
Definition device.h:75
@ Imaging
The device is an uncategorized imaging device.
Definition device.h:95
@ Tablet
The device is a graphics tablet (input device).
Definition device.h:87
@ Camera
The device is a camera.
Definition device.h:91
@ Peripheral
The device is an uncategorized peripheral device.
Definition device.h:89
@ AudioVideo
The device is an uncategorized audio video device.
Definition device.h:79
@ Toy
The device is a toy.
Definition device.h:99
@ Network
The device is a network.
Definition device.h:73
@ Mouse
The device is a mouse.
Definition device.h:83
@ Phone
The device is a phone.
Definition device.h:67
@ Headphones
The device is a headphones.
Definition device.h:77
@ Computer
The device is a computer.
Definition device.h:71
@ Joypad
The device is a joypad.
Definition device.h:85
@ Printer
The device is a printer.
Definition device.h:93
@ Keyboard
The device is a keyboard.
Definition device.h:81
@ Health
The device is a health device.
Definition device.h:101
QStringList uuids() const
Returns UUIDs of supported services by the device.
~Device() override
Destroys a Device object.
PendingCall * connectToDevice()
Connects all auto-connectable profiles of the device.
static QString typeToString(Device::Type type)
Returns a string for device type.
PendingCall * cancelPairing()
Cancels a pairing with the device.
PendingCall * setBlocked(bool blocked)
Sets the blocked state of the device.
static Device::Type stringToType(const QString &typeString)
Returns a device type for string.
bool isPaired() const
Returns whether the device is paired.
qint16 rssi() const
Returns Received Signal Strength Indicator of the device.
void deviceRemoved(DevicePtr device)
Indicates that the device was removed.
bool isBlocked() const
Returns whether the device is blocked.
quint32 deviceClass() const
Returns a class of the device.
void typeChanged(Type type)
Indicates that device's type have changed.
void trustedChanged(bool trusted)
Indicates that device's trusted state have changed.
PendingCall * disconnectProfile(const QString &uuid)
Disconnects a specific profile of the device.
void mediaTransportChanged(MediaTransportPtr mediaTransport)
Indicates that device's media transport have changed.
void inputChanged(InputPtr input)
Indicates that device's input have changed.
BatteryPtr battery() const
Returns the battery interface for the device.
void blockedChanged(bool blocked)
Indicates that device's blocked state have changed.
void iconChanged(const QString &icon)
Indicates that device's icon have changed.
ManData manufacturerData() const
Returns manufacturer specific advertisement data.
void mediaPlayerChanged(MediaPlayerPtr mediaPlayer)
Indicates that device's media player have changed.
void gattServicesChanged(QList< GattServiceRemotePtr > services)
Indicates that device GATT services list has changed.
void appearanceChanged(quint16 appearance)
Indicates that device's appearance have changed.
void legacyPairingChanged(bool legacyPairing)
Indicates that device's legacy pairing state have changed.
void friendlyNameChanged(const QString &friendlyName)
Indicates that device's friendly name have changed.
void gattServiceChanged(GattServiceRemotePtr service)
Indicates that at least one of the device's services have changed.
QString address() const
Returns an address of the device.
quint16 appearance() const
Returns an appearance of the device.
void serviceDataChanged(const QHash< QString, QByteArray > &serviceData)
Indicates that the device's service data has changed.
QString friendlyName() const
Returns a friendly name of the device.
void rssiChanged(qint16 rssi)
Indicates that device's RSSI have changed.
void remoteNameChanged(const QString &remoteName)
Indicates that device's remote name have changed.
void gattServiceRemoved(GattServiceRemotePtr service)
Indicates that a service was removed.
void connectedChanged(bool connected)
Indicates that device's connected state have changed.
PendingCall * setName(const QString &name)
Sets the name of the device.
void servicesResolvedChanged(bool servicesResolved)
Indicates that device's servicesResolved state have changed.
QString modalias() const
Returns remote device ID in modalias format.
void pairedChanged(bool paired)
Indicates that device's paired state have changed.
DevicePtr toSharedPtr() const
Returns a shared pointer from this.
void deviceClassChanged(quint32 deviceClass)
Indicates that device's class have changed.
PendingCall * disconnectFromDevice()
Disconnects all connected profiles of the device.
void batteryChanged(BatteryPtr battery)
Indicates that device's battery has changed.
void uuidsChanged(const QStringList &uuids)
Indicates that device's UUIDs have changed.
QString ubi() const
Returns an UBI of the device.
void gattServiceAdded(GattServiceRemotePtr service)
Indicates that a new service was added (eg.
Device::Type type() const
Returns a type of the device.
void manufacturerDataChanged(ManData man)
Indicates that device's manufacturer data have changed.
MediaPlayerPtr mediaPlayer() const
Returns the media player interface for the device.
MediaTransportPtr mediaTransport() const
Returns the media transport interface for the device.
bool isServicesResolved() const
Returns whether or not service discovery has been resolved.
AdapterPtr adapter() const
Returns an adapter that discovered this device.
void deviceChanged(DevicePtr device)
Indicates that at least one of the device's properties have changed.
void addressChanged(const QString &address)
Indicates that device's address have changed.
Pending method call.
Definition pendingcall.h:33