Mistake on this page?
Report an issue in GitHub or email us
gatt/GattCallbackParamTypes.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2020 ARM Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #include "ble/common/CallChainOfFunctionPointersWithContext.h"
19 
20 #ifndef MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__
21 #define MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__
22 
23 /**
24  * @addtogroup ble
25  * @{
26  * @addtogroup gatt
27  * @{
28  */
29 
30 /**
31  * GATT Write event definition.
32  *
33  * Instances of this type are created and passed to user registered callbacks
34  * whether the GattServer has received a write request or a GattClient has
35  * received a write response.
36  *
37  * @attention The GattServer only populates the fields offset, len and data
38  * when it has received a write request. Callbacks attached to the GattClient
39  * do not use those fields.
40  *
41  * @attention The GattClient only populates the fields status and error_code
42  * when it has received a write response. Callbacks attached to the GattServer
43  * do not use those fields.
44  */
46  /**
47  * Enumeration of allowed write operations.
48  */
49  enum WriteOp_t {
50  /**
51  * Invalid operation.
52  */
53  OP_INVALID = 0x00,
54 
55  /**
56  * Write request.
57  */
58  OP_WRITE_REQ = 0x01,
59 
60  /**
61  * Write command.
62  */
63  OP_WRITE_CMD = 0x02,
64 
65  /**
66  * Signed write command.
67  */
69 
70  /**
71  * Prepare write request.
72  */
74 
75  /**
76  * Execute write request: cancel all prepared writes.
77  */
79 
80  /**
81  * Execute write request: immediately execute all prepared writes.
82  */
84  };
85 
86  /**
87  * Handle of the connection that triggered the event.
88  */
90 
91  /**
92  * Handle of the attribute to which the write operation applies.
93  */
95 
96  /**
97  * Type of the write operation.
98  */
100 
101  union {
102  /**
103  * Offset within the attribute value to be written.
104  *
105  * @attention Reserved for GattServer registered callbacks.
106  */
107  uint16_t offset;
108 
109  /**
110  * Status of the GattClient Write operation.
111  *
112  * @attention Reserved for GattClient registered callbacks.
113  */
115  };
116 
117  union {
118  /**
119  * Length (in bytes) of the data to write.
120  *
121  * @attention Reserved for GattServer registered callbacks.
122  */
123  uint16_t len;
124 
125  /**
126  * Error code of the GattClient Write operation.
127  *
128  * @attention Reserved for GattClient registered callbacks.
129  */
130  uint8_t error_code;
131  };
132 
133  /**
134  * Pointer to the data to write.
135  *
136  * @attention Data may not persist beyond the callback scope.
137  *
138  * @attention Reserved for GattServer registered callbacks.
139  */
140  const uint8_t *data;
141 };
142 
143 /**
144  * GATT Read event definition.
145  *
146  * Instances of this type are created and passed to user registered callbacks
147  * whether the GattServer has received a read request or a GattClient has
148  * received a read response.
149  *
150  * @attention The GattClient only populates the fields status and error_code
151  * when it has received a read response. Callbacks attached to the GattServer
152  * do not use those fields.
153  */
155  /**
156  * Handle of the connection that triggered the event.
157  */
159 
160  /**
161  * Attribute Handle to which the read operation applies.
162  */
164 
165  /**
166  * Offset within the attribute value read.
167  */
168  uint16_t offset;
169 
170  union {
171  /**
172  * Length in bytes of the data read.
173  */
174  uint16_t len;
175 
176  /**
177  * Error code of the GattClient read operation.
178  *
179  * @attention Reserved for GattClient registered callbacks.
180  *
181  * @attention set if status is not equal to BLE_ERROR_NONE; otherwise,
182  * this field is interpreted as len.
183  */
184  uint8_t error_code;
185  };
186 
187  /**
188  * Pointer to the data read.
189  *
190  * @attention Data may not persist beyond the callback scope.
191  */
192  const uint8_t *data;
193 
194  /**
195  * Status of the GattClient Read operation.
196  *
197  * @attention Reserved for GattClient registered callbacks.
198  */
200 };
201 
202 /**
203  * @addtogroup server
204  * @{
205  */
206 
207 /**
208  * Enumeration of allowed values returned by read or write authorization process.
209  */
211  /**
212  * Success.
213  */
215 
216  /**
217  * ATT Error: Invalid attribute handle.
218  */
220 
221  /**
222  * ATT Error: Read not permitted.
223  */
225 
226  /**
227  * ATT Error: Write not permitted.
228  */
230 
231  /**
232  * ATT Error: Authenticated link required.
233  */
235 
236  /**
237  * ATT Error: The specified offset was past the end of the attribute.
238  */
240 
241  /**
242  * ATT Error: Used in ATT as "insufficient authorization".
243  */
245 
246  /**
247  * ATT Error: Used in ATT as "prepare queue full".
248  */
250 
251  /**
252  * ATT Error: Used in ATT as "attribute not found".
253  */
255 
256  /**
257  * ATT Error: Attribute cannot be read or written using read/write blob
258  * requests.
259  */
261 
262  /**
263  * ATT Error: Invalid value size.
264  */
266 
267  /**
268  * ATT Error: Encrypted link required.
269  */
271 };
272 
273 /**
274  * GATT write authorization request event.
275  */
277  /**
278  * Handle of the connection that triggered the event.
279  */
281 
282  /**
283  * Attribute Handle to which the write operation applies.
284  */
286 
287  /**
288  * Offset for the write operation.
289  */
290  uint16_t offset;
291 
292  /**
293  * Length of the incoming data.
294  */
295  uint16_t len;
296 
297  /**
298  * Incoming data.
299  */
300  const uint8_t *data;
301 
302  /**
303  * Authorization result.
304  *
305  * The callback sets this parameter. If the value is set to
306  * AUTH_CALLBACK_REPLY_SUCCESS, then the write request is accepted;
307  * otherwise, an error code is returned to the peer client.
308  */
310 };
311 
312 /**
313  * GATT read authorization request event.
314  */
316  /**
317  * The handle of the connection that triggered the event.
318  */
320 
321  /**
322  * Attribute Handle to which the read operation applies.
323  */
325 
326  /**
327  * Offset for the read operation.
328  */
329  uint16_t offset;
330 
331  /**
332  * Optional: new length of the outgoing data.
333  */
334  uint16_t len;
335 
336  /**
337  * Optional: new outgoing data. Leave at NULL if data is unchanged.
338  */
339  uint8_t *data;
340 
341  /**
342  * Authorization result.
343  *
344  * The callback sets this parameter. If the value is set to
345  * AUTH_CALLBACK_REPLY_SUCCESS, then the read request is accepted;
346  * otherwise, an error code is returned to the peer client.
347  */
349 };
350 
351 /**
352  * Handle Value Notification/Indication event.
353  *
354  * The GattClient generates this type of event upon the reception of a
355  * Handle Value Notification or Indication.
356  *
357  * The event is passed to callbacks registered by GattClient::onHVX().
358  */
360  /**
361  * The handle of the connection that triggered the event.
362  */
364 
365  /**
366  * Attribute Handle to which the HVx operation applies.
367  */
369 
370  /**
371  * Indication or Notification, see HVXType_t.
372  */
374 
375  /**
376  * Attribute value length.
377  */
378  uint16_t len;
379 
380  /**
381  * Attribute value.
382  */
383  const uint8_t *data;
384 
385 };
386 
387 /**
388  * Gatt Data Sent Attribute related events
389  *
390  * Used by `onDataSent`
391  */
393 
394  /**
395  * The handle of the connection that triggered the event.
396  */
398 
399  /**
400  * Attribute Handle to which the event applies
401  */
403 
404 };
405 
409 
410 namespace ble {
411 
412 /**
413  * Attribute read event handler.
414  *
415  * @see GattClient::onDataRead().
416  */
418 
419 /**
420  * Callchain of attribute read event handlers.
421  */
423 
424 /**
425  * Attribute write event handler.
426  *
427  * @see GattClient::onDataWrite().
428  */
430 
431 /**
432  * Callchain of attribute write event handlers.
433  *
434  * @see GattClient::onDataWrite().
435  */
437 
438 }
439 
440 /**
441  * @}
442  * @}
443  * @}
444  */
445 
446 #endif /*MBED_BLE_GATT_CALLBACK_PARAM_TYPES_H__*/
Execute write request: immediately execute all prepared writes.
GattAttribute::Handle_t handle
Attribute Handle to which the write operation applies.
Function like object adapter over freestanding and member functions.
GattAuthCallbackReply_t authorizationReply
Authorization result.
uint16_t offset
Offset within the attribute value read.
const uint8_t * data
Incoming data.
const uint8_t * data
Pointer to the data to write.
ble::connection_handle_t connHandle
Handle of the connection that triggered the event.
uint8_t error_code
Error code of the GattClient read operation.
uintptr_t connection_handle_t
Opaque reference to a connection.
uint8_t error_code
Error code of the GattClient Write operation.
GATT write authorization request event.
Handle Value Notification/Indication event.
Execute write request: cancel all prepared writes.
GATT read authorization request event.
GattAuthCallbackReply_t authorizationReply
Authorization result.
uint16_t offset
Offset within the attribute value to be written.
ATT Error: The specified offset was past the end of the attribute.
ble::connection_handle_t connHandle
Handle of the connection that triggered the event.
ATT Error: Attribute cannot be read or written using read/write blob requests.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
ble::connection_handle_t connHandle
The handle of the connection that triggered the event.
Gatt Data Sent Attribute related events.
uint16_t len
Optional: new length of the outgoing data.
ble_error_t status
Status of the GattClient Read operation.
GATT Write event definition.
uint16_t len
Length (in bytes) of the data to write.
GATT Read event definition.
uint8_t * data
Optional: new outgoing data.
uint16_t len
Length in bytes of the data read.
ATT Error: Used in ATT as "attribute not found".
ATT Error: Used in ATT as "prepare queue full".
const uint8_t * data
Attribute value.
HVXType_t
Handle Value Notification/Indication event.
Function like object hosting a list of FunctionPointerWithContext.
WriteOp_t writeOp
Type of the write operation.
uint16_t offset
Offset for the write operation.
uint16_t len
Length of the incoming data.
ble_error_t status
Status of the GattClient Write operation.
GattAttribute::Handle_t handle
Handle of the attribute to which the write operation applies.
GattAttribute::Handle_t handle
Attribute Handle to which the read operation applies.
ble::connection_handle_t connHandle
Handle of the connection that triggered the event.
uint16_t len
Attribute value length.
HVXType_t type
Indication or Notification, see HVXType_t.
GattAttribute::Handle_t attHandle
Attribute Handle to which the event applies.
Entry namespace for all BLE API definitions.
GattAttribute::Handle_t handle
Attribute Handle to which the HVx operation applies.
ble::connection_handle_t connHandle
The handle of the connection that triggered the event.
const uint8_t * data
Pointer to the data read.
WriteOp_t
Enumeration of allowed write operations.
GattAuthCallbackReply_t
Enumeration of allowed values returned by read or write authorization process.
ATT Error: Used in ATT as "insufficient authorization".
GattAttribute::Handle_t handle
Attribute Handle to which the read operation applies.
uint16_t offset
Offset for the read operation.
ble_error_t
Error codes for the BLE API.
ble::connection_handle_t connHandle
The handle of the connection that triggered the event.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.