BluezQt

gattserviceremote.h
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2021 Ivan Podkurkov <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7  */
8 
9 #ifndef BLUEZQT_GATTSERVICE_H
10 #define BLUEZQT_GATTSERVICE_H
11 
12 #include <QObject>
13 #include <QMap>
14 #include <QDBusObjectPath>
15 
16 #include "types.h"
17 #include "bluezqt_export.h"
18 
19 namespace BluezQt
20 {
21 
22 class Device;
23 class PendingCall;
24 
25 /**
26  * @class BluezQt::GattService gattservice.h <BluezQt/GattService>
27  *
28  * Bluetooth LE GATT service.
29  *
30  * This class represents a Bluetooth LE GATT service.
31  */
32 class BLUEZQT_EXPORT GattServiceRemote : public QObject
33 {
34  Q_OBJECT
35 
36  Q_PROPERTY(QString uuid READ uuid NOTIFY uuidChanged)
37  Q_PROPERTY(bool primary READ isPrimary NOTIFY primaryChanged)
38  Q_PROPERTY(DevicePtr device READ device CONSTANT)
39  Q_PROPERTY(QList<QDBusObjectPath> includes READ includes NOTIFY includesChanged)
40  Q_PROPERTY(quint16 handle READ handle WRITE setHandle NOTIFY handleChanged)
41  Q_PROPERTY(QList<GattCharacteristicRemotePtr> characteristics READ characteristics NOTIFY characteristicsChanged)
42 
43 public:
44  /**
45  * Destroys a GattService object.
46  */
47  ~GattServiceRemote() override;
48 
49  /**
50  * Returns a shared pointer from this.
51  *
52  * @return GattServicePtr
53  */
54  GattServiceRemotePtr toSharedPtr() const;
55 
56  /**
57  * Returns an UBI of the gatt service.
58  *
59  * Example UBI: "/org/bluez/hci0/dev_40_79_6A_0C_39_75/service01"
60  *
61  * @return UBI of gatt service
62  */
63  QString ubi() const;
64 
65  /**
66  * Returns an uuid of the service.
67  *
68  * @return uuid of the service
69  */
70  QString uuid() const;
71 
72  /**
73  * Returns whether the service is primary.
74  *
75  * @return true if service is primary
76  */
77  bool isPrimary() const;
78 
79  /**
80  * Returns a device that has this service.
81  *
82  * @return device of service
83  */
84  DevicePtr device() const;
85 
86  /**
87  * Returns object paths representing the included
88  * services of this service.
89  *
90  * @return Object paths of included services
91  */
92  QList<QDBusObjectPath> includes() const;
93 
94  /**
95  * Returns service handle.
96  *
97  * @return qint16 service handle
98  */
99  quint16 handle() const;
100 
101  /**
102  * Sets the service handle.
103  *
104  * @param handle service handle
105  * @return void pending call
106  */
107  PendingCall *setHandle(quint16 handle);
108 
109  /**
110  * Returns object paths representing the included
111  * services of this service.
112  *
113  * @return Object paths of included services
114  */
115  QList<GattCharacteristicRemotePtr> characteristics() const;
116 
117 Q_SIGNALS:
118  /**
119  * Indicates that at least one of the service's properties have changed.
120  */
121  void serviceChanged(GattServiceRemotePtr service);
122 
123  /**
124  * Indicates that a new characteristic was added (eg. found by connection).
125  */
126  void gattCharacteristicAdded(GattCharacteristicRemotePtr characteristic);
127 
128  /**
129  * Indicates that service characteristics list has changed
130  */
131  void characteristicsChanged(QList<GattCharacteristicRemotePtr> characteristics);
132 
133  /**
134  * Indicates that a characteristic was removed.
135  */
136  void gattCharacteristicRemoved(GattCharacteristicRemotePtr characteristic);
137 
138  /**
139  * Indicates that at least one of the characteristic's properties have changed.
140  */
141  void gattCharacteristicChanged(GattCharacteristicRemotePtr characteristic);
142 
143  /**
144  * Indicates that services's uuid have changed.
145  */
146  void uuidChanged(const QString &uuid);
147 
148  /**
149  * Indicates that services's primary state have changed.
150  */
151  void primaryChanged(bool primary);
152 
153  /**
154  * Indicates that services's handle have changed.
155  */
156  void handleChanged(quint16 handle);
157 
158  /**
159  * Indicates that object paths representing the included
160  * services have changed.
161  */
162  void includesChanged(const QList<QDBusObjectPath> &includes);
163 
164 private:
165  explicit GattServiceRemote(const QString &path, const QVariantMap &properties, DevicePtr device);
166 
167  const std::unique_ptr<class GattServiceRemotePrivate> d;
168 
169  friend class GattServiceRemotePrivate;
170  friend class DevicePrivate;
171  friend class ManagerPrivate;
172  friend class Adapter;
173 };
174 
175 } // namespace BluezQt
176 
177 #endif // BLUEZQT_GATTSERVICE_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.