Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
bluezperipheralapplication_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef BLUEZ_PERIPHERAL_APPLICATION_P_H
5#define BLUEZ_PERIPHERAL_APPLICATION_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtBluetooth/private/qlowenergycontroller_bluezdbus_p.h>
20
21#include <QtBluetooth/QBluetoothAddress>
22#include <QtCore/QCoreApplication>
23
24namespace QtBluetoothPrivate {
25
28
29} // namespace QtBluetoothPrivate
30
31QT_BEGIN_NAMESPACE
32
33class QLowEnergyControllerPrivateBluezDBus;
38
40{
42
43public:
46
47 // Register the application and its services to DBus & Bluez
49 // Unregister the application and its services from DBus & Bluez.
50 // Calling this doesn't invalidate the services
52 // Unregister and release all resources, invalidates services
53 void reset();
54
55 void addService(const QLowEnergyServiceData &serviceData,
56 QSharedPointer<QLowEnergyServicePrivate> servicePrivate,
57 QLowEnergyHandle serviceHandle);
58
59 // Call these when the user application has updated the attribute value
60 // Returns whether the new value was accepted
61 bool localCharacteristicWrite(QLowEnergyHandle handle, const QByteArray& value);
62 bool localDescriptorWrite(QLowEnergyHandle handle, const QByteArray& value);
63
64 // Returns true if application has services and is not registered
65 bool registrationNeeded();
66
67 // org.freedesktop.DBus.ObjectManager
68 Q_INVOKABLE ManagedObjectList GetManagedObjects();
69
72 void registered();
73
74 // Emitted when remote device reads a characteristic
75 void remoteDeviceAccessEvent(const QString& remoteDeviceObjectPath, quint16 mtu);
76
77 // These are emitted when remote has written a new value
78 void characteristicValueUpdatedByRemote(QLowEnergyHandle handle, const QByteArray& value);
79 void descriptorValueUpdatedByRemote(QLowEnergyHandle characteristicHandle,
80 QLowEnergyHandle descriptorHandle,
81 const QByteArray& value);
82private:
83 void registerServices();
84 void unregisterServices();
85
86 QLowEnergyHandle handleForCharacteristic(QBluetoothUuid uuid,
87 QSharedPointer<QLowEnergyServicePrivate> service);
88 QLowEnergyHandle handleForDescriptor(QBluetoothUuid uuid,
89 QSharedPointer<QLowEnergyServicePrivate> service,
90 QLowEnergyHandle characteristicHandle);
91
92 QMap<QLowEnergyHandle, QtBluezPeripheralService*> m_services;
93 QMap<QLowEnergyHandle, QtBluezPeripheralCharacteristic*> m_characteristics;
94 QMap<QLowEnergyHandle, QtBluezPeripheralDescriptor*> m_descriptors;
95
96 QString m_objectPath;
99 bool m_applicationRegistered{false};
100};
101
102QT_END_NAMESPACE
103
104#endif
QMap< QDBusObjectPath, InterfaceList > ManagedObjectList
static constexpr QLatin1String appObjectPathTemplate
bool localDescriptorWrite(QLowEnergyHandle handle, const QByteArray &value)
void remoteDeviceAccessEvent(const QString &remoteDeviceObjectPath, quint16 mtu)
void addService(const QLowEnergyServiceData &serviceData, QSharedPointer< QLowEnergyServicePrivate > servicePrivate, QLowEnergyHandle serviceHandle)
void characteristicValueUpdatedByRemote(QLowEnergyHandle handle, const QByteArray &value)
bool localCharacteristicWrite(QLowEnergyHandle handle, const QByteArray &value)
void descriptorValueUpdatedByRemote(QLowEnergyHandle characteristicHandle, QLowEnergyHandle descriptorHandle, const QByteArray &value)