blob: 3bd7ceb7bae4577a415b76394ac1c77e600cfb60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef BTPERIPHERALMANAGER_P_H
#define BTPERIPHERALMANAGER_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of internal files. This header file may change from version to version
// without notice, or even be removed.
//
// We mean it.
//
#include "btutility_p.h"
#include "qlowenergyserviceprivate_p.h"
#include "qbluetooth.h"
#include <QtCore/qsharedpointer.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qglobal.h>
#include <QtCore/qpair.h>
#include <QtCore/qmap.h>
#include <QtCore/private/qcore_mac_p.h>
#include <vector>
#include <deque>
#include <map>
#include <Foundation/Foundation.h>
#include <CoreBluetooth/CoreBluetooth.h>
QT_BEGIN_NAMESPACE
class QLowEnergyAdvertisingParameters;
class QLowEnergyAdvertisingData;
class QLowEnergyServiceData;
namespace DarwinBluetooth
{
class LECBManagerNotifier;
} // namespace DarwinBluetooth
QT_END_NAMESPACE
// Exposing names in a header is ugly, but constant QT_PREPEND_NAMESPACE is even worse ...
// After all, this header is to be included only in its own and controller's *.mm files.
QT_USE_NAMESPACE
using namespace DarwinBluetooth;
template<class Type>
using GenericLEMap = QMap<QLowEnergyHandle, Type>;
enum class PeripheralState
{
idle,
waitingForPowerOn,
advertising,
connected
};
struct UpdateRequest
{
UpdateRequest() = default;
UpdateRequest(QLowEnergyHandle handle, const ObjCStrongReference<NSData> &val)
: charHandle(handle),
value(val)
{
}
QLowEnergyHandle charHandle = {};
ObjCStrongReference<NSData> value;
};
using ValueRange = QPair<NSUInteger, NSUInteger>;
@interface QT_MANGLE_NAMESPACE(DarwinBTPeripheralManager) : NSObject<CBPeripheralManagerDelegate>
- (id)initWith:(LECBManagerNotifier *)notifier;
- (void)dealloc;
- (QSharedPointer<QLowEnergyServicePrivate>)addService:(const QLowEnergyServiceData &)data;
- (void) setParameters:(const QLowEnergyAdvertisingParameters &)parameters
data:(const QLowEnergyAdvertisingData &)data
scanResponse:(const QLowEnergyAdvertisingData &)scanResponse;
// To be executed on the Qt's special BTLE dispatch queue.
- (void)startAdvertising;
- (void)stopAdvertising;
- (void)detach;
- (void)write:(const QByteArray &)value
charHandle:(QLowEnergyHandle)charHandle;
// CBPeripheralManagerDelegate's callbacks (BTLE queue).
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral;
- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral
error:(NSError *)error;
- (void)peripheralManager:(CBPeripheralManager *)peripheral
didAddService:(CBService *)service error:(NSError *)error;
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central
didSubscribeToCharacteristic:(CBCharacteristic *)characteristic;
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central
didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic;
- (void)peripheralManager:(CBPeripheralManager *)peripheral
didReceiveReadRequest:(CBATTRequest *)request;
- (void)peripheralManager:(CBPeripheralManager *)peripheral
didReceiveWriteRequests:(NSArray *)requests;
- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)peripheral;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(DarwinBTPeripheralManager);
#endif
|