User | Revision | Line number | New contents of line |
switches |
0:0e018d759a2a
|
1
|
/* mbed Microcontroller Library
|
switches |
0:0e018d759a2a
|
2
|
* Copyright (c) 2006-2013 ARM Limited
|
switches |
0:0e018d759a2a
|
3
|
*
|
switches |
0:0e018d759a2a
|
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
switches |
0:0e018d759a2a
|
5
|
* you may not use this file except in compliance with the License.
|
switches |
0:0e018d759a2a
|
6
|
* You may obtain a copy of the License at
|
switches |
0:0e018d759a2a
|
7
|
*
|
switches |
0:0e018d759a2a
|
8
|
* http://www.apache.org/licenses/LICENSE-2.0
|
switches |
0:0e018d759a2a
|
9
|
*
|
switches |
0:0e018d759a2a
|
10
|
* Unless required by applicable law or agreed to in writing, software
|
switches |
0:0e018d759a2a
|
11
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
switches |
0:0e018d759a2a
|
12
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
switches |
0:0e018d759a2a
|
13
|
* See the License for the specific language governing permissions and
|
switches |
0:0e018d759a2a
|
14
|
* limitations under the License.
|
switches |
0:0e018d759a2a
|
15
|
*/
|
switches |
0:0e018d759a2a
|
16
|
|
switches |
0:0e018d759a2a
|
17
|
#ifndef __GATT_CLIENT_H__
|
switches |
0:0e018d759a2a
|
18
|
#define __GATT_CLIENT_H__
|
switches |
0:0e018d759a2a
|
19
|
|
switches |
0:0e018d759a2a
|
20
|
#include "Gap.h"
|
switches |
0:0e018d759a2a
|
21
|
#include "GattAttribute.h"
|
switches |
0:0e018d759a2a
|
22
|
#include "ServiceDiscovery.h"
|
switches |
0:0e018d759a2a
|
23
|
#include "CharacteristicDescriptorDiscovery.h"
|
switches |
0:0e018d759a2a
|
24
|
|
switches |
0:0e018d759a2a
|
25
|
#include "GattCallbackParamTypes.h"
|
switches |
0:0e018d759a2a
|
26
|
|
switches |
0:0e018d759a2a
|
27
|
#include "CallChainOfFunctionPointersWithContext.h"
|
switches |
0:0e018d759a2a
|
28
|
|
switches |
0:0e018d759a2a
|
29
|
class GattClient {
|
switches |
0:0e018d759a2a
|
30
|
public:
|
switches |
0:0e018d759a2a
|
31
|
/**
|
switches |
0:0e018d759a2a
|
32
|
* Type for the registered callbacks added to the data read callchain.
|
switches |
0:0e018d759a2a
|
33
|
* Refer to GattClient::onDataRead().
|
switches |
0:0e018d759a2a
|
34
|
*/
|
switches |
0:0e018d759a2a
|
35
|
typedef FunctionPointerWithContext<const GattReadCallbackParams*> ReadCallback_t;
|
switches |
0:0e018d759a2a
|
36
|
/**
|
switches |
0:0e018d759a2a
|
37
|
* Type for the data read event callchain. Refer to GattClient::onDataRead().
|
switches |
0:0e018d759a2a
|
38
|
*/
|
switches |
0:0e018d759a2a
|
39
|
typedef CallChainOfFunctionPointersWithContext<const GattReadCallbackParams*> ReadCallbackChain_t;
|
switches |
0:0e018d759a2a
|
40
|
|
switches |
0:0e018d759a2a
|
41
|
/**
|
switches |
0:0e018d759a2a
|
42
|
* Enumerator for write operations.
|
switches |
0:0e018d759a2a
|
43
|
*/
|
switches |
0:0e018d759a2a
|
44
|
enum WriteOp_t {
|
switches |
0:0e018d759a2a
|
45
|
GATT_OP_WRITE_REQ = 0x01, /**< Write request. */
|
switches |
0:0e018d759a2a
|
46
|
GATT_OP_WRITE_CMD = 0x02, /**< Write command. */
|
switches |
0:0e018d759a2a
|
47
|
};
|
switches |
0:0e018d759a2a
|
48
|
|
switches |
0:0e018d759a2a
|
49
|
/**
|
switches |
0:0e018d759a2a
|
50
|
* Type for the registered callbacks added to the data write callchain.
|
switches |
0:0e018d759a2a
|
51
|
* Refer to GattClient::onDataWrite().
|
switches |
0:0e018d759a2a
|
52
|
*/
|
switches |
0:0e018d759a2a
|
53
|
typedef FunctionPointerWithContext<const GattWriteCallbackParams*> WriteCallback_t;
|
switches |
0:0e018d759a2a
|
54
|
/**
|
switches |
0:0e018d759a2a
|
55
|
* Type for the data write event callchain. Refer to GattClient::onDataWrite().
|
switches |
0:0e018d759a2a
|
56
|
*/
|
switches |
0:0e018d759a2a
|
57
|
typedef CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams*> WriteCallbackChain_t;
|
switches |
0:0e018d759a2a
|
58
|
|
switches |
0:0e018d759a2a
|
59
|
/**
|
switches |
0:0e018d759a2a
|
60
|
* Type for the registered callbacks added to the update event callchain.
|
switches |
0:0e018d759a2a
|
61
|
* Refer to GattClient::onHVX().
|
switches |
0:0e018d759a2a
|
62
|
*/
|
switches |
0:0e018d759a2a
|
63
|
typedef FunctionPointerWithContext<const GattHVXCallbackParams*> HVXCallback_t;
|
switches |
0:0e018d759a2a
|
64
|
/**
|
switches |
0:0e018d759a2a
|
65
|
* Type for the update event callchain. Refer to GattClient::onHVX().
|
switches |
0:0e018d759a2a
|
66
|
*/
|
switches |
0:0e018d759a2a
|
67
|
typedef CallChainOfFunctionPointersWithContext<const GattHVXCallbackParams*> HVXCallbackChain_t;
|
switches |
0:0e018d759a2a
|
68
|
|
switches |
0:0e018d759a2a
|
69
|
/**
|
switches |
0:0e018d759a2a
|
70
|
* Type for the registered callbacks added to the shutdown callchain.
|
switches |
0:0e018d759a2a
|
71
|
* Refer to GattClient::onShutdown().
|
switches |
0:0e018d759a2a
|
72
|
*/
|
switches |
0:0e018d759a2a
|
73
|
typedef FunctionPointerWithContext<const GattClient *> GattClientShutdownCallback_t;
|
switches |
0:0e018d759a2a
|
74
|
/**
|
switches |
0:0e018d759a2a
|
75
|
* Type for the shutdown event callchain. Refer to GattClient::onShutown().
|
switches |
0:0e018d759a2a
|
76
|
*/
|
switches |
0:0e018d759a2a
|
77
|
typedef CallChainOfFunctionPointersWithContext<const GattClient *> GattClientShutdownCallbackChain_t;
|
switches |
0:0e018d759a2a
|
78
|
|
switches |
0:0e018d759a2a
|
79
|
/*
|
switches |
0:0e018d759a2a
|
80
|
* The following functions are meant to be overridden in the platform-specific sub-class.
|
switches |
0:0e018d759a2a
|
81
|
*/
|
switches |
0:0e018d759a2a
|
82
|
public:
|
switches |
0:0e018d759a2a
|
83
|
/**
|
switches |
0:0e018d759a2a
|
84
|
* Launch service discovery. Once launched, application callbacks will be
|
switches |
0:0e018d759a2a
|
85
|
* invoked for matching services or characteristics. isServiceDiscoveryActive()
|
switches |
0:0e018d759a2a
|
86
|
* can be used to determine status, and a termination callback (if one was set up)
|
switches |
0:0e018d759a2a
|
87
|
* will be invoked at the end. Service discovery can be terminated prematurely,
|
switches |
0:0e018d759a2a
|
88
|
* if needed, using terminateServiceDiscovery().
|
switches |
0:0e018d759a2a
|
89
|
*
|
switches |
0:0e018d759a2a
|
90
|
* @param[in] connectionHandle
|
switches |
0:0e018d759a2a
|
91
|
* Handle for the connection with the peer.
|
switches |
0:0e018d759a2a
|
92
|
* @param[in] sc
|
switches |
0:0e018d759a2a
|
93
|
* This is the application callback for a matching service. Taken as
|
switches |
0:0e018d759a2a
|
94
|
* NULL by default. Note: service discovery may still be active
|
switches |
0:0e018d759a2a
|
95
|
* when this callback is issued; calling asynchronous BLE-stack
|
switches |
0:0e018d759a2a
|
96
|
* APIs from within this application callback might cause the
|
switches |
0:0e018d759a2a
|
97
|
* stack to abort service discovery. If this becomes an issue, it
|
switches |
0:0e018d759a2a
|
98
|
* may be better to make a local copy of the discoveredService and
|
switches |
0:0e018d759a2a
|
99
|
* wait for service discovery to terminate before operating on the
|
switches |
0:0e018d759a2a
|
100
|
* service.
|
switches |
0:0e018d759a2a
|
101
|
* @param[in] cc
|
switches |
0:0e018d759a2a
|
102
|
* This is the application callback for a matching characteristic.
|
switches |
0:0e018d759a2a
|
103
|
* Taken as NULL by default. Note: service discovery may still be
|
switches |
0:0e018d759a2a
|
104
|
* active when this callback is issued; calling asynchronous
|
switches |
0:0e018d759a2a
|
105
|
* BLE-stack APIs from within this application callback might cause
|
switches |
0:0e018d759a2a
|
106
|
* the stack to abort service discovery. If this becomes an issue,
|
switches |
0:0e018d759a2a
|
107
|
* it may be better to make a local copy of the discoveredCharacteristic
|
switches |
0:0e018d759a2a
|
108
|
* and wait for service discovery to terminate before operating on the
|
switches |
0:0e018d759a2a
|
109
|
* characteristic.
|
switches |
0:0e018d759a2a
|
110
|
* @param[in] matchingServiceUUID
|
switches |
0:0e018d759a2a
|
111
|
* UUID-based filter for specifying a service in which the application is
|
switches |
0:0e018d759a2a
|
112
|
* interested. By default it is set as the wildcard UUID_UNKNOWN,
|
switches |
0:0e018d759a2a
|
113
|
* in which case it matches all services. If characteristic-UUID
|
switches |
0:0e018d759a2a
|
114
|
* filter (below) is set to the wildcard value, then a service
|
switches |
0:0e018d759a2a
|
115
|
* callback will be invoked for the matching service (or for every
|
switches |
0:0e018d759a2a
|
116
|
* service if the service filter is a wildcard).
|
switches |
0:0e018d759a2a
|
117
|
* @param[in] matchingCharacteristicUUIDIn
|
switches |
0:0e018d759a2a
|
118
|
* UUID-based filter for specifying characteristic in which the application
|
switches |
0:0e018d759a2a
|
119
|
* is interested. By default it is set as the wildcard UUID_UKNOWN
|
switches |
0:0e018d759a2a
|
120
|
* to match against any characteristic. If both service-UUID
|
switches |
0:0e018d759a2a
|
121
|
* filter and characteristic-UUID filter are used with non-wildcard
|
switches |
0:0e018d759a2a
|
122
|
* values, then only a single characteristic callback is
|
switches |
0:0e018d759a2a
|
123
|
* invoked for the matching characteristic.
|
switches |
0:0e018d759a2a
|
124
|
*
|
switches |
0:0e018d759a2a
|
125
|
* @note Using wildcard values for both service-UUID and characteristic-
|
switches |
0:0e018d759a2a
|
126
|
* UUID will result in complete service discovery: callbacks being
|
switches |
0:0e018d759a2a
|
127
|
* called for every service and characteristic.
|
switches |
0:0e018d759a2a
|
128
|
*
|
switches |
0:0e018d759a2a
|
129
|
* @note Providing NULL for the characteristic callback will result in
|
switches |
0:0e018d759a2a
|
130
|
* characteristic discovery being skipped for each matching
|
switches |
0:0e018d759a2a
|
131
|
* service. This allows for an inexpensive method to discover only
|
switches |
0:0e018d759a2a
|
132
|
* services.
|
switches |
0:0e018d759a2a
|
133
|
*
|
switches |
0:0e018d759a2a
|
134
|
* @return
|
switches |
0:0e018d759a2a
|
135
|
* BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
|
switches |
0:0e018d759a2a
|
136
|
*/
|
switches |
0:0e018d759a2a
|
137
|
virtual ble_error_t launchServiceDiscovery(Gap::Handle_t connectionHandle,
|
switches |
0:0e018d759a2a
|
138
|
ServiceDiscovery::ServiceCallback_t sc = NULL,
|
switches |
0:0e018d759a2a
|
139
|
ServiceDiscovery::CharacteristicCallback_t cc = NULL,
|
switches |
0:0e018d759a2a
|
140
|
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
|
switches |
0:0e018d759a2a
|
141
|
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) {
|
switches |
0:0e018d759a2a
|
142
|
/* Avoid compiler warnings about unused variables. */
|
switches |
0:0e018d759a2a
|
143
|
(void)connectionHandle;
|
switches |
0:0e018d759a2a
|
144
|
(void)sc;
|
switches |
0:0e018d759a2a
|
145
|
(void)cc;
|
switches |
0:0e018d759a2a
|
146
|
(void)matchingServiceUUID;
|
switches |
0:0e018d759a2a
|
147
|
(void)matchingCharacteristicUUIDIn;
|
switches |
0:0e018d759a2a
|
148
|
|
switches |
0:0e018d759a2a
|
149
|
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
150
|
}
|
switches |
0:0e018d759a2a
|
151
|
|
switches |
0:0e018d759a2a
|
152
|
/**
|
switches |
0:0e018d759a2a
|
153
|
* Launch service discovery for services. Once launched, service discovery will remain
|
switches |
0:0e018d759a2a
|
154
|
* active with service-callbacks being issued back into the application for matching
|
switches |
0:0e018d759a2a
|
155
|
* services. isServiceDiscoveryActive() can be used to
|
switches |
0:0e018d759a2a
|
156
|
* determine status, and a termination callback (if set up) will be invoked
|
switches |
0:0e018d759a2a
|
157
|
* at the end. Service discovery can be terminated prematurely, if needed,
|
switches |
0:0e018d759a2a
|
158
|
* using terminateServiceDiscovery().
|
switches |
0:0e018d759a2a
|
159
|
*
|
switches |
0:0e018d759a2a
|
160
|
* @param[in] connectionHandle
|
switches |
0:0e018d759a2a
|
161
|
* Handle for the connection with the peer.
|
switches |
0:0e018d759a2a
|
162
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
163
|
* This is the application callback for a matching service.
|
switches |
0:0e018d759a2a
|
164
|
* Note: service discovery may still be active
|
switches |
0:0e018d759a2a
|
165
|
* when this callback is issued; calling asynchronous BLE-stack
|
switches |
0:0e018d759a2a
|
166
|
* APIs from within this application callback might cause the
|
switches |
0:0e018d759a2a
|
167
|
* stack to abort service discovery. If this becomes an issue, it
|
switches |
0:0e018d759a2a
|
168
|
* may be better to make a local copy of the discoveredService and
|
switches |
0:0e018d759a2a
|
169
|
* wait for service discovery to terminate before operating on the
|
switches |
0:0e018d759a2a
|
170
|
* service.
|
switches |
0:0e018d759a2a
|
171
|
* @param[in] matchingServiceUUID
|
switches |
0:0e018d759a2a
|
172
|
* UUID-based filter for specifying a service in which the application is
|
switches |
0:0e018d759a2a
|
173
|
* interested. By default it is set as the wildcard UUID_UNKNOWN,
|
switches |
0:0e018d759a2a
|
174
|
* in which case it matches all services.
|
switches |
0:0e018d759a2a
|
175
|
*
|
switches |
0:0e018d759a2a
|
176
|
* @return
|
switches |
0:0e018d759a2a
|
177
|
* BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
|
switches |
0:0e018d759a2a
|
178
|
*/
|
switches |
0:0e018d759a2a
|
179
|
virtual ble_error_t discoverServices(Gap::Handle_t connectionHandle,
|
switches |
0:0e018d759a2a
|
180
|
ServiceDiscovery::ServiceCallback_t callback,
|
switches |
0:0e018d759a2a
|
181
|
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) {
|
switches |
0:0e018d759a2a
|
182
|
return launchServiceDiscovery(connectionHandle, callback, NULL, matchingServiceUUID); /* We take advantage of the property
|
switches |
0:0e018d759a2a
|
183
|
* that providing NULL for the characteristic callback will result in
|
switches |
0:0e018d759a2a
|
184
|
* characteristic discovery being skipped for each matching
|
switches |
0:0e018d759a2a
|
185
|
* service. This allows for an inexpensive method to discover only
|
switches |
0:0e018d759a2a
|
186
|
* services. Porters are free to override this. */
|
switches |
0:0e018d759a2a
|
187
|
}
|
switches |
0:0e018d759a2a
|
188
|
|
switches |
0:0e018d759a2a
|
189
|
/**
|
switches |
0:0e018d759a2a
|
190
|
* Launch service discovery for services. Once launched, service discovery will remain
|
switches |
0:0e018d759a2a
|
191
|
* active with service-callbacks being issued back into the application for matching
|
switches |
0:0e018d759a2a
|
192
|
* services. isServiceDiscoveryActive() can be used to
|
switches |
0:0e018d759a2a
|
193
|
* determine status, and a termination callback (if set up) will be invoked
|
switches |
0:0e018d759a2a
|
194
|
* at the end. Service discovery can be terminated prematurely, if needed,
|
switches |
0:0e018d759a2a
|
195
|
* using terminateServiceDiscovery().
|
switches |
0:0e018d759a2a
|
196
|
*
|
switches |
0:0e018d759a2a
|
197
|
* @param[in] connectionHandle
|
switches |
0:0e018d759a2a
|
198
|
* Handle for the connection with the peer.
|
switches |
0:0e018d759a2a
|
199
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
200
|
* This is the application callback for a matching service.
|
switches |
0:0e018d759a2a
|
201
|
* Note: service discovery may still be active
|
switches |
0:0e018d759a2a
|
202
|
* when this callback is issued; calling asynchronous BLE-stack
|
switches |
0:0e018d759a2a
|
203
|
* APIs from within this application callback might cause the
|
switches |
0:0e018d759a2a
|
204
|
* stack to abort service discovery. If this becomes an issue, it
|
switches |
0:0e018d759a2a
|
205
|
* may be better to make a local copy of the discoveredService and
|
switches |
0:0e018d759a2a
|
206
|
* wait for service discovery to terminate before operating on the
|
switches |
0:0e018d759a2a
|
207
|
* service.
|
switches |
0:0e018d759a2a
|
208
|
* @param[in] startHandle, endHandle
|
switches |
0:0e018d759a2a
|
209
|
* Handle range within which to limit the search.
|
switches |
0:0e018d759a2a
|
210
|
*
|
switches |
0:0e018d759a2a
|
211
|
* @return
|
switches |
0:0e018d759a2a
|
212
|
* BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
|
switches |
0:0e018d759a2a
|
213
|
*/
|
switches |
0:0e018d759a2a
|
214
|
virtual ble_error_t discoverServices(Gap::Handle_t connectionHandle,
|
switches |
0:0e018d759a2a
|
215
|
ServiceDiscovery::ServiceCallback_t callback,
|
switches |
0:0e018d759a2a
|
216
|
GattAttribute::Handle_t startHandle,
|
switches |
0:0e018d759a2a
|
217
|
GattAttribute::Handle_t endHandle) {
|
switches |
0:0e018d759a2a
|
218
|
/* Avoid compiler warnings about unused variables. */
|
switches |
0:0e018d759a2a
|
219
|
(void)connectionHandle;
|
switches |
0:0e018d759a2a
|
220
|
(void)callback;
|
switches |
0:0e018d759a2a
|
221
|
(void)startHandle;
|
switches |
0:0e018d759a2a
|
222
|
(void)endHandle;
|
switches |
0:0e018d759a2a
|
223
|
|
switches |
0:0e018d759a2a
|
224
|
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
225
|
}
|
switches |
0:0e018d759a2a
|
226
|
|
switches |
0:0e018d759a2a
|
227
|
/**
|
switches |
0:0e018d759a2a
|
228
|
* Check if service-discovery is currently active.
|
switches |
0:0e018d759a2a
|
229
|
*
|
switches |
0:0e018d759a2a
|
230
|
* @return true if service-discovery is active, false otherwise.
|
switches |
0:0e018d759a2a
|
231
|
*/
|
switches |
0:0e018d759a2a
|
232
|
virtual bool isServiceDiscoveryActive(void) const {
|
switches |
0:0e018d759a2a
|
233
|
return false; /* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
234
|
}
|
switches |
0:0e018d759a2a
|
235
|
|
switches |
0:0e018d759a2a
|
236
|
/**
|
switches |
0:0e018d759a2a
|
237
|
* Terminate an ongoing service discovery. This should result in an
|
switches |
0:0e018d759a2a
|
238
|
* invocation of TerminationCallback if service-discovery is active.
|
switches |
0:0e018d759a2a
|
239
|
*/
|
switches |
0:0e018d759a2a
|
240
|
virtual void terminateServiceDiscovery(void) {
|
switches |
0:0e018d759a2a
|
241
|
/* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
242
|
}
|
switches |
0:0e018d759a2a
|
243
|
|
switches |
0:0e018d759a2a
|
244
|
/**
|
switches |
0:0e018d759a2a
|
245
|
* Initiate a GATT Client read procedure by attribute-handle.
|
switches |
0:0e018d759a2a
|
246
|
*
|
switches |
0:0e018d759a2a
|
247
|
* @param[in] connHandle
|
switches |
0:0e018d759a2a
|
248
|
* Handle for the connection with the peer.
|
switches |
0:0e018d759a2a
|
249
|
* @param[in] attributeHandle
|
switches |
0:0e018d759a2a
|
250
|
* Handle of the attribute to read data from.
|
switches |
0:0e018d759a2a
|
251
|
* @param[in] offset
|
switches |
0:0e018d759a2a
|
252
|
* The offset from the start of the attribute value to be read.
|
switches |
0:0e018d759a2a
|
253
|
*
|
switches |
0:0e018d759a2a
|
254
|
* @return
|
switches |
0:0e018d759a2a
|
255
|
* BLE_ERROR_NONE if read procedure was successfully started.
|
switches |
0:0e018d759a2a
|
256
|
*/
|
switches |
0:0e018d759a2a
|
257
|
virtual ble_error_t read(Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const {
|
switches |
0:0e018d759a2a
|
258
|
/* Avoid compiler warnings about unused variables. */
|
switches |
0:0e018d759a2a
|
259
|
(void)connHandle;
|
switches |
0:0e018d759a2a
|
260
|
(void)attributeHandle;
|
switches |
0:0e018d759a2a
|
261
|
(void)offset;
|
switches |
0:0e018d759a2a
|
262
|
|
switches |
0:0e018d759a2a
|
263
|
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
264
|
}
|
switches |
0:0e018d759a2a
|
265
|
|
switches |
0:0e018d759a2a
|
266
|
/**
|
switches |
0:0e018d759a2a
|
267
|
* Initiate a GATT Client write procedure.
|
switches |
0:0e018d759a2a
|
268
|
*
|
switches |
0:0e018d759a2a
|
269
|
* @param[in] cmd
|
switches |
0:0e018d759a2a
|
270
|
* Command can be either a write-request (which generates a
|
switches |
0:0e018d759a2a
|
271
|
* matching response from the peripheral), or a write-command
|
switches |
0:0e018d759a2a
|
272
|
* (which doesn't require the connected peer to respond).
|
switches |
0:0e018d759a2a
|
273
|
* @param[in] connHandle
|
switches |
0:0e018d759a2a
|
274
|
* Connection handle.
|
switches |
0:0e018d759a2a
|
275
|
* @param[in] attributeHandle
|
switches |
0:0e018d759a2a
|
276
|
* Handle for the target attribtue on the remote GATT server.
|
switches |
0:0e018d759a2a
|
277
|
* @param[in] length
|
switches |
0:0e018d759a2a
|
278
|
* Length of the new value.
|
switches |
0:0e018d759a2a
|
279
|
* @param[in] value
|
switches |
0:0e018d759a2a
|
280
|
* New value being written.
|
switches |
0:0e018d759a2a
|
281
|
*
|
switches |
0:0e018d759a2a
|
282
|
* @return
|
switches |
0:0e018d759a2a
|
283
|
* BLE_ERROR_NONE if write procedure was successfully started.
|
switches |
0:0e018d759a2a
|
284
|
*/
|
switches |
0:0e018d759a2a
|
285
|
virtual ble_error_t write(GattClient::WriteOp_t cmd,
|
switches |
0:0e018d759a2a
|
286
|
Gap::Handle_t connHandle,
|
switches |
0:0e018d759a2a
|
287
|
GattAttribute::Handle_t attributeHandle,
|
switches |
0:0e018d759a2a
|
288
|
size_t length,
|
switches |
0:0e018d759a2a
|
289
|
const uint8_t *value) const {
|
switches |
0:0e018d759a2a
|
290
|
/* Avoid compiler warnings about unused variables. */
|
switches |
0:0e018d759a2a
|
291
|
(void)cmd;
|
switches |
0:0e018d759a2a
|
292
|
(void)connHandle;
|
switches |
0:0e018d759a2a
|
293
|
(void)attributeHandle;
|
switches |
0:0e018d759a2a
|
294
|
(void)length;
|
switches |
0:0e018d759a2a
|
295
|
(void)value;
|
switches |
0:0e018d759a2a
|
296
|
|
switches |
0:0e018d759a2a
|
297
|
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
298
|
}
|
switches |
0:0e018d759a2a
|
299
|
|
switches |
0:0e018d759a2a
|
300
|
/* Event callback handlers. */
|
switches |
0:0e018d759a2a
|
301
|
public:
|
switches |
0:0e018d759a2a
|
302
|
/**
|
switches |
0:0e018d759a2a
|
303
|
* Set up a callback for read response events.
|
switches |
0:0e018d759a2a
|
304
|
*
|
switches |
0:0e018d759a2a
|
305
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
306
|
* Event handler being registered.
|
switches |
0:0e018d759a2a
|
307
|
*
|
switches |
0:0e018d759a2a
|
308
|
* @note It is possible to chain together multiple onDataRead callbacks
|
switches |
0:0e018d759a2a
|
309
|
* (potentially from different modules of an application).
|
switches |
0:0e018d759a2a
|
310
|
*
|
switches |
0:0e018d759a2a
|
311
|
* @note It is possible to unregister a callback using
|
switches |
0:0e018d759a2a
|
312
|
* onDataRead().detach(callbackToRemove).
|
switches |
0:0e018d759a2a
|
313
|
*/
|
switches |
0:0e018d759a2a
|
314
|
void onDataRead(ReadCallback_t callback) {
|
switches |
0:0e018d759a2a
|
315
|
onDataReadCallbackChain.add(callback);
|
switches |
0:0e018d759a2a
|
316
|
}
|
switches |
0:0e018d759a2a
|
317
|
|
switches |
0:0e018d759a2a
|
318
|
/**
|
switches |
0:0e018d759a2a
|
319
|
* @brief Provide access to the callchain of read event callbacks.
|
switches |
0:0e018d759a2a
|
320
|
*
|
switches |
0:0e018d759a2a
|
321
|
* @return A reference to the read event callback chain.
|
switches |
0:0e018d759a2a
|
322
|
*
|
switches |
0:0e018d759a2a
|
323
|
* @note It is possible to register callbacks using onDataRead().add(callback).
|
switches |
0:0e018d759a2a
|
324
|
*
|
switches |
0:0e018d759a2a
|
325
|
* @note It is possible to unregister callbacks using onDataRead().detach(callback).
|
switches |
0:0e018d759a2a
|
326
|
*/
|
switches |
0:0e018d759a2a
|
327
|
ReadCallbackChain_t& onDataRead() {
|
switches |
0:0e018d759a2a
|
328
|
return onDataReadCallbackChain;
|
switches |
0:0e018d759a2a
|
329
|
}
|
switches |
0:0e018d759a2a
|
330
|
|
switches |
0:0e018d759a2a
|
331
|
/**
|
switches |
0:0e018d759a2a
|
332
|
* Set up a callback for write response events.
|
switches |
0:0e018d759a2a
|
333
|
*
|
switches |
0:0e018d759a2a
|
334
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
335
|
* Event handler being registered.
|
switches |
0:0e018d759a2a
|
336
|
*
|
switches |
0:0e018d759a2a
|
337
|
* @note It is possible to remove registered callbacks using
|
switches |
0:0e018d759a2a
|
338
|
* onDataWritten().detach(callbackToRemove).
|
switches |
0:0e018d759a2a
|
339
|
*
|
switches |
0:0e018d759a2a
|
340
|
* @note Write commands (issued using writeWoResponse) don't generate a response.
|
switches |
0:0e018d759a2a
|
341
|
*/
|
switches |
0:0e018d759a2a
|
342
|
void onDataWritten(WriteCallback_t callback) {
|
switches |
0:0e018d759a2a
|
343
|
onDataWriteCallbackChain.add(callback);
|
switches |
0:0e018d759a2a
|
344
|
}
|
switches |
0:0e018d759a2a
|
345
|
|
switches |
0:0e018d759a2a
|
346
|
/**
|
switches |
0:0e018d759a2a
|
347
|
* @brief Provide access to the callchain of data written callbacks.
|
switches |
0:0e018d759a2a
|
348
|
*
|
switches |
0:0e018d759a2a
|
349
|
* @return A reference to the data written callbacks chain.
|
switches |
0:0e018d759a2a
|
350
|
*
|
switches |
0:0e018d759a2a
|
351
|
* @note It is possible to register callbacks using onDataWritten().add(callback).
|
switches |
0:0e018d759a2a
|
352
|
*
|
switches |
0:0e018d759a2a
|
353
|
* @note It is possible to unregister callbacks using onDataWritten().detach(callback).
|
switches |
0:0e018d759a2a
|
354
|
*/
|
switches |
0:0e018d759a2a
|
355
|
WriteCallbackChain_t& onDataWritten() {
|
switches |
0:0e018d759a2a
|
356
|
return onDataWriteCallbackChain;
|
switches |
0:0e018d759a2a
|
357
|
}
|
switches |
0:0e018d759a2a
|
358
|
|
switches |
0:0e018d759a2a
|
359
|
/**
|
switches |
0:0e018d759a2a
|
360
|
* Set up a callback for write response events.
|
switches |
0:0e018d759a2a
|
361
|
*
|
switches |
0:0e018d759a2a
|
362
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
363
|
* Event handler being registered.
|
switches |
0:0e018d759a2a
|
364
|
*
|
switches |
0:0e018d759a2a
|
365
|
* @note Write commands (issued using writeWoResponse) don't generate a response.
|
switches |
0:0e018d759a2a
|
366
|
*
|
switches |
0:0e018d759a2a
|
367
|
* @deprecated Please use GattServer::onDataWritten() instead.
|
switches |
0:0e018d759a2a
|
368
|
*/
|
switches |
0:0e018d759a2a
|
369
|
void onDataWrite(WriteCallback_t callback) {
|
switches |
0:0e018d759a2a
|
370
|
onDataWritten(callback);
|
switches |
0:0e018d759a2a
|
371
|
}
|
switches |
0:0e018d759a2a
|
372
|
|
switches |
0:0e018d759a2a
|
373
|
/**
|
switches |
0:0e018d759a2a
|
374
|
* Set up a callback for when serviceDiscovery terminates.
|
switches |
0:0e018d759a2a
|
375
|
*
|
switches |
0:0e018d759a2a
|
376
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
377
|
* Event handler being registered.
|
switches |
0:0e018d759a2a
|
378
|
*/
|
switches |
0:0e018d759a2a
|
379
|
virtual void onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback) {
|
switches |
0:0e018d759a2a
|
380
|
(void)callback; /* Avoid compiler warnings about ununsed variables. */
|
switches |
0:0e018d759a2a
|
381
|
|
switches |
0:0e018d759a2a
|
382
|
/* Requesting action from porters: override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
383
|
}
|
switches |
0:0e018d759a2a
|
384
|
|
switches |
0:0e018d759a2a
|
385
|
/**
|
switches |
0:0e018d759a2a
|
386
|
* @brief Launch discovery of descriptors for a given characteristic.
|
switches |
0:0e018d759a2a
|
387
|
*
|
switches |
0:0e018d759a2a
|
388
|
* @details This function will discover all descriptors available for a
|
switches |
0:0e018d759a2a
|
389
|
* specific characteristic.
|
switches |
0:0e018d759a2a
|
390
|
*
|
switches |
0:0e018d759a2a
|
391
|
* @param[in] characteristic
|
switches |
0:0e018d759a2a
|
392
|
* The characteristic targeted by this discovery procedure.
|
switches |
0:0e018d759a2a
|
393
|
* @param[in] discoveryCallback
|
switches |
0:0e018d759a2a
|
394
|
* User function called each time a descriptor is found during
|
switches |
0:0e018d759a2a
|
395
|
* the procedure.
|
switches |
0:0e018d759a2a
|
396
|
* @param[in] terminationCallback
|
switches |
0:0e018d759a2a
|
397
|
* User provided function which will be called once the
|
switches |
0:0e018d759a2a
|
398
|
* discovery procedure is terminating. This will get called
|
switches |
0:0e018d759a2a
|
399
|
* when all the descriptors have been discovered or if an
|
switches |
0:0e018d759a2a
|
400
|
* error occur during the discovery procedure.
|
switches |
0:0e018d759a2a
|
401
|
*
|
switches |
0:0e018d759a2a
|
402
|
* @return
|
switches |
0:0e018d759a2a
|
403
|
* BLE_ERROR_NONE if characteristic descriptor discovery is launched
|
switches |
0:0e018d759a2a
|
404
|
* successfully; else an appropriate error.
|
switches |
0:0e018d759a2a
|
405
|
*/
|
switches |
0:0e018d759a2a
|
406
|
virtual ble_error_t discoverCharacteristicDescriptors(
|
switches |
0:0e018d759a2a
|
407
|
const DiscoveredCharacteristic& characteristic,
|
switches |
0:0e018d759a2a
|
408
|
const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
|
switches |
0:0e018d759a2a
|
409
|
const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback) {
|
switches |
0:0e018d759a2a
|
410
|
(void) characteristic;
|
switches |
0:0e018d759a2a
|
411
|
(void) discoveryCallback;
|
switches |
0:0e018d759a2a
|
412
|
(void) terminationCallback;
|
switches |
0:0e018d759a2a
|
413
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
414
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
switches |
0:0e018d759a2a
|
415
|
}
|
switches |
0:0e018d759a2a
|
416
|
|
switches |
0:0e018d759a2a
|
417
|
/**
|
switches |
0:0e018d759a2a
|
418
|
* @brief Indicate if the discovery of characteristic descriptors is active
|
switches |
0:0e018d759a2a
|
419
|
* for a given characteristic or not.
|
switches |
0:0e018d759a2a
|
420
|
*
|
switches |
0:0e018d759a2a
|
421
|
* @param[in] characteristic
|
switches |
0:0e018d759a2a
|
422
|
* The characteristic concerned by the descriptors discovery.
|
switches |
0:0e018d759a2a
|
423
|
*
|
switches |
0:0e018d759a2a
|
424
|
* @return true if a descriptors discovery is active for the characteristic
|
switches |
0:0e018d759a2a
|
425
|
* in input; otherwise false.
|
switches |
0:0e018d759a2a
|
426
|
*/
|
switches |
0:0e018d759a2a
|
427
|
virtual bool isCharacteristicDescriptorDiscoveryActive(const DiscoveredCharacteristic& characteristic) const
|
switches |
0:0e018d759a2a
|
428
|
{
|
switches |
0:0e018d759a2a
|
429
|
(void) characteristic;
|
switches |
0:0e018d759a2a
|
430
|
return false; /* Requesting action from porter(s): override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
431
|
}
|
switches |
0:0e018d759a2a
|
432
|
|
switches |
0:0e018d759a2a
|
433
|
/**
|
switches |
0:0e018d759a2a
|
434
|
* @brief Terminate an ongoing characteristic descriptor discovery.
|
switches |
0:0e018d759a2a
|
435
|
*
|
switches |
0:0e018d759a2a
|
436
|
* @details This should result in an invocation of the TerminationCallback if
|
switches |
0:0e018d759a2a
|
437
|
* the characteristic descriptor discovery is active.
|
switches |
0:0e018d759a2a
|
438
|
*
|
switches |
0:0e018d759a2a
|
439
|
* @param[in] characteristic
|
switches |
0:0e018d759a2a
|
440
|
* The characteristic on which the running descriptors
|
switches |
0:0e018d759a2a
|
441
|
* discovery should be stopped.
|
switches |
0:0e018d759a2a
|
442
|
*/
|
switches |
0:0e018d759a2a
|
443
|
virtual void terminateCharacteristicDescriptorDiscovery(const DiscoveredCharacteristic& characteristic) {
|
switches |
0:0e018d759a2a
|
444
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
switches |
0:0e018d759a2a
|
445
|
(void) characteristic;
|
switches |
0:0e018d759a2a
|
446
|
}
|
switches |
0:0e018d759a2a
|
447
|
|
switches |
0:0e018d759a2a
|
448
|
/**
|
switches |
0:0e018d759a2a
|
449
|
* Set up a callback for when the GATT Client receives an update event
|
switches |
0:0e018d759a2a
|
450
|
* corresponding to a change in the value of a characteristic on the remote
|
switches |
0:0e018d759a2a
|
451
|
* GATT Server.
|
switches |
0:0e018d759a2a
|
452
|
*
|
switches |
0:0e018d759a2a
|
453
|
* @note It is possible to unregister callbacks using
|
switches |
0:0e018d759a2a
|
454
|
* onHVX().detach(callbackToRemove).
|
switches |
0:0e018d759a2a
|
455
|
*/
|
switches |
0:0e018d759a2a
|
456
|
void onHVX(HVXCallback_t callback) {
|
switches |
0:0e018d759a2a
|
457
|
onHVXCallbackChain.add(callback);
|
switches |
0:0e018d759a2a
|
458
|
}
|
switches |
0:0e018d759a2a
|
459
|
|
switches |
0:0e018d759a2a
|
460
|
/**
|
switches |
0:0e018d759a2a
|
461
|
* Setup a callback to be invoked to notify the user application that the
|
switches |
0:0e018d759a2a
|
462
|
* GattClient instance is about to shutdown (possibly as a result of a call
|
switches |
0:0e018d759a2a
|
463
|
* to BLE::shutdown()).
|
switches |
0:0e018d759a2a
|
464
|
*
|
switches |
0:0e018d759a2a
|
465
|
* @param[in] callback
|
switches |
0:0e018d759a2a
|
466
|
* Event handler being registered.
|
switches |
0:0e018d759a2a
|
467
|
*
|
switches |
0:0e018d759a2a
|
468
|
* @note It is possible to chain together multiple onShutdown callbacks
|
switches |
0:0e018d759a2a
|
469
|
* (potentially from different modules of an application) to be notified
|
switches |
0:0e018d759a2a
|
470
|
* before the GattClient is shutdown.
|
switches |
0:0e018d759a2a
|
471
|
*
|
switches |
0:0e018d759a2a
|
472
|
* @note It is also possible to set up a callback into a member function of
|
switches |
0:0e018d759a2a
|
473
|
* some object.
|
switches |
0:0e018d759a2a
|
474
|
*
|
switches |
0:0e018d759a2a
|
475
|
* @note It is possible to unregister a callback using onShutdown().detach(callback).
|
switches |
0:0e018d759a2a
|
476
|
*/
|
switches |
0:0e018d759a2a
|
477
|
void onShutdown(const GattClientShutdownCallback_t& callback) {
|
switches |
0:0e018d759a2a
|
478
|
shutdownCallChain.add(callback);
|
switches |
0:0e018d759a2a
|
479
|
}
|
switches |
0:0e018d759a2a
|
480
|
|
switches |
0:0e018d759a2a
|
481
|
/**
|
switches |
0:0e018d759a2a
|
482
|
* Same as GattClient::onShutdown(), but allows the possibility to add an object
|
switches |
0:0e018d759a2a
|
483
|
* reference and member function as handler for shutdown event
|
switches |
0:0e018d759a2a
|
484
|
* callbacks.
|
switches |
0:0e018d759a2a
|
485
|
*
|
switches |
0:0e018d759a2a
|
486
|
* @param[in] objPtr
|
switches |
0:0e018d759a2a
|
487
|
* Pointer to the object of a class defining the member callback
|
switches |
0:0e018d759a2a
|
488
|
* function (@p memberPtr).
|
switches |
0:0e018d759a2a
|
489
|
* @param[in] memberPtr
|
switches |
0:0e018d759a2a
|
490
|
* The member callback (within the context of an object) to be
|
switches |
0:0e018d759a2a
|
491
|
* invoked.
|
switches |
0:0e018d759a2a
|
492
|
*/
|
switches |
0:0e018d759a2a
|
493
|
template <typename T>
|
switches |
0:0e018d759a2a
|
494
|
void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *)) {
|
switches |
0:0e018d759a2a
|
495
|
shutdownCallChain.add(objPtr, memberPtr);
|
switches |
0:0e018d759a2a
|
496
|
}
|
switches |
0:0e018d759a2a
|
497
|
|
switches |
0:0e018d759a2a
|
498
|
/**
|
switches |
0:0e018d759a2a
|
499
|
* @brief Provide access to the callchain of shutdown event callbacks.
|
switches |
0:0e018d759a2a
|
500
|
*
|
switches |
0:0e018d759a2a
|
501
|
* @return A reference to the shutdown event callbacks chain.
|
switches |
0:0e018d759a2a
|
502
|
*
|
switches |
0:0e018d759a2a
|
503
|
* @note It is possible to register callbacks using onShutdown().add(callback).
|
switches |
0:0e018d759a2a
|
504
|
*
|
switches |
0:0e018d759a2a
|
505
|
* @note It is possible to unregister callbacks using onShutdown().detach(callback).
|
switches |
0:0e018d759a2a
|
506
|
*/
|
switches |
0:0e018d759a2a
|
507
|
GattClientShutdownCallbackChain_t& onShutdown() {
|
switches |
0:0e018d759a2a
|
508
|
return shutdownCallChain;
|
switches |
0:0e018d759a2a
|
509
|
}
|
switches |
0:0e018d759a2a
|
510
|
|
switches |
0:0e018d759a2a
|
511
|
/**
|
switches |
0:0e018d759a2a
|
512
|
* @brief provide access to the callchain of HVX callbacks.
|
switches |
0:0e018d759a2a
|
513
|
*
|
switches |
0:0e018d759a2a
|
514
|
* @return A reference to the HVX callbacks chain.
|
switches |
0:0e018d759a2a
|
515
|
*
|
switches |
0:0e018d759a2a
|
516
|
* @note It is possible to register callbacks using onHVX().add(callback).
|
switches |
0:0e018d759a2a
|
517
|
*
|
switches |
0:0e018d759a2a
|
518
|
* @note It is possible to unregister callbacks using onHVX().detach(callback).
|
switches |
0:0e018d759a2a
|
519
|
*/
|
switches |
0:0e018d759a2a
|
520
|
HVXCallbackChain_t& onHVX() {
|
switches |
0:0e018d759a2a
|
521
|
return onHVXCallbackChain;
|
switches |
0:0e018d759a2a
|
522
|
}
|
switches |
0:0e018d759a2a
|
523
|
|
switches |
0:0e018d759a2a
|
524
|
public:
|
switches |
0:0e018d759a2a
|
525
|
/**
|
switches |
0:0e018d759a2a
|
526
|
* Notify all registered onShutdown callbacks that the GattClient is
|
switches |
0:0e018d759a2a
|
527
|
* about to be shutdown and clear all GattClient state of the
|
switches |
0:0e018d759a2a
|
528
|
* associated object.
|
switches |
0:0e018d759a2a
|
529
|
*
|
switches |
0:0e018d759a2a
|
530
|
* This function is meant to be overridden in the platform-specific
|
switches |
0:0e018d759a2a
|
531
|
* sub-class. Nevertheless, the sub-class is only expected to reset its
|
switches |
0:0e018d759a2a
|
532
|
* state and not the data held in GattClient members. This shall be achieved
|
switches |
0:0e018d759a2a
|
533
|
* by a call to GattClient::reset() from the sub-class' reset()
|
switches |
0:0e018d759a2a
|
534
|
* implementation.
|
switches |
0:0e018d759a2a
|
535
|
*
|
switches |
0:0e018d759a2a
|
536
|
* @return BLE_ERROR_NONE on success.
|
switches |
0:0e018d759a2a
|
537
|
*/
|
switches |
0:0e018d759a2a
|
538
|
virtual ble_error_t reset(void) {
|
switches |
0:0e018d759a2a
|
539
|
/* Notify that the instance is about to shutdown */
|
switches |
0:0e018d759a2a
|
540
|
shutdownCallChain.call(this);
|
switches |
0:0e018d759a2a
|
541
|
shutdownCallChain.clear();
|
switches |
0:0e018d759a2a
|
542
|
|
switches |
0:0e018d759a2a
|
543
|
onDataReadCallbackChain.clear();
|
switches |
0:0e018d759a2a
|
544
|
onDataWriteCallbackChain.clear();
|
switches |
0:0e018d759a2a
|
545
|
onHVXCallbackChain.clear();
|
switches |
0:0e018d759a2a
|
546
|
|
switches |
0:0e018d759a2a
|
547
|
return BLE_ERROR_NONE;
|
switches |
0:0e018d759a2a
|
548
|
}
|
switches |
0:0e018d759a2a
|
549
|
|
switches |
0:0e018d759a2a
|
550
|
protected:
|
switches |
0:0e018d759a2a
|
551
|
GattClient() {
|
switches |
0:0e018d759a2a
|
552
|
/* Empty */
|
switches |
0:0e018d759a2a
|
553
|
}
|
switches |
0:0e018d759a2a
|
554
|
|
switches |
0:0e018d759a2a
|
555
|
/* Entry points for the underlying stack to report events back to the user. */
|
switches |
0:0e018d759a2a
|
556
|
public:
|
switches |
0:0e018d759a2a
|
557
|
/**
|
switches |
0:0e018d759a2a
|
558
|
* Helper function that notifies all registered handlers of an occurrence
|
switches |
0:0e018d759a2a
|
559
|
* of a data read event. This function is meant to be called from the
|
switches |
0:0e018d759a2a
|
560
|
* BLE stack specific implementation when a data read event occurs.
|
switches |
0:0e018d759a2a
|
561
|
*
|
switches |
0:0e018d759a2a
|
562
|
* @param[in] params
|
switches |
0:0e018d759a2a
|
563
|
* The data read parameters passed to the registered
|
switches |
0:0e018d759a2a
|
564
|
* handlers.
|
switches |
0:0e018d759a2a
|
565
|
*/
|
switches |
0:0e018d759a2a
|
566
|
void processReadResponse(const GattReadCallbackParams *params) {
|
switches |
0:0e018d759a2a
|
567
|
onDataReadCallbackChain(params);
|
switches |
0:0e018d759a2a
|
568
|
}
|
switches |
0:0e018d759a2a
|
569
|
|
switches |
0:0e018d759a2a
|
570
|
/**
|
switches |
0:0e018d759a2a
|
571
|
* Helper function that notifies all registered handlers of an occurrence
|
switches |
0:0e018d759a2a
|
572
|
* of a data written event. This function is meant to be called from the
|
switches |
0:0e018d759a2a
|
573
|
* BLE stack specific implementation when a data written event occurs.
|
switches |
0:0e018d759a2a
|
574
|
*
|
switches |
0:0e018d759a2a
|
575
|
* @param[in] params
|
switches |
0:0e018d759a2a
|
576
|
* The data written parameters passed to the registered
|
switches |
0:0e018d759a2a
|
577
|
* handlers.
|
switches |
0:0e018d759a2a
|
578
|
*/
|
switches |
0:0e018d759a2a
|
579
|
void processWriteResponse(const GattWriteCallbackParams *params) {
|
switches |
0:0e018d759a2a
|
580
|
onDataWriteCallbackChain(params);
|
switches |
0:0e018d759a2a
|
581
|
}
|
switches |
0:0e018d759a2a
|
582
|
|
switches |
0:0e018d759a2a
|
583
|
/**
|
switches |
0:0e018d759a2a
|
584
|
* Helper function that notifies all registered handlers of an occurrence
|
switches |
0:0e018d759a2a
|
585
|
* of an update event. This function is meant to be called from the
|
switches |
0:0e018d759a2a
|
586
|
* BLE stack specific implementation when an update event occurs.
|
switches |
0:0e018d759a2a
|
587
|
*
|
switches |
0:0e018d759a2a
|
588
|
* @param[in] params
|
switches |
0:0e018d759a2a
|
589
|
* The update event parameters passed to the registered
|
switches |
0:0e018d759a2a
|
590
|
* handlers.
|
switches |
0:0e018d759a2a
|
591
|
*/
|
switches |
0:0e018d759a2a
|
592
|
void processHVXEvent(const GattHVXCallbackParams *params) {
|
switches |
0:0e018d759a2a
|
593
|
if (onHVXCallbackChain) {
|
switches |
0:0e018d759a2a
|
594
|
onHVXCallbackChain(params);
|
switches |
0:0e018d759a2a
|
595
|
}
|
switches |
0:0e018d759a2a
|
596
|
}
|
switches |
0:0e018d759a2a
|
597
|
|
switches |
0:0e018d759a2a
|
598
|
protected:
|
switches |
0:0e018d759a2a
|
599
|
/**
|
switches |
0:0e018d759a2a
|
600
|
* Callchain containing all registered callback handlers for data read
|
switches |
0:0e018d759a2a
|
601
|
* events.
|
switches |
0:0e018d759a2a
|
602
|
*/
|
switches |
0:0e018d759a2a
|
603
|
ReadCallbackChain_t onDataReadCallbackChain;
|
switches |
0:0e018d759a2a
|
604
|
/**
|
switches |
0:0e018d759a2a
|
605
|
* Callchain containing all registered callback handlers for data write
|
switches |
0:0e018d759a2a
|
606
|
* events.
|
switches |
0:0e018d759a2a
|
607
|
*/
|
switches |
0:0e018d759a2a
|
608
|
WriteCallbackChain_t onDataWriteCallbackChain;
|
switches |
0:0e018d759a2a
|
609
|
/**
|
switches |
0:0e018d759a2a
|
610
|
* Callchain containing all registered callback handlers for update
|
switches |
0:0e018d759a2a
|
611
|
* events.
|
switches |
0:0e018d759a2a
|
612
|
*/
|
switches |
0:0e018d759a2a
|
613
|
HVXCallbackChain_t onHVXCallbackChain;
|
switches |
0:0e018d759a2a
|
614
|
/**
|
switches |
0:0e018d759a2a
|
615
|
* Callchain containing all registered callback handlers for shutdown
|
switches |
0:0e018d759a2a
|
616
|
* events.
|
switches |
0:0e018d759a2a
|
617
|
*/
|
switches |
0:0e018d759a2a
|
618
|
GattClientShutdownCallbackChain_t shutdownCallChain;
|
switches |
0:0e018d759a2a
|
619
|
|
switches |
0:0e018d759a2a
|
620
|
private:
|
switches |
0:0e018d759a2a
|
621
|
/* Disallow copy and assignment. */
|
switches |
0:0e018d759a2a
|
622
|
GattClient(const GattClient &);
|
switches |
0:0e018d759a2a
|
623
|
GattClient& operator=(const GattClient &);
|
switches |
0:0e018d759a2a
|
624
|
};
|
switches |
0:0e018d759a2a
|
625
|
|
switches |
0:0e018d759a2a
|
626
|
#endif /* ifndef __GATT_CLIENT_H__ */
|