ble_gattc.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file ble_gattc.h
5  *
6  * @brief BLE GATTC API
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  *****************************************************************************************
36  */
37 
38  /**
39  * @addtogroup BLE
40  * @{
41  */
42 
43  /**
44  * @addtogroup BLE_GATT Generic Attribute Profile (GATT)
45  * @{
46  * @brief Definitions and prototypes for the GATT interface.
47  */
48 
49 /**
50  @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
51  @{
52  @brief Definitions and prototypes for the GATT client interfaces.
53  */
54 
55 #ifndef __BLE_GATTC_H__
56 #define __BLE_GATTC_H__
57 
58 #include "ble_error.h"
59 #include "ble_gatt.h"
60 #include "ble_att.h"
61 
62 #include <stdint.h>
63 #include <stdbool.h>
64 
65 /** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
66  * @{ */
67 
68 /**
69  * @brief GATT Client Service type IDs.
70  */
71 typedef enum
72 {
73  BLE_GATTC_PRI_SERV, /**< Primary Service. */
74  BLE_GATTC_SEC_SERV, /**< Secondary Service. */
76 
77 /** @} */
78 
79 
80 /**
81  * @brief GATT Client Service Discover Attribute type IDs.
82  */
83 typedef enum
84 {
85  BLE_GATTC_BROWSE_NONE, /**< No Attribute Information. */
86  BLE_GATTC_BROWSE_INC_SRVC, /**< Included Service information. */
87  BLE_GATTC_BROWSE_ATTR_CHAR, /**< Characteristic Declaration. */
88  BLE_GATTC_BROWSE_ATTR_VAL, /**< Attribute Value definition. */
89  BLE_GATTC_BROWSE_ATTR_DESC, /**< Attribute Descriptor. */
91 
92 /** @} */
93 
94 /** @addtogroup BLE_GATTC_STRUCTURES Structures
95  * @{ */
96 
97 /**
98  * @brief GATTC discovery characteristic structure.
99  */
100 typedef struct
101 {
102  uint16_t start_hdl; /**< Start handle. */
103  uint16_t end_hdl; /**< End handle. */
104  ble_uuid_t *p_uuid; /**< Characteristic UUID. */
106 
107 /**
108  * @brief GATTC read by characteristic UUID structure.
109  */
110 typedef struct
111 {
112  uint16_t start_hdl; /**< Start handle. */
113  uint16_t end_hdl; /**< End handle. */
114  ble_uuid_t *p_uuid; /**< Characteristic UUID. */
116 
117 /**
118  * @brief GATTC write attribute value structure.
119  */
120 typedef struct
121 {
122  uint16_t handle; /**< Attribute handle. */
123  uint16_t offset; /**< value offset to start with. */
124  uint16_t length; /**< Write length. */
125  uint8_t *p_value; /**< Value to write. */
127 
128 /**
129  * @brief GATTC write without response structure.
130  */
131 typedef struct
132 {
133  bool signed_write; /**< True if signed write should be used when possible/applicable. */
134  uint16_t handle; /**< Attribute handle. */
135  uint16_t length; /**< Write length. */
136  uint8_t *p_value; /**< Value to write. */
138 
139 /**@brief Read Multiple Handles. */
140 typedef struct
141 {
142  uint16_t handle; /**< Attribute handle. */
143  uint16_t len; /**< Known value: length of the handle (len shall not be set to 0). */
145 
146 /**@brief GATTC Read Multiple. */
147 typedef struct
148 {
149  uint16_t handle_count; /**< Handle count of the multiple attributes to be read. */
150  ble_gattc_multiple_att_t *p_read_multiple; /**< Pointer to the multiple attributes to be read. */
152 
153 /**@brief GATTC Browse information about Characteristic. */
154 typedef struct
155 {
156  ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref BLE_GATTC_BROWSE_ATTR_CHAR for Characteristic Declaration. */
157  uint8_t prop; /**< Value property. */
158  uint16_t handle; /**< Value handle. */
159  uint8_t uuid_len; /**< Characteristic UUID length. */
160  uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Characteristic UUID. */
162 
163 /**@brief GATTC Browse information about Included Service. */
164 typedef struct
165 {
166  ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref BLE_GATTC_BROWSE_INC_SRVC for Included Service Information. */
167  uint8_t uuid_len; /**< Included Service UUID length. */
168  uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Included Service UUID. */
169  uint16_t start_hdl; /**< Included Service start handle. */
170  uint16_t end_hdl; /**< Included Service end handle. */
172 
173 /**@brief GATTC Browse information about Attribute. */
174 typedef struct
175 {
176  ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref BLE_GATTC_BROWSE_ATTR_VAL for Attribute Value. See @ref BLE_GATTC_BROWSE_ATTR_DESC for Attribute Descriptor. */
177  uint8_t uuid_len; /**< Attribute UUID length. */
178  uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Characteristic UUID or Characteristic Descriptor UUID. */
180 
181 /**@brief GATTC Browse attribute information. */
183 {
184  ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref ble_gattc_attr_type_t. */
185  ble_gattc_browse_attr_char_t attr_char; /**< Information about Characteristic. When union attr_type is @ref BLE_GATTC_BROWSE_ATTR_CHAR */
186  ble_gattc_browse_inc_srvc_t inc_srvc; /**< Information about Included Service. When union attr_type is @ref BLE_GATTC_BROWSE_INC_SRVC */
187  ble_gattc_browse_attr_t attr; /**< Information about Attribute. When union attr_type is @ref BLE_GATTC_BROWSE_ATTR_VAL or @ref BLE_GATTC_BROWSE_ATTR_DESC. */
188 };
189 
190 /**@brief GATTC Browse service(s) indication. */
191 typedef struct
192 {
193  uint8_t serv_type; /**< Service type. See @ref gatt_serv_type_t.*/
194  uint8_t uuid_len; /**< Service UUID length. */
195  uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Service UUID. */
196  uint16_t start_hdl; /**< Service start handle. */
197  uint16_t end_hdl; /**< Service end handle. */
198  union ble_gattc_browse_attr_info info[__ARRAY_EMPTY]; /**< Attribute information presented in the service(array length = end_hdl - start_hdl);
199  If attr_type is equal to BLE_GATTC_BROWSE_NONE, the last attribute information has been found in previous one, although not reach the service end handle. */
201 
202 
203 
204 /**@brief GATT service. */
205 typedef struct
206 {
207  uint16_t start_hdl; /**< Start handle. */
208  uint16_t end_hdl; /**< End handle. */
209  uint8_t uuid_len; /**< Service UUID length. */
210  uint8_t *p_uuid; /**< Service UUID. */
212 
213 /**@brief GATT include. */
214 typedef struct
215 {
216  uint16_t attr_hdl; /**< Attribute handle. */
217  uint16_t start_hdl; /**< Start handle. */
218  uint16_t end_hdl; /**< End handle. */
219  uint8_t uuid_len; /**< Service UUID length. */
220  uint8_t *p_uuid; /**< Service UUID. */
222 
223 /**@brief GATT characteristic. */
224 typedef struct
225 {
226  uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
227  uint16_t handle_value; /**< Handle of the Characteristic Value. */
228  uint8_t prop; /**< Properties. */
229  uint8_t uuid_len; /**< Characteristic UUID length. */
230  uint8_t *p_uuid; /**< Characteristic UUID. */
232 
233 /**@brief GATT descriptor. */
234 typedef struct
235 {
236  uint16_t attr_hdl; /**< Attribute handle. */
237  uint8_t uuid_len; /**< Descriptor UUID length. */
238  uint8_t *p_uuid; /**< Descriptor UUID. */
240 
241 /**@brief GATT service discovery. */
242 typedef struct
243 {
244  uint16_t count; /**< Service count. */
245  ble_gattc_service_t services[__ARRAY_EMPTY]; /**< Service data. */
247 
248 /**@brief GATT include discovery. */
249 typedef struct
250 {
251  uint16_t count; /**< Include count. */
252  ble_gattc_include_t includes[__ARRAY_EMPTY]; /**< Include data. */
254 
255 /**@brief GATT characteristic discovery. */
256 typedef struct
257 {
258  uint16_t count; /**< Characteristic count. */
259  ble_gattc_char_t chars[__ARRAY_EMPTY]; /**< Characteristic data. */
261 
262 /**@brief GATT characteristic descriptor discovery. */
263 typedef struct
264 {
265  uint16_t count; /**< Descriptor count. */
266  ble_gattc_desc_t char_descs[__ARRAY_EMPTY]; /**< Descriptor data. */
268 
269 /**@brief GATT Client Read value. */
270 typedef struct
271 {
272  uint16_t handle; /**< Attribute handle. */
273  uint16_t offset; /**< Offset of the attribute value. */
274  uint16_t length; /**< Attribute value length. */
275  uint8_t *p_value; /**< Pointer to the attribute value data. */
277 
278 /**@brief GATT value Read response. */
279 typedef struct
280 {
281  uint16_t count; /**< Value Count. */
282  ble_gattc_read_value_t vals[__ARRAY_EMPTY]; /**< Value(s) list. */
284 
285 
286 /**@brief GATT Client Write. */
287 typedef struct
288 {
289  uint16_t handle; /**< Attribute handle. */
291 
292 
293 /**@brief GATTC Notification and Indication value indication. */
294 typedef struct
295 {
296  ble_gatt_evt_type_t type; /**< Event type. */
297  uint16_t length; /**< Attribute value length. */
298  uint16_t handle; /**< Attribute handle. */
299  uint8_t *p_value; /**< Pointer to the attribute value data. */
301 
302 /**
303  * @brief GATTC profile register enumeration.
304  */
305 typedef enum
306 {
307  BLE_GATTC_EVT_REGISTER, /**< GATT client event register. */
308  BLE_GATTC_EVT_UNREGISTER, /**< GATT client event unregister. */
310 
311 
312 /**@brief GATTC profile register event for @ref BLE_GATTC_EVT_PRIMARY_SRVC_DISC. */
313 typedef struct
314 {
315  ble_gattc_prf_reg_evt_t prf_reg_evt; /**< Porfile Register Event. */
317 
318 /**@brief GATTC Browse service(s) event for @ref BLE_GATTC_EVT_SRVC_BROWSE. */
319 typedef struct
320 {
321  uint8_t serv_type; /**< Service type. See @ref gatt_serv_type_t.*/
322  uint8_t uuid_len; /**< Service UUID length. */
323  uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Service UUID. */
324  uint16_t start_hdl; /**< Service start handle. */
325  uint16_t end_hdl; /**< Service end handle. */
326  union ble_gattc_browse_attr_info *info; /**< Attribute information presented in the service(array length = end_hdl - start_hdl);If attr_type is equal to BLE_GATTC_BROWSE_NONE, the last attribute information has been found in previous one, although not reach the service end handle. */
328 
329 /**@brief GATT service discovery event for @ref BLE_GATTC_EVT_PRIMARY_SRVC_DISC. */
330 typedef struct
331 {
332  uint16_t count; /**< Service count. */
333  ble_gattc_service_t *services; /**< Service data. */
335 
336 /**@brief GATT include discovery event for @ref BLE_GATTC_EVT_INCLUDE_SRVC_DISC. */
337 typedef struct
338 {
339  uint16_t count; /**< Include count. */
340  ble_gattc_include_t *includes; /**< Include data. */
342 
343 /**@brief GATT characteristic discovery event for @ref BLE_GATTC_EVT_CHAR_DISC. */
344 typedef struct
345 {
346  uint16_t count; /**< Characteristic count. */
347  ble_gattc_char_t *chars; /**< Characteristic data. */
349 
350 /**@brief GATT characteristic descriptor discovery event for @ref BLE_GATTC_EVT_CHAR_DESC_DISC. */
351 typedef struct
352 {
353  uint16_t count; /**< Descriptor count. */
354  ble_gattc_desc_t *char_descs; /**< Descriptor data. */
356 
357 /**@brief GATT Client Read response event for @ref BLE_GATTC_EVT_READ_RSP. */
358 typedef struct
359 {
360  uint16_t count; /**< Value Count. */
361  ble_gattc_read_value_t *value; /**< Value(s) list. */
363 
364 
365 /**@brief GATT Client Write Response event for @ref BLE_GATTC_EVT_WRITE_RSP. */
366 typedef struct
367 {
368  uint16_t handle; /**< Attribute handle. */
370 
371 
372 /**@brief GATTC Notification and Indication event for @ref BLE_GATTC_EVT_NTF_IND. */
373 typedef struct
374 {
375  ble_gatt_evt_type_t type; /**< Event type. */
376  uint16_t length; /**< Attribute value length. */
377  uint16_t handle; /**< Attribute handle. */
378  uint8_t *p_value; /**< Pointer to the attribute value data. */
380 
381 /**@brief BLE GATTC event structure. */
382 typedef struct
383 {
384  uint8_t index; /**< Index of connection. */
385  union
386  {
387  ble_gattc_evt_browse_srvc_t srvc_browse; /**< Browce service discovery response event. */
388  ble_gattc_evt_srvc_disc_t prim_srvc_disc; /**< Primary service discovery response event. */
389  ble_gattc_evt_incl_disc_t inc_srvc_disc; /**< Include service discovery response event. */
390  ble_gattc_evt_char_disc_t char_disc; /**< Characteristic discovery response event. */
391  ble_gattc_evt_char_desc_disc_t char_desc_disc; /**< Characteristic descriptor discovery response event. */
392  ble_gattc_evt_read_t read_rsp; /**< Read response event. */
393  ble_gattc_evt_write_t write_rsp; /**< Write response event. */
394  ble_gattc_evt_ntf_ind_t ntf_ind; /**< Handle value Notification/Indication response. */
395  ble_gattc_evt_prf_reg_t prf_reg; /**< Profile register event. */
396  } params; /**< Event Parameters. */
398 /** @} */
399 
400 /** @addtogroup BLE_GATTC_FUNCTIONS Functions
401  * @{ */
402 
403 /**
404  ****************************************************************************************
405  * @brief Perform MTU Exchange.
406  *
407  * @param[in] conn_idx: Current connection index.
408  *
409  * @retval ::SDK_SUCCESS: Successfully send an MTU Exchange request.
410  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
411  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
412  ****************************************************************************************
413  */
414 uint16_t ble_gattc_mtu_exchange(uint8_t conn_idx);
415 
416 /**
417  ****************************************************************************************
418  * @brief Browse all Primary Services or specific Primary Service information on remote GATT server.
419  *
420  * @note This discovery automatically searches for Primary Services, Included Services, Characteristics and Descriptors of each service.
421  * To discover one or more services only, use ble_gattc_primary_services_discover() instead.
422  * This discovery is able to search all Primary Services or a specific one.
423  * If srvc_uuid is NULL, all services are returned.
424  *
425  * @param[in] conn_idx: Current connection index.
426  * @param[in] p_srvc_uuid: Pointer to Service UUID. If it is NULL, all services will be returned.
427  *
428  * @retval ::SDK_SUCCESS: Successfully start the Browse Service(s) procedure.
429  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
430  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
431  ****************************************************************************************
432  */
433 uint16_t ble_gattc_services_browse(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
434 
435 /**
436  ****************************************************************************************
437  * @brief Discover Primary Services on remote GATT server.
438  *
439  * @param[in] conn_idx: Current connection index.
440  * @param[in] p_srvc_uuid: Pointer to Service UUID. If it is NULL, all Primary Services will be returned.
441  *
442  * @retval ::SDK_SUCCESS: Successfully start the Primary Service Discovery procedure.
443  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
444  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
445  ****************************************************************************************
446  */
447 uint16_t ble_gattc_primary_services_discover(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
448 
449 /**
450  ****************************************************************************************
451  * @brief Discover Included Services on remote GATT server.
452  *
453  * @param[in] conn_idx: Current connection index.
454  * @param[in] start_hdl: Start handle.
455  * @param[in] end_hdl: End handle.
456  *
457  * @retval ::SDK_SUCCESS: Successfully start the Relationship Discovery procedure.
458  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
459  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
460  ****************************************************************************************
461  */
462 uint16_t ble_gattc_included_services_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
463 
464 /**
465  ****************************************************************************************
466  * @brief Discover Characteristics on remote GATT server.
467  *
468  * @param[in] conn_idx: Current connection index.
469  * @param[in] start_hdl: Start handle.
470  * @param[in] end_hdl: End handle.
471  * @param[in] p_char_uuid: Pointer to Characteristic UUID.If it is NULL, all characteristics are returned.
472  *
473  * @retval ::SDK_SUCCESS: Successfully start the Characteristic Discovery procedure.
474  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
475  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
476  ****************************************************************************************
477  */
478 uint16_t ble_gattc_char_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid);
479 
480 /**
481  ****************************************************************************************
482  * @brief Discover Characteristics Descriptors on remote GATT server.
483  *
484  * @param[in] conn_idx: Current connection index.
485  * @param[in] start_hdl: Start handle.
486  * @param[in] end_hdl: End handle.
487  *
488  * @retval ::SDK_SUCCESS: Successfully start the Descriptor Discovery procedure.
489  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
490  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
491  ****************************************************************************************
492  */
493 uint16_t ble_gattc_char_desc_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
494 
495 /**
496  ****************************************************************************************
497  * @brief Read Attribute from remote GATT server.
498  *
499  * @note This uses either the "Read Characteristic Value" procedure or the "Read Characteristic Descriptor"
500  * procedure, depending on the attribute pointed by handle. If offset is non-zero or the
501  * attribute length is larger than the MTU, the "Read Long Characteristic Value" procedure or the
502  * "Read Long Characteristic Descriptor" procedure will be used respectively.
503  *
504  * @param[in] conn_idx: Current connection index.
505  * @param[in] handle: Attribute handle.
506  * @param[in] offset: Value offset to start with.
507  *
508  * @retval ::SDK_SUCCESS: Successfully start the Read (Long) procedure.
509  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
510  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
511  ****************************************************************************************
512  */
513 uint16_t ble_gattc_read(uint8_t conn_idx, uint16_t handle, uint16_t offset);
514 
515 /**
516  ****************************************************************************************
517  * @brief Read Attribute by UUID.
518  *
519  * @param[in] conn_idx: Current connection index.
520  * @param[in] start_hdl: Start handle.
521  * @param[in] end_hdl: End handle.
522  * @param[in] p_char_uuid: Pointer to Characteristic UUID.
523  *
524  *
525  * @retval ::SDK_SUCCESS: Successfully start the Read using Characteristic UUID procedure.
526  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
527  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
528  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
529  ****************************************************************************************
530  */
531 uint16_t ble_gattc_read_by_uuid(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid);
532 
533 /**
534  ****************************************************************************************
535  * @brief Initiate a Read Multiple Characteristic Values procedure
536  *
537  * @param[in] conn_idx: Current connection index.
538  * @param[in] p_param: Pointer to the parameters of the value.
539  *
540  * @retval ::SDK_SUCCESS: Successfully start the Read Multiple Characteristic Values procedure.
541  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
542  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
543  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
544  ****************************************************************************************
545  */
546 uint16_t ble_gattc_read_multiple(uint8_t conn_idx, const ble_gattc_read_multiple_t *p_param);
547 
548 /**
549  ****************************************************************************************
550  * @brief Write (long) Characteristic (Descriptor) Value.
551  *
552  * @note This uses either the "Write Characteristic Value" procedure or the "Write Characteristic
553  * Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero
554  * or the attribute length is larger than the MTU, the "Write Long Characteristic Value" procedure
555  * or the "Write Long Characteristic Descriptor" procedure will be used respectively.
556  *
557  * @param[in] conn_idx: Current connection index.
558  * @param[in] handle: The handle of the attribute to be written.
559  * @param[in] offset: Offset into the attribute value to be written.
560  * @param[in] length: Length of the value data in bytes.
561  * @param[in] p_value: Pointer to the value data.
562  *
563  * @retval ::SDK_SUCCESS: Successfully start the Write procedure.
564  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
565  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
566  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
567  ****************************************************************************************
568  */
569 uint16_t ble_gattc_write(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
570 
571 /**
572  ****************************************************************************************
573  * @brief Prepare Long/Reliable Write to remote GATT server.
574  *
575  * @param[in] conn_idx: Current connection index.
576  * @param[in] handle: Attribute handle.
577  * @param[in] offset: Value offset to start with.
578  * @param[in] length: Value length.
579  * @param[in] p_value: Value data.
580  *
581  * @retval ::SDK_SUCCESS: Successfully send a Prepare Write request.
582  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
583  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
584  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
585  ****************************************************************************************
586  */
587 uint16_t ble_gattc_write_prepare(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
588 
589 /**
590  ****************************************************************************************
591  * @brief Execute Reliable/Long Write to remote GATT server.
592  *
593  * @param[in] conn_idx: Current connection index.
594  * @param[in] execute: True if data shall be written; false if cancel all prepared writes.
595  *
596  * @retval ::SDK_SUCCESS: Successfully send an Execute Write request.
597  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
598  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
599  ****************************************************************************************
600  */
601 uint16_t ble_gattc_write_execute(uint8_t conn_idx, bool execute);
602 
603 /**
604  ****************************************************************************************
605  * @brief Write Attribute to remote GATT server (without response).
606  *
607  * @note If signed_write is set to false, the "Write Without Response" procedure will be used.
608  * If signed_write is set to true, the "Signed Write Without Response" procedure will be used on
609  * a link which is not encrypted.
610  * If a link is already encrypted, "Write Without Response" procedure shall be used instead of "Signed Write Without Response".
611  *
612  * @param[in] conn_idx: Current connection index.
613  * @param[in] handle: Attribute handle.
614  * @param[in] signed_write: True if signed write should be used, false write without response.
615  * @param[in] length: Value length.
616  * @param[in] p_value: Value data.
617  *
618  * @retval ::SDK_SUCCESS: Successfully start the (Signed) Write Without Response procedure.
619  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
620  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
621  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
622  ****************************************************************************************
623  */
624 uint16_t ble_gattc_write_no_resp(uint8_t conn_idx, bool signed_write, uint16_t handle, uint16_t length, const uint8_t *p_value);
625 
626 /**
627  ****************************************************************************************
628  * @brief Confirm Reception of Indication.
629  *
630  * @note Confirm indication which has been correctly received from the peer.
631  *
632  * @param[in] conn_idx: Current connection index.
633  * @param[in] handle: Value handle.
634  *
635  * @retval ::SDK_SUCCESS: Successfully send indication confirm.
636  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
637  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
638  ****************************************************************************************
639  */
640 uint16_t ble_gattc_indicate_cfm(uint8_t conn_idx, uint16_t handle);
641 
642 /** @} */
643 
644 #endif
645 
646 /** @} */
647 
648 /** @} */
649 
ble_gattc_browse_attr_char_t::handle
uint16_t handle
Definition: ble_gattc.h:158
ble_gattc_ntf_ind_t
GATTC Notification and Indication value indication.
Definition: ble_gattc.h:295
ble_gattc_browse_attr_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:177
BLE_GATTC_BROWSE_NONE
@ BLE_GATTC_BROWSE_NONE
Definition: ble_gattc.h:85
ble_gattc_evt_ntf_ind_t
GATTC Notification and Indication event for BLE_GATTC_EVT_NTF_IND.
Definition: ble_gattc.h:374
ble_gattc_evt_read_t
GATT Client Read response event for BLE_GATTC_EVT_READ_RSP.
Definition: ble_gattc.h:359
ble_gattc_evt_char_desc_disc_t::count
uint16_t count
Definition: ble_gattc.h:353
ble_gattc_prf_reg_evt_t
ble_gattc_prf_reg_evt_t
GATTC profile register enumeration.
Definition: ble_gattc.h:306
BLE_GATTC_SEC_SERV
@ BLE_GATTC_SEC_SERV
Definition: ble_gattc.h:74
ble_gattc_evt_browse_srvc_t
GATTC Browse service(s) event for BLE_GATTC_EVT_SRVC_BROWSE.
Definition: ble_gattc.h:320
BLE_GATTC_BROWSE_ATTR_CHAR
@ BLE_GATTC_BROWSE_ATTR_CHAR
Definition: ble_gattc.h:87
BLE_ATT_UUID_128_LEN
#define BLE_ATT_UUID_128_LEN
Definition: ble_att.h:65
gatt_serv_type_t
gatt_serv_type_t
GATT Client Service type IDs.
Definition: ble_gattc.h:72
ble_gattc_evt_t::ntf_ind
ble_gattc_evt_ntf_ind_t ntf_ind
Definition: ble_gattc.h:394
ble_gattc_srvc_disc_t
GATT service discovery.
Definition: ble_gattc.h:243
ble_gattc_char_disc_t::count
uint16_t count
Definition: ble_gattc.h:258
ble_gattc_char_t::handle_value
uint16_t handle_value
Definition: ble_gattc.h:227
BLE_GATTC_BROWSE_INC_SRVC
@ BLE_GATTC_BROWSE_INC_SRVC
Definition: ble_gattc.h:86
BLE_GATTC_EVT_REGISTER
@ BLE_GATTC_EVT_REGISTER
Definition: ble_gattc.h:307
BLE_GATTC_BROWSE_ATTR_DESC
@ BLE_GATTC_BROWSE_ATTR_DESC
Definition: ble_gattc.h:89
ble_gattc_service_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:210
ble_gattc_write_prepare
uint16_t ble_gattc_write_prepare(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value)
Prepare Long/Reliable Write to remote GATT server.
ble_gattc_browse_inc_srvc_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:170
BLE_GATTC_BROWSE_ATTR_VAL
@ BLE_GATTC_BROWSE_ATTR_VAL
Definition: ble_gattc.h:88
ble_gattc_read_by_uuid_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:112
ble_gattc_included_services_discover
uint16_t ble_gattc_included_services_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Discover Included Services on remote GATT server.
ble_gattc_evt_browse_srvc_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:324
ble_gattc_evt_browse_srvc_t::serv_type
uint8_t serv_type
Definition: ble_gattc.h:321
ble_gattc_read_multiple_t::handle_count
uint16_t handle_count
Definition: ble_gattc.h:149
ble_gattc_evt_read_t::value
ble_gattc_read_value_t * value
Definition: ble_gattc.h:361
ble_gattc_write_attr_value_t::length
uint16_t length
Definition: ble_gattc.h:124
ble_gattc_write_attr_value_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:125
ble_gattc_char_disc_t
GATT characteristic discovery.
Definition: ble_gattc.h:257
ble_gattc_include_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:218
ble_gattc_evt_t::inc_srvc_disc
ble_gattc_evt_incl_disc_t inc_srvc_disc
Definition: ble_gattc.h:389
ble_gattc_char_desc_discover
uint16_t ble_gattc_char_desc_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Discover Characteristics Descriptors on remote GATT server.
ble_gattc_multiple_att_t::len
uint16_t len
Definition: ble_gattc.h:143
ble_gattc_evt_read_t::count
uint16_t count
Definition: ble_gattc.h:360
ble_gattc_evt_write_t
GATT Client Write Response event for BLE_GATTC_EVT_WRITE_RSP.
Definition: ble_gattc.h:367
ble_gattc_write_attr_value_t::offset
uint16_t offset
Definition: ble_gattc.h:123
ble_gattc_char_t::handle_decl
uint16_t handle_decl
Definition: ble_gattc.h:226
ble_gattc_ntf_ind_t::length
uint16_t length
Definition: ble_gattc.h:297
ble_gattc_mtu_exchange
uint16_t ble_gattc_mtu_exchange(uint8_t conn_idx)
Perform MTU Exchange.
ble_gattc_multiple_att_t::handle
uint16_t handle
Definition: ble_gattc.h:142
ble_gattc_desc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:237
ble_gattc_service_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:209
ble_gattc_evt_t::write_rsp
ble_gattc_evt_write_t write_rsp
Definition: ble_gattc.h:393
ble_gattc_char_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:229
ble_gattc_evt_srvc_disc_t
GATT service discovery event for BLE_GATTC_EVT_PRIMARY_SRVC_DISC.
Definition: ble_gattc.h:331
ble_gattc_evt_browse_srvc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:322
ble_gattc_services_browse
uint16_t ble_gattc_services_browse(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Browse all Primary Services or specific Primary Service information on remote GATT server.
ble_gattc_evt_char_desc_disc_t::char_descs
ble_gattc_desc_t * char_descs
Definition: ble_gattc.h:354
ble_gatt.h
BLE GATT.
ble_gattc_browse_attr_info::attr
ble_gattc_browse_attr_t attr
Definition: ble_gattc.h:187
ble_gattc_read_multiple_t::p_read_multiple
ble_gattc_multiple_att_t * p_read_multiple
Definition: ble_gattc.h:150
ble_gattc_browse_attr_char_t
GATTC Browse information about Characteristic.
Definition: ble_gattc.h:155
ble_gattc_evt_t::char_disc
ble_gattc_evt_char_disc_t char_disc
Definition: ble_gattc.h:390
ble_gattc_browse_attr_info::inc_srvc
ble_gattc_browse_inc_srvc_t inc_srvc
Definition: ble_gattc.h:186
ble_gattc_browse_srvc_t
GATTC Browse service(s) indication.
Definition: ble_gattc.h:192
ble_gattc_char_t
GATT characteristic.
Definition: ble_gattc.h:225
ble_gattc_evt_t::prf_reg
ble_gattc_evt_prf_reg_t prf_reg
Definition: ble_gattc.h:395
ble_gattc_browse_inc_srvc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:167
ble_gattc_evt_ntf_ind_t::handle
uint16_t handle
Definition: ble_gattc.h:377
ble_gattc_read_value_t
GATT Client Read value.
Definition: ble_gattc.h:271
ble_gattc_write_no_resp_t
GATTC write without response structure.
Definition: ble_gattc.h:132
ble_gattc_browse_srvc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:194
ble_gattc_evt_write_t::handle
uint16_t handle
Definition: ble_gattc.h:368
ble_gattc_incl_disc_t
GATT include discovery.
Definition: ble_gattc.h:250
ble_gattc_multiple_att_t
Read Multiple Handles.
Definition: ble_gattc.h:141
BLE_GATTC_PRI_SERV
@ BLE_GATTC_PRI_SERV
Definition: ble_gattc.h:73
ble_gattc_char_desc_disc_t
GATT characteristic descriptor discovery.
Definition: ble_gattc.h:264
ble_gattc_write_attr_value_t::handle
uint16_t handle
Definition: ble_gattc.h:122
ble_gattc_char_t::prop
uint8_t prop
Definition: ble_gattc.h:228
ble_gattc_evt_incl_disc_t::includes
ble_gattc_include_t * includes
Definition: ble_gattc.h:340
ble_gattc_evt_prf_reg_t
GATTC profile register event for BLE_GATTC_EVT_PRIMARY_SRVC_DISC.
Definition: ble_gattc.h:314
ble_gattc_attr_type_t
ble_gattc_attr_type_t
GATT Client Service Discover Attribute type IDs.
Definition: ble_gattc.h:84
ble_gattc_evt_browse_srvc_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:325
ble_error.h
File that contains error codes.
ble_gattc_browse_inc_srvc_t::attr_type
ble_gattc_attr_type_t attr_type
Definition: ble_gattc.h:166
ble_gattc_service_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:208
ble_gattc_write_no_resp_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:136
ble_gattc_write
uint16_t ble_gattc_write(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value)
Write (long) Characteristic (Descriptor) Value.
ble_gattc_include_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:219
ble_gattc_primary_services_discover
uint16_t ble_gattc_primary_services_discover(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Discover Primary Services on remote GATT server.
ble_gattc_write_no_resp
uint16_t ble_gattc_write_no_resp(uint8_t conn_idx, bool signed_write, uint16_t handle, uint16_t length, const uint8_t *p_value)
Write Attribute to remote GATT server (without response).
ble_gattc_browse_attr_info::attr_type
ble_gattc_attr_type_t attr_type
Definition: ble_gattc.h:184
BLE_GATTC_EVT_UNREGISTER
@ BLE_GATTC_EVT_UNREGISTER
Definition: ble_gattc.h:308
ble_gattc_write_no_resp_t::length
uint16_t length
Definition: ble_gattc.h:135
__ARRAY_EMPTY
#define __ARRAY_EMPTY
Definition: gr5405_sys_cfg.h:53
ble_gattc_browse_attr_char_t::attr_type
ble_gattc_attr_type_t attr_type
Definition: ble_gattc.h:156
ble_gattc_evt_char_disc_t
GATT characteristic discovery event for BLE_GATTC_EVT_CHAR_DISC.
Definition: ble_gattc.h:345
ble_gattc_disc_char_t::p_uuid
ble_uuid_t * p_uuid
Definition: ble_gattc.h:104
ble_gattc_evt_char_disc_t::count
uint16_t count
Definition: ble_gattc.h:346
ble_gattc_read_value_t::offset
uint16_t offset
Definition: ble_gattc.h:273
ble_gattc_evt_incl_disc_t::count
uint16_t count
Definition: ble_gattc.h:339
ble_gattc_desc_t
GATT descriptor.
Definition: ble_gattc.h:235
ble_gattc_evt_ntf_ind_t::type
ble_gatt_evt_type_t type
Definition: ble_gattc.h:375
ble_gattc_srvc_disc_t::count
uint16_t count
Definition: ble_gattc.h:244
ble_gatt_evt_type_t
ble_gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
ble_gattc_write_t::handle
uint16_t handle
Definition: ble_gattc.h:289
ble_gattc_service_t
GATT service.
Definition: ble_gattc.h:206
ble_gattc_read
uint16_t ble_gattc_read(uint8_t conn_idx, uint16_t handle, uint16_t offset)
Read Attribute from remote GATT server.
ble_gattc_read_by_uuid_t::p_uuid
ble_uuid_t * p_uuid
Definition: ble_gattc.h:114
ble_gattc_browse_srvc_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:196
ble_gattc_browse_inc_srvc_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:169
ble_gattc_char_discover
uint16_t ble_gattc_char_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid)
Discover Characteristics on remote GATT server.
ble_gattc_read_value_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:275
ble_gattc_write_attr_value_t
GATTC write attribute value structure.
Definition: ble_gattc.h:121
ble_gattc_ntf_ind_t::handle
uint16_t handle
Definition: ble_gattc.h:298
ble_gattc_desc_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:238
ble_gattc_include_t
GATT include.
Definition: ble_gattc.h:215
ble_gattc_indicate_cfm
uint16_t ble_gattc_indicate_cfm(uint8_t conn_idx, uint16_t handle)
Confirm Reception of Indication.
ble_gattc_evt_srvc_disc_t::count
uint16_t count
Definition: ble_gattc.h:332
ble_gattc_write_no_resp_t::signed_write
bool signed_write
Definition: ble_gattc.h:133
ble_gattc_browse_srvc_t::serv_type
uint8_t serv_type
Definition: ble_gattc.h:193
ble_gattc_evt_t::prim_srvc_disc
ble_gattc_evt_srvc_disc_t prim_srvc_disc
Definition: ble_gattc.h:388
ble_gattc_browse_attr_char_t::prop
uint8_t prop
Definition: ble_gattc.h:157
ble_gattc_char_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:230
ble_gattc_read_by_uuid_t
GATTC read by characteristic UUID structure.
Definition: ble_gattc.h:111
ble_gattc_read_by_uuid_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:113
ble_gattc_evt_browse_srvc_t::info
union ble_gattc_browse_attr_info * info
Definition: ble_gattc.h:326
ble_gattc_evt_t::index
uint8_t index
Definition: ble_gattc.h:384
ble_gattc_incl_disc_t::count
uint16_t count
Definition: ble_gattc.h:251
ble_gattc_disc_char_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:102
ble_gattc_evt_char_desc_disc_t
GATT characteristic descriptor discovery event for BLE_GATTC_EVT_CHAR_DESC_DISC.
Definition: ble_gattc.h:352
ble_att.h
Attribute Protocol.
ble_gattc_evt_t::char_desc_disc
ble_gattc_evt_char_desc_disc_t char_desc_disc
Definition: ble_gattc.h:391
ble_gattc_evt_char_disc_t::chars
ble_gattc_char_t * chars
Definition: ble_gattc.h:347
ble_gattc_browse_inc_srvc_t
GATTC Browse information about Included Service.
Definition: ble_gattc.h:165
ble_gattc_write_t
GATT Client Write.
Definition: ble_gattc.h:288
ble_gattc_browse_attr_info
GATTC Browse attribute information.
Definition: ble_gattc.h:183
ble_gattc_include_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:220
ble_gattc_evt_t::srvc_browse
ble_gattc_evt_browse_srvc_t srvc_browse
Definition: ble_gattc.h:387
ble_gattc_evt_srvc_disc_t::services
ble_gattc_service_t * services
Definition: ble_gattc.h:333
ble_gattc_evt_t::read_rsp
ble_gattc_evt_read_t read_rsp
Definition: ble_gattc.h:392
ble_uuid_t
GATT UUID structure.
Definition: ble_gatt.h:81
ble_gattc_read_rsp_t
GATT value Read response.
Definition: ble_gattc.h:280
ble_gattc_read_by_uuid
uint16_t ble_gattc_read_by_uuid(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid)
Read Attribute by UUID.
ble_gattc_char_desc_disc_t::count
uint16_t count
Definition: ble_gattc.h:265
ble_gattc_browse_attr_char_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:159
ble_gattc_browse_attr_info::attr_char
ble_gattc_browse_attr_char_t attr_char
Definition: ble_gattc.h:185
ble_gattc_evt_incl_disc_t
GATT include discovery event for BLE_GATTC_EVT_INCLUDE_SRVC_DISC.
Definition: ble_gattc.h:338
ble_gattc_read_multiple_t
GATTC Read Multiple.
Definition: ble_gattc.h:148
ble_gattc_include_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:217
ble_gattc_desc_t::attr_hdl
uint16_t attr_hdl
Definition: ble_gattc.h:236
ble_gattc_include_t::attr_hdl
uint16_t attr_hdl
Definition: ble_gattc.h:216
ble_gattc_evt_ntf_ind_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:378
ble_gattc_ntf_ind_t::type
ble_gatt_evt_type_t type
Definition: ble_gattc.h:296
ble_gattc_read_value_t::length
uint16_t length
Definition: ble_gattc.h:274
ble_gattc_read_value_t::handle
uint16_t handle
Definition: ble_gattc.h:272
ble_gattc_write_no_resp_t::handle
uint16_t handle
Definition: ble_gattc.h:134
ble_gattc_browse_attr_t
GATTC Browse information about Attribute.
Definition: ble_gattc.h:175
ble_gattc_browse_attr_t::attr_type
ble_gattc_attr_type_t attr_type
Definition: ble_gattc.h:176
ble_gattc_evt_prf_reg_t::prf_reg_evt
ble_gattc_prf_reg_evt_t prf_reg_evt
Definition: ble_gattc.h:315
ble_gattc_ntf_ind_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:299
ble_gattc_write_execute
uint16_t ble_gattc_write_execute(uint8_t conn_idx, bool execute)
Execute Reliable/Long Write to remote GATT server.
ble_gattc_read_multiple
uint16_t ble_gattc_read_multiple(uint8_t conn_idx, const ble_gattc_read_multiple_t *p_param)
Initiate a Read Multiple Characteristic Values procedure.
ble_gattc_evt_ntf_ind_t::length
uint16_t length
Definition: ble_gattc.h:376
ble_gattc_read_rsp_t::count
uint16_t count
Definition: ble_gattc.h:281
ble_gattc_disc_char_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:103
ble_gattc_service_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:207
ble_gattc_evt_t
BLE GATTC event structure.
Definition: ble_gattc.h:383
ble_gattc_disc_char_t
GATTC discovery characteristic structure.
Definition: ble_gattc.h:101