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
qlowenergycontrollerbase_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 QLOWENERGYCONTROLLERPRIVATEBASE_P_H
5#define QLOWENERGYCONTROLLERPRIVATEBASE_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 <qglobal.h>
19#include <QtCore/qobject.h>
20
21#include <QtBluetooth/qlowenergycontroller.h>
22
24
25QT_BEGIN_NAMESPACE
26
27typedef QMap<QBluetoothUuid, QSharedPointer<QLowEnergyServicePrivate> > ServiceDataMap;
28
30{
32public:
33 // This class is required to enable selection of multiple
34 // alternative QLowEnergyControllerPrivate implementations on BlueZ.
35 // Bluez has a low level ATT protocol stack implementation and a DBus
36 // implementation.
37
40
41 // interface definition
42 virtual void init() = 0;
43 virtual void connectToDevice() = 0;
44 virtual void disconnectFromDevice() = 0;
45
46 virtual void discoverServices() = 0;
47 virtual void discoverServiceDetails(const QBluetoothUuid &service,
48 QLowEnergyService::DiscoveryMode mode) = 0;
49
50 virtual void readCharacteristic(
51 const QSharedPointer<QLowEnergyServicePrivate> service,
52 const QLowEnergyHandle charHandle) = 0;
53 virtual void readDescriptor(
54 const QSharedPointer<QLowEnergyServicePrivate> service,
55 const QLowEnergyHandle charHandle,
56 const QLowEnergyHandle descriptorHandle) = 0;
57
58 virtual void writeCharacteristic(
59 const QSharedPointer<QLowEnergyServicePrivate> service,
60 const QLowEnergyHandle charHandle,
61 const QByteArray &newValue,
62 QLowEnergyService::WriteMode writeMode) = 0;
63 virtual void writeDescriptor(
64 const QSharedPointer<QLowEnergyServicePrivate> service,
65 const QLowEnergyHandle charHandle,
66 const QLowEnergyHandle descriptorHandle,
67 const QByteArray &newValue) = 0;
68
69 virtual void startAdvertising(
70 const QLowEnergyAdvertisingParameters &params,
71 const QLowEnergyAdvertisingData &advertisingData,
72 const QLowEnergyAdvertisingData &scanResponseData) = 0;
73 virtual void stopAdvertising() = 0;
74
76 const QLowEnergyConnectionParameters & params) = 0;
77 virtual void addToGenericAttributeList(
78 const QLowEnergyServiceData &service,
79 QLowEnergyHandle startHandle) = 0;
80
81 virtual int mtu() const = 0;
82 virtual void readRssi();
83
84 virtual QLowEnergyService *addServiceHelper(
85 const QLowEnergyServiceData &service);
86
87 // common backend methods
89 void setError(QLowEnergyController::Error newError);
90 void setState(QLowEnergyController::ControllerState newState);
91
92 // public variables
95
96 // list of all found service uuids on remote device
98 // list of all found service uuids on local peripheral device
100
101 //common helper functions
103 QLowEnergyCharacteristic characteristicForHandle(QLowEnergyHandle handle);
104 QLowEnergyDescriptor descriptorForHandle(QLowEnergyHandle handle);
105 quint16 updateValueOfCharacteristic(QLowEnergyHandle charHandle,
106 const QByteArray &value,
107 bool appendValue);
108 quint16 updateValueOfDescriptor(QLowEnergyHandle charHandle,
109 QLowEnergyHandle descriptorHandle,
110 const QByteArray &value,
111 bool appendValue);
112 void invalidateServices();
113
114protected:
118
121
123
124 QString remoteName; // device name of the remote
125 QBluetoothUuid deviceUuid; // quite useless anywhere but Darwin (CoreBluetooth).
126
127 Q_DECLARE_PUBLIC(QLowEnergyController)
129};
130
131QT_END_NAMESPACE
132
133#endif // QLOWENERGYCONTROLLERPRIVATEBASE_P_H
void writeCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QByteArray &newValue, QLowEnergyService::WriteMode mode) override
void writeDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle, const QByteArray &newValue) override
void startAdvertising(const QLowEnergyAdvertisingParameters &params, const QLowEnergyAdvertisingData &advertisingData, const QLowEnergyAdvertisingData &scanResponseData) override
void readDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle) override
void discoverServiceDetails(const QBluetoothUuid &service, QLowEnergyService::DiscoveryMode mode) override
void readCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle) override
void requestConnectionUpdate(const QLowEnergyConnectionParameters &params) override
void addToGenericAttributeList(const QLowEnergyServiceData &service, QLowEnergyHandle startHandle) override
QLowEnergyCharacteristic characteristicForHandle(QLowEnergyHandle handle)
Returns a valid characteristic if the given handle is the handle of the characteristic itself or one ...
QSharedPointer< QLowEnergyServicePrivate > serviceForHandle(QLowEnergyHandle handle)
virtual int mtu() const =0
virtual void readDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle)=0
virtual void writeDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle, const QByteArray &newValue)=0
quint16 updateValueOfDescriptor(QLowEnergyHandle charHandle, QLowEnergyHandle descriptorHandle, const QByteArray &value, bool appendValue)
Returns the length of the updated descriptor value.
QLowEnergyDescriptor descriptorForHandle(QLowEnergyHandle handle)
Returns a valid descriptor if handle belongs to a descriptor; otherwise an invalid one.
virtual void readCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle)=0
virtual void disconnectFromDevice()=0
virtual void connectToDevice()=0
virtual void writeCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QByteArray &newValue, QLowEnergyService::WriteMode writeMode)=0
virtual void stopAdvertising()=0
void setError(QLowEnergyController::Error newError)
virtual void discoverServiceDetails(const QBluetoothUuid &service, QLowEnergyService::DiscoveryMode mode)=0
quint16 updateValueOfCharacteristic(QLowEnergyHandle charHandle, const QByteArray &value, bool appendValue)
Returns the length of the updated characteristic value.
virtual void requestConnectionUpdate(const QLowEnergyConnectionParameters &params)=0
void setState(QLowEnergyController::ControllerState newState)
virtual void discoverServices()=0
void registerQLowEnergyControllerMetaType()