Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlowenergycontroller_bluezdbus_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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 QLOWENERGYCONTROLLERPRIVATEDBUS_P_H
5#define QLOWENERGYCONTROLLERPRIVATEDBUS_P_H
6
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
22
23#include <QtDBus/QDBusObjectPath>
24
33
35
39
41{
43public:
44 QLowEnergyControllerPrivateBluezDBus(const QString& adapterPathWithPeripheralSupport = {});
46
47 void init() override;
48 void connectToDevice() override;
49 void disconnectFromDevice() override;
50
51 void discoverServices() override;
52 void discoverServiceDetails(const QBluetoothUuid &service,
54
56 const QSharedPointer<QLowEnergyServicePrivate> service,
57 const QLowEnergyHandle charHandle) override;
58 void readDescriptor(
59 const QSharedPointer<QLowEnergyServicePrivate> service,
60 const QLowEnergyHandle charHandle,
61 const QLowEnergyHandle descriptorHandle) override;
62
64 const QSharedPointer<QLowEnergyServicePrivate> service,
65 const QLowEnergyHandle charHandle,
66 const QByteArray &newValue,
67 QLowEnergyService::WriteMode writeMode) override;
68 void writeDescriptor(
69 const QSharedPointer<QLowEnergyServicePrivate> service,
70 const QLowEnergyHandle charHandle,
71 const QLowEnergyHandle descriptorHandle,
72 const QByteArray &newValue) override;
73
76 const QLowEnergyAdvertisingData &advertisingData,
77 const QLowEnergyAdvertisingData &scanResponseData) override;
78 void stopAdvertising() override;
79
81 const QLowEnergyConnectionParameters & params) override;
83 const QLowEnergyServiceData &service,
84 QLowEnergyHandle startHandle) override;
85
86 int mtu() const override;
87
88private:
89 void connectToDeviceHelper();
90 void resetController();
91
92 void scheduleNextJob();
93
94private slots:
95 void devicePropertiesChanged(const QString &interface, const QVariantMap &changedProperties,
96 const QStringList &invalidatedProperties);
97 void characteristicPropertiesChanged(QLowEnergyHandle charHandle, const QString &interface,
98 const QVariantMap &changedProperties,
99 const QStringList &invalidatedProperties);
100 void interfacesRemoved(const QDBusObjectPath &objectPath, const QStringList &interfaces);
101
102 void onCharReadFinished(QDBusPendingCallWatcher *call);
103 void onDescReadFinished(QDBusPendingCallWatcher *call);
104 void onCharWriteFinished(QDBusPendingCallWatcher *call);
105 void onDescWriteFinished(QDBusPendingCallWatcher *call);
106private:
107
108 OrgBluezAdapter1Interface* adapter{};
109 OrgBluezDevice1Interface* device{};
112 QString adapterPathWithPeripheralSupport;
113
114 int remoteMtu{-1};
115 QtBluezPeripheralApplication* peripheralApplication{};
116 QtBluezPeripheralConnectionManager* peripheralConnectionManager{};
117 QLeDBusAdvertiser *advertiser{};
118 void handleAdvertisingError();
119 void handlePeripheralApplicationError();
120 void handlePeripheralApplicationRegistered();
121 void handlePeripheralConnectivityChanged(bool connected);
122 void handlePeripheralCharacteristicValueUpdate(QLowEnergyHandle handle,
123 const QByteArray& value);
124 void handlePeripheralDescriptorValueUpdate(QLowEnergyHandle characteristicHandle,
125 QLowEnergyHandle descriptorHandle,
126 const QByteArray& value);
127 void handlePeripheralRemoteDeviceChanged(const QBluetoothAddress& address,
128 const QString& name,
129 quint16 mtu);
130 bool pendingConnect = false;
131 bool disconnectSignalRequired = false;
132
133 struct GattCharacteristic
134 {
135 QSharedPointer<OrgBluezGattCharacteristic1Interface> characteristic;
136 QSharedPointer<OrgFreedesktopDBusPropertiesInterface> charMonitor;
137 QList<QSharedPointer<OrgBluezGattDescriptor1Interface>> descriptors;
138 };
139
140 struct GattService
141 {
142 QString servicePath;
143 QList<GattCharacteristic> characteristics;
144
145 bool hasBatteryService = false;
146 QSharedPointer<OrgBluezBattery1Interface> batteryInterface;
147 };
148
149 QHash<QBluetoothUuid, GattService> dbusServices;
150 QLowEnergyHandle runningHandle = 1;
151
152 struct GattJob {
153 enum JobFlag {
154 Unset = 0x00,
155 CharRead = 0x01,
156 CharWrite = 0x02,
157 DescRead = 0x04,
158 DescWrite = 0x08,
159 ServiceDiscovery = 0x10,
160 LastServiceDiscovery = 0x20
161 };
162 Q_DECLARE_FLAGS(JobFlags, JobFlag)
163
164 JobFlags flags = GattJob::Unset;
168 QSharedPointer<QLowEnergyServicePrivate> service;
169 };
170
171 QList<GattJob> jobs;
172 bool jobPending = false;
173
174 void prepareNextJob();
175 void discoverBatteryServiceDetails(GattService &dbusData,
176 QSharedPointer<QLowEnergyServicePrivate> serviceData);
177 void executeClose(QLowEnergyController::Error newError);
178};
179
181
182#endif // QLOWENERGYCONTROLLERPRIVATEDBUS_P_H
bool connected
\inmodule QtBluetooth
\inmodule QtBluetooth
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtDBus
The QLowEnergyAdvertisingData class represents the data to be broadcast during Bluetooth Low Energy a...
The QLowEnergyAdvertisingParameters class represents the parameters used for Bluetooth Low Energy adv...
The QLowEnergyConnectionParameters class is used when requesting or reporting an update of the parame...
void requestConnectionUpdate(const QLowEnergyConnectionParameters &params) override
void startAdvertising(const QLowEnergyAdvertisingParameters &params, const QLowEnergyAdvertisingData &advertisingData, const QLowEnergyAdvertisingData &scanResponseData) override
void discoverServiceDetails(const QBluetoothUuid &service, QLowEnergyService::DiscoveryMode mode) override
void addToGenericAttributeList(const QLowEnergyServiceData &service, QLowEnergyHandle startHandle) override
void writeCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QByteArray &newValue, QLowEnergyService::WriteMode writeMode) override
void writeDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle, const QByteArray &newValue) override
void readDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle) override
QLowEnergyControllerPrivateBluezDBus(const QString &adapterPathWithPeripheralSupport={})
void readCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle) override
Error
Indicates all possible error conditions found during the controller's existence.
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth.
DiscoveryMode
This enum lists service discovery modes.
WriteMode
This enum describes the mode to be used when writing a characteristic value.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
quint16 QLowEnergyHandle
Definition qbluetooth.h:42
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char * interface
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
GLuint64 GLenum void * handle
GLenum mode
GLbitfield flags
GLuint name
void ** params
GLuint GLuint64EXT address
#define Q_OBJECT
#define slots
unsigned short quint16
Definition qtypes.h:48