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  /** The attribute handle given was not valid on this server. */
218 
219  /** The attribute cannot be read. */
221 
222  /** The attribute cannot be written. */
224 
225  /** The attribute PDU was invalid. */
227 
228  /** The attribute requires authentication before it can be read or
229  * written.
230  */
232  AUTH_CALLBACK_REPLY_ATTERR_INSUF_AUTHENTICATION = 0x05,
233 
234  /** Attribute server does not support the request received from the
235  * client.
236  */
238 
239  /** Offset specified was past the end of the attribute. */
241 
242  /** The attribute requires authorization before it can be read or written. */
244  AUTH_CALLBACK_REPLY_ATTERR_INSUF_AUTHORIZATION = 0x08,
245 
246  /** Too many prepare writes have been queued. */
248 
249  /** No attribute found within the given attribute handle range. */
251 
252  /** The attribute cannot be read using the Read Blob Request. */
254 
255  /** The Encryption Key Size used for encrypting this link is
256  * insufficient.
257  */
259 
260  /** The attribute value length is invalid for the operation. */
262  AUTH_CALLBACK_REPLY_ATTERR_INVALID_ATT_VAL_LENGTH = 0x0D,
263 
264  /** The attribute request that was requested has encountered an error
265  * that was unlikely, and therefore could not be completed as requested.
266  */
268 
269  /** The attribute requires encryption before it can be read or written. */
271 
272  /** The attribute type is not a supported grouping attribute as defined
273  * by a higher layer specification.
274  */
276 
277  /** Insufficient Resources to complete the request. */
279  AUTH_CALLBACK_REPLY_ATTERR_INSUF_RESOURCES = 0x11,
280 
281  /* 0x12 - 0x7F => reserved for future use */
282 
283  /* 0x80 - 0x9F => Application Error */
284 
285  /* 0xA0 0xDF => Reserved for future use */
286 
287  /* 0xE0 - 0xFF Common Profile and service Error Codes */
288 
289  /** The Write Request Rejected error code is used when a requested write
290  * operation cannot be fulfilled for reasons other than permissions.
291  */
293 
294  /** The Client Characteristic Configuration Descriptor Improperly
295  * Configured error code is used when a Client Characteristic
296  * Configuration descriptor is not configured according to the
297  * requirements of the profile or service.
298  */
300 
301  /** The Procedure Already in Progress error code is used when a profile
302  * or service request cannot be serviced because an operation that has
303  * been previously triggered is still in progress
304  */
306 
307  /** The Out of Range error code is used when an attribute value is out
308  * of range as defined by a profile or service specification.
309  */
311 };
312 
313 /**
314  * GATT write authorization request event.
315  */
317  /**
318  * Handle of the connection that triggered the event.
319  */
321 
322  /**
323  * Attribute Handle to which the write operation applies.
324  */
326 
327  /**
328  * Offset for the write operation.
329  */
330  uint16_t offset;
331 
332  /**
333  * Length of the incoming data.
334  */
335  uint16_t len;
336 
337  /**
338  * Incoming data.
339  */
340  const uint8_t *data;
341 
342  /**
343  * Authorization result.
344  *
345  * The callback sets this parameter. If the value is set to
346  * AUTH_CALLBACK_REPLY_SUCCESS, then the write request is accepted;
347  * otherwise, an error code is returned to the peer client.
348  */
350 };
351 
352 /**
353  * GATT read authorization request event.
354  */
356  /**
357  * The handle of the connection that triggered the event.
358  */
360 
361  /**
362  * Attribute Handle to which the read operation applies.
363  */
365 
366  /**
367  * Offset for the read operation.
368  */
369  uint16_t offset;
370 
371  /**
372  * Optional: new length of the outgoing data.
373  */
374  uint16_t len;
375 
376  /**
377  * Optional: new outgoing data. Leave at NULL if data is unchanged.
378  */
379  uint8_t *data;
380 
381  /**
382  * Authorization result.
383  *
384  * The callback sets this parameter. If the value is set to
385  * AUTH_CALLBACK_REPLY_SUCCESS, then the read request is accepted;
386  * otherwise, an error code is returned to the peer client.
387  */
389 };
390 
391 /**
392  * Handle Value Notification/Indication event.
393  *
394  * The GattClient generates this type of event upon the reception of a
395  * Handle Value Notification or Indication.
396  *
397  * The event is passed to callbacks registered by GattClient::onHVX().
398  */
400  /**
401  * The handle of the connection that triggered the event.
402  */
404 
405  /**
406  * Attribute Handle to which the HVx operation applies.
407  */
409 
410  /**
411  * Indication or Notification, see HVXType_t.
412  */
414 
415  /**
416  * Attribute value length.
417  */
418  uint16_t len;
419 
420  /**
421  * Attribute value.
422  */
423  const uint8_t *data;
424 
425 };
426 
427 /**
428  * Gatt Data Sent Attribute related events
429  *
430  * Used by `onDataSent`
431  */
433 
434  /**
435  * The handle of the connection that triggered the event.
436  */
438 
439  /**
440  * Attribute Handle to which the event applies
441  */
443 
444 };
445 
446 /**
447  * Gatt Updates Changed Attribute related events
448  *
449  * Used by `onUpdatesEnabled` and 'onUpdatesDisabled'
450  */
452 
453  /**
454  * The handle of the connection that triggered the event.
455  */
457 
458  /**
459  * The handle of the CCCD producing the event
460  */
462 
463  /**
464  * The value handle of the characteristic containing the CCCD
465  */
467 
468 };
469 
473 
474 namespace ble {
475 
476 /**
477  * Attribute read event handler.
478  *
479  * @see GattClient::onDataRead().
480  */
482 
483 /**
484  * Callchain of attribute read event handlers.
485  */
487 
488 /**
489  * Attribute write event handler.
490  *
491  * @see GattClient::onDataWrite().
492  */
494 
495 /**
496  * Callchain of attribute write event handlers.
497  *
498  * @see GattClient::onDataWrite().
499  */
501 
502 }
503 
504 /**
505  * @}
506  * @}
507  * @}
508  */
509 
510 #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.
The attribute value length is invalid for the operation.
uint16_t offset
Offset within the attribute value read.
const uint8_t * data
Incoming data.
Attribute server does not support the request received from the client.
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.
The Client Characteristic Configuration Descriptor Improperly Configured error code is used when a Cl...
GATT write authorization request event.
Handle Value Notification/Indication event.
The attribute requires authorization before it can be read or written.
The Write Request Rejected error code is used when a requested write operation cannot be fulfilled fo...
The attribute handle given was not valid on this server.
Execute write request: cancel all prepared writes.
GATT read authorization request event.
GattAuthCallbackReply_t authorizationReply
Authorization result.
GattAttribute::Handle_t charHandle
The value handle of the characteristic containing the CCCD.
uint16_t offset
Offset within the attribute value to be written.
Offset specified was past the end of the attribute.
ble::connection_handle_t connHandle
Handle of the connection that triggered the event.
The attribute cannot be read using the Read Blob Request.
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.
The Encryption Key Size used for encrypting this link is insufficient.
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.
The attribute request that was requested has encountered an error that was unlikely, and therefore could not be completed as requested.
No attribute found within the given attribute handle range.
Insufficient Resources to complete the request.
Too many prepare writes have been queued.
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.
GattAttribute::Handle_t attHandle
The handle of the CCCD producing the event.
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.
The attribute requires encryption before it can be read or written.
The Out of Range error code is used when an attribute value is out of range as defined by a profile o...
The attribute type is not a supported grouping attribute as defined by a higher layer specification...
ble::connection_handle_t connHandle
Handle of the connection that triggered the event.
uint16_t len
Attribute value length.
Gatt Updates Changed Attribute related events.
HVXType_t type
Indication or Notification, see HVXType_t.
GattAttribute::Handle_t attHandle
Attribute Handle to which the event applies.
The attribute requires authentication before it can be read or written.
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.
The Procedure Already in Progress error code is used when a profile or service request cannot be serv...
GattAttribute::Handle_t handle
Attribute Handle to which the read operation applies.
uint16_t offset
Offset for the read operation.
ble::connection_handle_t connHandle
The handle of the connection that triggered the event.
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.