| 1 | /* |
| 2 | * BluezQt - Asynchronous Bluez wrapper library |
| 3 | * |
| 4 | * SPDX-FileCopyrightText: 2021 Ivan Podkurkov <podkiva2@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_GATTSERVICEREMOTE_H |
| 10 | #define BLUEZQT_GATTSERVICEREMOTE_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 | * \inmodule BluezQt |
| 27 | * \class BluezQt::GattServiceRemote |
| 28 | * \inheaderfile BluezQt/GattServiceRemote |
| 29 | * \brief Bluetooth LE GATT service. |
| 30 | * |
| 31 | * This class represents a Bluetooth LE GATT service. |
| 32 | */ |
| 33 | class BLUEZQT_EXPORT GattServiceRemote : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | /*! \property BluezQt::GattServiceRemote::uuid */ |
| 38 | Q_PROPERTY(QString uuid READ uuid NOTIFY uuidChanged) |
| 39 | /*! \property BluezQt::GattServiceRemote::primary */ |
| 40 | Q_PROPERTY(bool primary READ isPrimary NOTIFY primaryChanged) |
| 41 | /*! \property BluezQt::GattServiceRemote::device */ |
| 42 | Q_PROPERTY(DevicePtr device READ device CONSTANT) |
| 43 | /*! \property BluezQt::GattServiceRemote::includes */ |
| 44 | Q_PROPERTY(QList<QDBusObjectPath> includes READ includes NOTIFY includesChanged) |
| 45 | /*! \property BluezQt::GattServiceRemote::handle */ |
| 46 | Q_PROPERTY(quint16 handle READ handle WRITE setHandle NOTIFY handleChanged) |
| 47 | /*! \property BluezQt::GattServiceRemote::characteristics */ |
| 48 | Q_PROPERTY(QList<GattCharacteristicRemotePtr> characteristics READ characteristics NOTIFY characteristicsChanged) |
| 49 | |
| 50 | public: |
| 51 | ~GattServiceRemote() override; |
| 52 | |
| 53 | /*! |
| 54 | * Returns a shared pointer from this. |
| 55 | */ |
| 56 | GattServiceRemotePtr toSharedPtr() const; |
| 57 | |
| 58 | /*! |
| 59 | * Returns the UBI of the gatt service. |
| 60 | * |
| 61 | * Example UBI: "/org/bluez/hci0/dev_40_79_6A_0C_39_75/service01" |
| 62 | */ |
| 63 | QString ubi() const; |
| 64 | |
| 65 | /*! |
| 66 | * Returns the UUID of the service. |
| 67 | */ |
| 68 | QString uuid() const; |
| 69 | |
| 70 | /*! |
| 71 | * Returns whether the service is primary. |
| 72 | */ |
| 73 | bool isPrimary() const; |
| 74 | |
| 75 | /*! |
| 76 | * Returns the device that has this service. |
| 77 | */ |
| 78 | DevicePtr device() const; |
| 79 | |
| 80 | /*! |
| 81 | * Returns object paths representing the included |
| 82 | * services of this service. |
| 83 | */ |
| 84 | QList<QDBusObjectPath> includes() const; |
| 85 | |
| 86 | /*! |
| 87 | * Returns service handle. |
| 88 | * |
| 89 | * Returns qint16 service handle |
| 90 | */ |
| 91 | quint16 handle() const; |
| 92 | |
| 93 | /*! |
| 94 | * Sets the service \a handle. |
| 95 | * |
| 96 | * Returns void pending call. |
| 97 | */ |
| 98 | PendingCall *setHandle(quint16 handle); |
| 99 | |
| 100 | /*! |
| 101 | * Returns object paths representing the included |
| 102 | * services of this service. |
| 103 | */ |
| 104 | QList<GattCharacteristicRemotePtr> characteristics() const; |
| 105 | |
| 106 | Q_SIGNALS: |
| 107 | /*! |
| 108 | * Indicates that at least one of the \a service's properties has changed. |
| 109 | */ |
| 110 | void serviceChanged(GattServiceRemotePtr service); |
| 111 | |
| 112 | /*! |
| 113 | * Indicates that a new \a characteristic was added (eg. found by connection). |
| 114 | */ |
| 115 | void gattCharacteristicAdded(GattCharacteristicRemotePtr characteristic); |
| 116 | |
| 117 | /*! |
| 118 | * Indicates that the service \a characteristics list has changed. |
| 119 | */ |
| 120 | void characteristicsChanged(QList<GattCharacteristicRemotePtr> characteristics); |
| 121 | |
| 122 | /*! |
| 123 | * Indicates that a \a characteristic was removed. |
| 124 | */ |
| 125 | void gattCharacteristicRemoved(GattCharacteristicRemotePtr characteristic); |
| 126 | |
| 127 | /*! |
| 128 | * Indicates that at least one of the \a characteristic's properties has changed. |
| 129 | */ |
| 130 | void gattCharacteristicChanged(GattCharacteristicRemotePtr characteristic); |
| 131 | |
| 132 | /*! |
| 133 | * Indicates that the service's \a uuid has changed. |
| 134 | */ |
| 135 | void uuidChanged(const QString &uuid); |
| 136 | |
| 137 | /*! |
| 138 | * Indicates that the services's \a primary state has changed. |
| 139 | */ |
| 140 | void primaryChanged(bool primary); |
| 141 | |
| 142 | /*! |
| 143 | * Indicates that the services's \a handle has changed. |
| 144 | */ |
| 145 | void handleChanged(quint16 handle); |
| 146 | |
| 147 | /*! |
| 148 | * Indicates that the object paths representing the included |
| 149 | * services \a includes have changed. |
| 150 | */ |
| 151 | void includesChanged(const QList<QDBusObjectPath> &includes); |
| 152 | |
| 153 | private: |
| 154 | BLUEZQT_NO_EXPORT explicit GattServiceRemote(const QString &path, const QVariantMap &properties, DevicePtr device); |
| 155 | |
| 156 | const std::unique_ptr<class GattServiceRemotePrivate> d; |
| 157 | |
| 158 | friend class GattServiceRemotePrivate; |
| 159 | friend class DevicePrivate; |
| 160 | friend class ManagerPrivate; |
| 161 | friend class Adapter; |
| 162 | }; |
| 163 | |
| 164 | } // namespace BluezQt |
| 165 | |
| 166 | #endif // BLUEZQT_GATTSERVICEREMOTE_H |
| 167 | |