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
qlowenergycontroller_darwin_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// Copyright (C) 2016 Javier S. Pedro <maemo@javispedro.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4#ifndef QLOWENERGYCONTROLLER_DARWIN_P_H
5#define QLOWENERGYCONTROLLER_DARWIN_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
21#include "darwin/btnotifier_p.h"
23#include "darwin/btraii_p.h"
24#include "qbluetoothuuid.h"
25
26#include <QtCore/qsharedpointer.h>
27#include <QtCore/qglobal.h>
28#include <QtCore/qstring.h>
29#include <QtCore/qmap.h>
30
31QT_BEGIN_NAMESPACE
32
33class QByteArray;
34
36{
37 friend class QLowEnergyController;
38 friend class QLowEnergyService;
39
41public:
44
45 void init() override;
46 bool lazyInit();
47 void connectToDevice() override;
48 void disconnectFromDevice() override;
49 void discoverServices() override;
50 void discoverServiceDetails(const QBluetoothUuid &serviceUuid,
51 QLowEnergyService::DiscoveryMode mode) override;
52
53 void readCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service,
54 const QLowEnergyHandle charHandle) override;
55 void readDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service,
56 const QLowEnergyHandle charHandle,
57 const QLowEnergyHandle descriptorHandle) override;
58
59 void writeCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service,
60 const QLowEnergyHandle charHandle, const QByteArray &newValue,
61 QLowEnergyService::WriteMode mode) override;
62 void writeDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service,
63 const QLowEnergyHandle charHandle,
64 const QLowEnergyHandle descriptorHandle,
65 const QByteArray &newValue) override;
66
67
68 void requestConnectionUpdate(const QLowEnergyConnectionParameters &params) override;
69 void addToGenericAttributeList(const QLowEnergyServiceData &service,
70 QLowEnergyHandle startHandle) override;
71
72 int mtu() const override;
73 void readRssi() override;
74
75 void startAdvertising(const QLowEnergyAdvertisingParameters &params,
76 const QLowEnergyAdvertisingData &advertisingData,
77 const QLowEnergyAdvertisingData &scanResponseData) override;
78 void stopAdvertising()override;
79 QLowEnergyService *addServiceHelper(const QLowEnergyServiceData &service) override;
80
81 // Valid - a central or peripheral instance was allocated, and this may also
82 // mean a proper usage description was provided/found:
83 bool isValid() const;
84
85private Q_SLOTS:
86 void _q_connected();
87 void _q_disconnected();
88
89 void _q_mtuChanged(int newValue);
90 void _q_serviceDiscoveryFinished();
91 void _q_serviceDetailsDiscoveryFinished(QSharedPointer<QLowEnergyServicePrivate> service);
92 void _q_servicesWereModified();
93
94 void _q_characteristicRead(QLowEnergyHandle charHandle, const QByteArray &value);
95 void _q_characteristicWritten(QLowEnergyHandle charHandle, const QByteArray &value);
96 void _q_characteristicUpdated(QLowEnergyHandle charHandle, const QByteArray &value);
97 void _q_descriptorRead(QLowEnergyHandle descHandle, const QByteArray &value);
98 void _q_descriptorWritten(QLowEnergyHandle charHandle, const QByteArray &value);
99 void _q_notificationEnabled(QLowEnergyHandle charHandle, bool enabled);
100
101 void _q_LEnotSupported();
102 void _q_CBManagerError(QLowEnergyController::Error error);
103 void _q_CBManagerError(const QBluetoothUuid &serviceUuid, QLowEnergyController::Error error);
104 void _q_CBManagerError(const QBluetoothUuid &serviceUuid, QLowEnergyService::ServiceError error);
105
106private:
107 void setNotifyValue(QSharedPointer<QLowEnergyServicePrivate> service,
108 QLowEnergyHandle charHandle, const QByteArray &newValue);
109
110 quint16 updateValueOfCharacteristic(QLowEnergyHandle charHandle,
111 const QByteArray &value,
112 bool appendValue);
113
114 quint16 updateValueOfDescriptor(QLowEnergyHandle charHandle,
115 QLowEnergyHandle descHandle,
116 const QByteArray &value,
117 bool appendValue);
118
119 bool connectSlots(DarwinBluetooth::LECBManagerNotifier *notifier);
120
121 DarwinBluetooth::ScopedPointer centralManager;
122 DarwinBluetooth::ScopedPointer peripheralManager;
123
125};
126
127QT_END_NAMESPACE
128
129#endif // QLOWENERGYCONTROLLER_DARWIN_P_H
#define QT_BT_MAC_AUTORELEASEPOOL
Definition btutility_p.h:78
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
void startAdvertising(const QLowEnergyAdvertisingParameters &params, const QLowEnergyAdvertisingData &advertisingData, const QLowEnergyAdvertisingData &scanResponseData) override
void writeCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QByteArray &newValue, QLowEnergyService::WriteMode mode) override
void discoverServiceDetails(const QBluetoothUuid &serviceUuid, QLowEnergyService::DiscoveryMode mode) override
QLowEnergyService * addServiceHelper(const QLowEnergyServiceData &service) override
void addToGenericAttributeList(const QLowEnergyServiceData &service, QLowEnergyHandle startHandle) override
void requestConnectionUpdate(const QLowEnergyConnectionParameters &params) override
void readCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle) override