File indexing completed on 2024-05-05 03:52:29

0001 /*
0002  * BluezQt - Asynchronous BlueZ wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #ifndef BLUEZQT_GATTMANAGER_H
0010 #define BLUEZQT_GATTMANAGER_H
0011 
0012 #include <QObject>
0013 
0014 #include "bluezqt_export.h"
0015 
0016 #include <memory>
0017 
0018 namespace BluezQt
0019 {
0020 class GattApplication;
0021 class PendingCall;
0022 
0023 /**
0024  * @class BluezQt::GattManager GattManager.h <BluezQt/GattManager>
0025  *
0026  * Bluetooth GattManager.
0027  *
0028  * GATT Manager allows external applications to register GATT services and
0029  * profiles.
0030  *
0031  * Registering a profile allows applications to subscribe to *remote* services.
0032  * These must implement the GattProfile1 interface defined above.
0033  *
0034  * Registering a service allows applications to publish a *local* GATT service,
0035  * which then becomes available to remote devices. A GATT service is represented by
0036  * a D-Bus object hierarchy where the root node corresponds to a service and the
0037  * child nodes represent characteristics and descriptors that belong to that
0038  * service. Each node must implement one of GattService1, GattCharacteristic1,
0039  * or GattDescriptor1 interfaces described above, based on the attribute it
0040  * represents. Each node must also implement the standard D-Bus Properties
0041  * interface to expose their properties. These objects collectively represent a
0042  * GATT service definition.
0043  *
0044  * @see GattApplication
0045  */
0046 class BLUEZQT_EXPORT GattManager : public QObject
0047 {
0048     Q_OBJECT
0049 
0050 public:
0051     /**
0052      * Destroys a GattManager object.
0053      */
0054     ~GattManager() override;
0055 
0056     /**
0057      * Registers a local GATT services hierarchy as described
0058      * above (GATT Server) and/or GATT profiles (GATT Client).
0059      *
0060      * The application object path together with the D-Bus
0061      * system bus connection ID define the identification of
0062      * the application registering a GATT based
0063      * service or profile.
0064      *
0065      * Possible errors: org.bluez.Error.InvalidArguments
0066      *             org.bluez.Error.AlreadyExists
0067      *
0068      * @param application application to be registered
0069      * @return void pending call
0070      */
0071     PendingCall *registerApplication(GattApplication *application);
0072 
0073     /**
0074      * This unregisters the services that has been
0075      * previously registered. The object path parameter
0076      * must match the same value that has been used
0077      * on registration.
0078      *
0079      * Possible errors: org.bluez.Error.InvalidArguments
0080      *             org.bluez.Error.DoesNotExist
0081      *
0082      * @param application application to be unregistered
0083      * @return void pending call
0084      */
0085     PendingCall *unregisterApplication(GattApplication *application);
0086 
0087 private:
0088     BLUEZQT_NO_EXPORT explicit GattManager(const QString &path, QObject *parent = nullptr);
0089 
0090     std::unique_ptr<class GattManagerPrivate> const d;
0091 
0092     friend class AdapterPrivate;
0093 };
0094 
0095 } // namespace BluezQt
0096 
0097 #endif