• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "gr55xx_sys_cfg.h"
62 
63 #include <stdint.h>
64 #include <stdbool.h>
65 
66 /** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
67  * @{ */
68 
69 /**
70  * @brief GATT Client Service Discover Attribute type IDs.
71  */
72 typedef enum {
73     BLE_GATTC_BROWSE_NONE,          /**< No Attribute Information. */
74     BLE_GATTC_BROWSE_INC_SRVC,      /**< Included Service information. */
75     BLE_GATTC_BROWSE_ATTR_CHAR,     /**< Characteristic Declaration. */
76     BLE_GATTC_BROWSE_ATTR_VAL,      /**< Attribute Value definition. */
77     BLE_GATTC_BROWSE_ATTR_DESC,     /**< Attribute Descriptor. */
78 } gatt_attr_t;
79 
80 /** @} */
81 
82 /** @addtogroup BLE_GATTC_STRUCTURES Structures
83  * @{ */
84 
85 /**
86  * @brief GATTC discovery characteristic structure.
87  */
88 typedef struct {
89     uint16_t        start_hdl;              /**< Start handle. */
90     uint16_t        end_hdl;                /**< End handle. */
91     ble_uuid_t     *p_uuid;                 /**< Characteristic UUID. */
92 } gattc_disc_char_t;
93 
94 /**
95  * @brief GATTC read by characteristic UUID structure.
96  */
97 typedef struct {
98     uint16_t        start_hdl;      /**< Start handle. */
99     uint16_t        end_hdl;        /**< End handle. */
100     ble_uuid_t     *p_uuid;         /**< Characteristic UUID. */
101 } gattc_read_by_uuid_t;
102 
103 /**
104  * @brief GATTC write attribute value structure.
105  */
106 typedef struct {
107     uint16_t        handle;         /**< Attribute handle. */
108     uint16_t        offset;         /**< value offset to start with. */
109     uint16_t        length;         /**< Write length. */
110     uint8_t        *p_value;        /**< Value to write. */
111 } gattc_write_attr_value_t;
112 
113 /**
114  * @brief GATTC write without response structure.
115  */
116 typedef struct {
117     bool            signed_write;       /**< True if signed write should be used when possible/applicable. */
118     uint16_t        handle;             /**< Attribute handle. */
119     uint16_t        length;             /**< Write length. */
120     uint8_t        *p_value;            /**< Value to write. */
121 } gattc_write_no_resp_t;
122 
123 /** @brief Read Multiple Handles. */
124 typedef struct {
125     uint16_t    handle;    /**< Attribute handle. */
126     uint16_t    len;       /**< Known value: length of the handle (len shall not be set to 0). */
127 } read_multiple_t;
128 
129 /** @brief GATTC Read Multiple. */
130 typedef struct {
131     uint16_t            handle_count;      /**< Handle count of the multiple attributes to be read. */
132     read_multiple_t    *p_read_multiple;   /**< Pointer to the multiple attributes to be read. */
133 } gattc_read_multiple_t;
134 
135 
136 /** @brief GATTC Browse information about Characteristic. */
137 typedef struct {
138     uint8_t attr_type;    /**< Attribute type. See @ref BLE_GATTC_BROWSE_ATTR_CHAR for Characteristic Declaration. */
139     uint8_t     prop;     /**< Value property. */
140     uint16_t    handle;   /**< Value handle. */
141     uint8_t     uuid_len; /**< Characteristic UUID length. */
142     uint8_t     uuid[BLE_ATT_UUID_128_LEN];     /**< Characteristic UUID. */
143 } gattc_browse_attr_char_t;
144 
145 /** @brief GATTC Browse information about Included Service. */
146 typedef struct {
147     uint8_t  attr_type;   /**< Attribute type. See @ref BLE_GATTC_BROWSE_INC_SRVC for Included Service Information. */
148     uint8_t  uuid_len;                       /**< Included Service UUID length. */
149     uint8_t  uuid[BLE_ATT_UUID_128_LEN];     /**< Included Service UUID. */
150     uint16_t start_hdl;                      /**< Included Service start handle. */
151     uint16_t end_hdl;                        /**< Included Service end handle. */
152 } gattc_browse_inc_srvc_t;
153 
154 /** @brief GATTC Browse information about Attribute. */
155 typedef struct {
156     uint8_t  attr_type;                    /**< Attribute type. See @ref BLE_GATTC_BROWSE_ATTR_VAL for Attribute Value.
157                                                 See @ref BLE_GATTC_BROWSE_ATTR_DESC for Attribute Descriptor. */
158     uint8_t  uuid_len;                     /**< Attribute UUID length. */
159     uint8_t  uuid[BLE_ATT_UUID_128_LEN];   /**< Characteristic UUID or Characteristic Descriptor UUID. */
160 } gattc_browse_attr_t;
161 
162 /** @brief GATTC Browse attribute information. */
163 union gattc_browse_attr_info {
164     uint8_t attr_type;        /**< Attribute type. See @ref gatt_attr_t. */
165     gattc_browse_attr_char_t attr_char; /**< Information about Characteristic.
166                                              When union attr_type is @ref BLE_GATTC_BROWSE_ATTR_CHAR */
167     gattc_browse_inc_srvc_t inc_srvc;   /**< Information about Included Service.
168                                              When union attr_type is @ref BLE_GATTC_BROWSE_INC_SRVC */
169     gattc_browse_attr_t attr;           /**< Information about Attribute. When union attr_type is
170                                              @ref BLE_GATTC_BROWSE_ATTR_VAL or @ref BLE_GATTC_BROWSE_ATTR_DESC. */
171 };
172 
173 /** @brief GATTC Browse service(s) indication. */
174 typedef struct {
175     uint8_t  uuid_len;                                  /**< Service UUID length. */
176     uint8_t  uuid[BLE_ATT_UUID_128_LEN];                /**< Service UUID. */
177     uint16_t start_hdl;                                 /**< Service start handle. */
178     uint16_t end_hdl;                                   /**< Service end handle. */
179     union gattc_browse_attr_info info[ARRAY_EMPTY];   /**< Attribute information presented in the service
180                                                              (array length = end_hdl - start_hdl);
181                                                              If attr_type is equal to BLE_GATTC_BROWSE_NONE,the last
182                                                              attribute information has been found in previous one,
183                                                              although not reach the service end handle. */
184 } ble_gattc_browse_srvc_t;
185 
186 /** @brief GATT service. */
187 typedef struct {
188     uint16_t  start_hdl;            /**< Start handle. */
189     uint16_t  end_hdl;              /**< End handle. */
190     uint8_t   uuid_len;             /**< Service UUID length. */
191     uint8_t  *p_uuid;               /**< Service UUID. */
192 } ble_gattc_service_t;
193 
194 /** @brief GATT include. */
195 typedef struct {
196     uint16_t  attr_hdl;               /**< Attribute handle. */
197     uint16_t  start_hdl;              /**< Start handle. */
198     uint16_t  end_hdl;                /**< End handle. */
199     uint8_t   uuid_len;               /**< Service UUID length. */
200     uint8_t  *p_uuid;                 /**< Service UUID. */
201 } ble_gattc_include_t;
202 
203 /** @brief GATT characteristic. */
204 typedef struct {
205     uint16_t  handle_decl;            /**< Handle of the Characteristic Declaration. */
206     uint16_t  handle_value;           /**< Handle of the Characteristic Value. */
207     uint8_t   prop;                   /**< Properties. */
208     uint8_t   uuid_len;               /**< Characteristic UUID length. */
209     uint8_t  *p_uuid;                 /**< Characteristic UUID. */
210 } ble_gattc_char_t;
211 
212 /** @brief GATT descriptor. */
213 typedef struct {
214     uint16_t  attr_hdl;               /**< Attribute handle. */
215     uint8_t   uuid_len;               /**< Descriptor UUID length. */
216     uint8_t  *p_uuid;                 /**< Descriptor UUID. */
217 } ble_gattc_desc_t;
218 
219 /** @brief GATT service discovery. */
220 typedef struct {
221     uint16_t            count;                        /**< Service count. */
222     ble_gattc_service_t services[ARRAY_EMPTY];      /**< Service data. */
223 } ble_gattc_srvc_disc_t;
224 
225 /** @brief GATT include discovery. */
226 typedef struct {
227     uint16_t            count;                       /**< Include count. */
228     ble_gattc_include_t includes[ARRAY_EMPTY];     /**< Include data. */
229 } ble_gattc_incl_disc_t;
230 
231 /** @brief GATT characteristic discovery. */
232 typedef struct {
233     uint16_t            count;                  /**< Characteristic count. */
234     ble_gattc_char_t    chars[ARRAY_EMPTY];   /**< Characteristic data. */
235 } ble_gattc_char_disc_t;
236 
237 /** @brief GATT characteristic descriptor discovery. */
238 typedef struct {
239     uint16_t            count;                      /**< Descriptor count. */
240     ble_gattc_desc_t    char_descs[ARRAY_EMPTY];  /**< Descriptor data. */
241 } ble_gattc_char_desc_disc_t;
242 
243 /** @brief GATT Client Read value. */
244 typedef struct {
245     uint16_t  handle;                 /**< Attribute handle. */
246     uint16_t  offset;                 /**< Offset of the attribute value. */
247     uint16_t  length;                 /**< Attribute value length. */
248     uint8_t  *p_value;                /**< Pointer to the attribute value data. */
249 } ble_gattc_read_value_t;
250 
251 /** @brief GATT value Read response. */
252 typedef struct {
253     uint16_t                    count;                 /**< Value Count. */
254     ble_gattc_read_value_t      vals[ARRAY_EMPTY];   /**< Value(s) list. */
255 } ble_gattc_read_rsp_t;
256 
257 
258 /** @brief GATT Client Write. */
259 typedef struct {
260     uint16_t handle;            /**< Attribute handle. */
261 } ble_gattc_write_t;
262 
263 
264 /** @brief GATTC Notification and Indication value indication. */
265 typedef struct {
266     gatt_evt_type_t  type;               /**< Event type. */
267     uint16_t         length;             /**< Attribute value length. */
268     uint16_t         handle;             /**< Attribute handle. */
269     uint8_t         *p_value;            /**< Pointer to the attribute value data. */
270 } ble_gattc_ntf_ind_t;
271 
272 /** @brief GATTC Event callback Structures. */
273 typedef struct {
274     /**< Primary Service Discovery Response callback. */
275     void (*app_gattc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_srvc_disc_t *p_prim_srvc_disc);
276     /**< Relationship Discovery Response callback. */
277     void (*app_gattc_inc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status,
278                                        const ble_gattc_incl_disc_t *p_inc_srvc_disc);
279     /**< Characteristic Discovery Response callback. */
280     void (*app_gattc_char_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_char_disc_t *p_char_disc);
281     /**< Descriptor Discovery Response callback. */
282     void (*app_gattc_char_desc_disc_cb)(uint8_t conn_idx, uint8_t status,
283                                         const ble_gattc_char_desc_disc_t *p_char_desc_disc);
284     /**< Read Response callback. */
285     void (*app_gattc_read_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_read_rsp_t *p_read_rsp);
286     /**< Write complete callback. */
287     void (*app_gattc_write_cb)(uint8_t conn_idx, uint8_t status, uint16_t handle);
288     /**< Handle Value Notification/Indication Event callback. */
289     void (*app_gattc_ntf_ind_cb)(uint8_t conn_idx, const ble_gattc_ntf_ind_t *p_ntf_ind);
290     /**< Service found callback during browsing procedure. */
291     void (*app_gattc_srvc_browse_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_browse_srvc_t *p_browse_srvc);
292 } gattc_cb_fun_t;
293 /** @} */
294 
295 /** @addtogroup BLE_GATTC_FUNCTIONS Functions
296  * @{ */
297 
298 /**
299  ****************************************************************************************
300  * @brief Perform MTU Exchange.
301  *
302  * @note MTU Exchange Callback @ref gatt_common_cb_fun_t::app_gatt_mtu_exchange_cb will be called to
303  *       indicate to APP once receiving the peer response.
304  *
305  * @param[in] conn_idx:     Current connection index.
306  *
307  * @retval ::SDK_SUCCESS: Successfully send an MTU Exchange request.
308  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
309  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
310  ****************************************************************************************
311  */
312 uint16_t ble_gattc_mtu_exchange(uint8_t conn_idx);
313 
314 /**
315  ****************************************************************************************
316  * @brief Browse all Primary Services or specific Primary Service information on remote GATT server.
317  *
318  * @note This discovery automatically searches for Primary Services, Included Services,
319  *       Characteristics and Descriptors of each service.
320  *       To discover one or more services only, use ble_gattc_primary_services_discover() instead.
321  *       This discovery is able to search all Primary Services or a specific one.
322  *       If srvc_uuid is NULL, all services are returned.
323  *
324  * @note Function callback @ref gattc_cb_fun_t::app_gattc_srvc_browse_cb will be called for
325  *       all attributes of each service found.
326  *
327  * @param[in] conn_idx:        Current connection index.
328  * @param[in] p_srvc_uuid:     Pointer to Service UUID. If it is NULL, all services will be returned.
329  *
330  * @retval ::SDK_SUCCESS: Successfully start the Browse Service(s) procedure.
331  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
332  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
333  ****************************************************************************************
334  */
335 uint16_t ble_gattc_services_browse(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
336 
337 /**
338  ****************************************************************************************
339  * @brief Discover Primary Services on remote GATT server.
340  *
341  * @note Function callback @ref gattc_cb_fun_t::app_gattc_srvc_disc_cb will be called for service(s) found.
342  *
343  * @param[in] conn_idx:       Current connection index.
344  * @param[in] p_srvc_uuid:    Pointer to Service UUID. If it is NULL, all Primary Services will be returned.
345  *
346  * @retval ::SDK_SUCCESS: Successfully start the Primary Service Discovery procedure.
347  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
348  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
349  ****************************************************************************************
350  */
351 uint16_t ble_gattc_primary_services_discover(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
352 
353 /**
354  ****************************************************************************************
355  * @brief Discover Included Services on remote GATT server.
356  *
357  * @note Function callback @ref gattc_cb_fun_t:app_gattc_inc_srvc_disc_cb will be called for Included Service(s) found.
358  * @param[in] conn_idx:     Current connection index.
359  * @param[in] start_hdl:    Start handle.
360  * @param[in] end_hdl:      End handle.
361  *
362  * @retval ::SDK_SUCCESS: Successfully start the Relationship Discovery procedure.
363  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
364  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
365  ****************************************************************************************
366  */
367 uint16_t ble_gattc_included_services_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
368 
369 /**
370  ****************************************************************************************
371  * @brief Discover Characteristics on remote GATT server.
372  * @note Function callback @ref gattc_cb_fun_t::app_gattc_char_disc_cb will be called
373  *       for Characteristic Declaration(s) found.
374  * @param[in] conn_idx:       Current connection index.
375  * @param[in] start_hdl:      Start handle.
376  * @param[in] end_hdl:        End handle.
377  * @param[in] p_char_uuid:    Pointer to Characteristic UUID.If it is NULL, all characteristics are returned.
378  *
379  * @retval ::SDK_SUCCESS: Successfully start the Characteristic Discovery procedure.
380  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
381  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
382  ****************************************************************************************
383  */
384 uint16_t ble_gattc_char_discover(uint8_t conn_idx, uint16_t start_hdl,
385                                  uint16_t end_hdl, const ble_uuid_t *p_char_uuid);
386 
387 /**
388  ****************************************************************************************
389  * @brief Discover Characteristics Descriptors on remote GATT server.
390  *
391  * @note Function callback @ref gattc_cb_fun_t::app_gattc_char_desc_disc_cb will be called
392  *       for Characteristic Descriptor(s) found.
393  *       If the last Descriptor has not been reached, this function must be called again with an updated handle
394  *       range to continue the discovery.
395  *
396  * @param[in] conn_idx:     Current connection index.
397  * @param[in] start_hdl:    Start handle.
398  * @param[in] end_hdl:      End handle.
399  *
400  * @retval ::SDK_SUCCESS: Successfully start the Descriptor Discovery procedure.
401  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
402  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
403  ****************************************************************************************
404  */
405 uint16_t ble_gattc_char_desc_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
406 
407 /**
408  ****************************************************************************************
409  * @brief Read Attribute from remote GATT server.
410  *
411  * @note This uses either the "Read Characteristic Value" procedure or the "Read Characteristic Descriptor"
412  *       procedure, depending on the attribute pointed by handle. If offset is non-zero or the
413  *       attribute length is larger than the MTU, the "Read Long Characteristic Value" procedure or the
414  *       "Read Long Characteristic Descriptor" procedure will be used respectively.
415  *
416  * @note Function callback @ref gattc_cb_fun_t::app_gattc_read_cb will be called when Read is finished.
417  * @param[in] conn_idx:   Current connection index.
418  * @param[in] handle:     Attribute handle.
419  * @param[in] offset:     Value offset to start with.
420  *
421  * @retval ::SDK_SUCCESS: Successfully start the Read (Long) procedure.
422  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
423  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
424  ****************************************************************************************
425  */
426 uint16_t ble_gattc_read(uint8_t conn_idx, uint16_t handle, uint16_t offset);
427 
428 /**
429  ****************************************************************************************
430  * @brief Read Attribute by UUID.
431  *
432  * @note Function callback @ref gattc_cb_fun_t::app_gattc_read_cb will be called when Read is finished.
433  * @param[in] conn_idx:         Current connection index.
434  * @param[in] start_hdl:        Start handle.
435  * @param[in] end_hdl:          End handle.
436  * @param[in] p_char_uuid:      Pointer to Characteristic UUID.
437  *
438  *
439  * @retval ::SDK_SUCCESS: Successfully start the Read using Characteristic UUID procedure.
440  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
441  * @retval ::SDK_ERR_POINTER_NULL:     Invalid pointer supplied.
442  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
443  ****************************************************************************************
444  */
445 uint16_t ble_gattc_read_by_uuid(uint8_t conn_idx, uint16_t start_hdl,
446                                 uint16_t end_hdl, const ble_uuid_t *p_char_uuid);
447 
448 /**
449  ****************************************************************************************
450  * @brief Initiate a Read Multiple Characteristic Values procedure
451  *
452  * @note Function callback @ref gattc_cb_fun_t::app_gattc_read_cb will be called for each handle value which is read.
453  * @param[in] conn_idx:    Current connection index.
454  * @param[in] p_param:     Pointer to the parameters of the value.
455  *
456  * @retval ::SDK_SUCCESS: Successfully start the Read Multiple Characteristic Values procedure.
457  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
458  * @retval ::SDK_ERR_POINTER_NULL:     Invalid pointer supplied.
459  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
460  ****************************************************************************************
461  */
462 uint16_t ble_gattc_read_multiple(uint8_t conn_idx, const gattc_read_multiple_t *p_param);
463 
464 /**
465  ****************************************************************************************
466  * @brief Write (long) Characteristic (Descriptor) Value.
467  *
468  * @note This uses either the "Write Characteristic Value" procedure or the "Write Characteristic
469  *       Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero
470  *       or the attribute length is larger than the MTU, the "Write Long Characteristic Value" procedure
471  *       or the "Write Long Characteristic Descriptor" procedure will be used respectively.
472  *
473  * @note Once completed @ref gattc_cb_fun_t::app_gattc_write_cb will be called.
474  *
475  * @param[in] conn_idx:     Current connection index.
476  * @param[in] handle:       The handle of the attribute to be written.
477  * @param[in] offset:       Offset into the attribute value to be written.
478  * @param[in] length:       Length of the value data in bytes.
479  * @param[in] p_value:      Pointer to the value data.
480  *
481  * @retval ::SDK_SUCCESS: Successfully start the Write procedure.
482  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
483  * @retval ::SDK_ERR_POINTER_NULL:     Invalid pointer supplied.
484  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
485  ****************************************************************************************
486  */
487 uint16_t ble_gattc_write(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
488 
489 /**
490  ****************************************************************************************
491  * @brief Prepare Long/Reliable Write to remote GATT server.
492  *
493  * @note When this function completes, @ref gattc_cb_fun_t::app_gattc_write_cb will be called.
494  *
495  * @param[in] conn_idx:     Current connection index.
496  * @param[in] handle:       Attribute handle.
497  * @param[in] offset:       Value offset to start with.
498  * @param[in] length:       Value length.
499  * @param[in] p_value:      Value data.
500  *
501  * @retval ::SDK_SUCCESS: Successfully send a Prepare Write request.
502  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
503  * @retval ::SDK_ERR_POINTER_NULL:     Invalid pointer supplied.
504  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
505  ****************************************************************************************
506  */
507 uint16_t ble_gattc_write_prepare(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length,
508                                  const uint8_t *p_value);
509 
510 /**
511  ****************************************************************************************
512  * @brief Execute Reliable/Long Write to remote GATT server.
513  *
514  * @note When this function completes, @ref gattc_cb_fun_t::app_gattc_write_cb will be called.
515  *
516  * @param[in] conn_idx:     Current connection index.
517  * @param[in] execute:      True if data shall be written; false if cancel all prepared writes.
518  *
519  * @retval ::SDK_SUCCESS: Successfully send an Execute Write request.
520  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
521  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
522  ****************************************************************************************
523  */
524 uint16_t ble_gattc_write_execute(uint8_t conn_idx, bool execute);
525 
526 /**
527  ****************************************************************************************
528  * @brief Write Attribute to remote GATT server (without response).
529  *
530  * @note If signed_write is set to false, the "Write Without Response" procedure will be used.
531  *       If signed_write is set to true, the "Signed Write Without Response" procedure will be used on
532  *       a link which is not encrypted. If a link is already encrypted,
533  *       "Write Without Response" procedure shall be used instead of "Signed Write Without Response".
534  * @note Once completed @ref gattc_cb_fun_t::app_gattc_write_cb will be called.
535  *
536  * @param[in] conn_idx:         Current connection index.
537  * @param[in] handle:           Attribute handle.
538  * @param[in] signed_write:     True if signed write should be used, false write without response.
539  * @param[in] length:           Value length.
540  * @param[in] p_value:          Value data.
541  *
542  * @retval ::SDK_SUCCESS: Successfully start the (Signed) Write Without Response procedure.
543  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
544  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
545  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
546  ****************************************************************************************
547  */
548 uint16_t ble_gattc_write_no_resp(uint8_t conn_idx, bool signed_write, uint16_t handle, uint16_t length,
549                                  const uint8_t *p_value);
550 
551 /**
552  ****************************************************************************************
553  * @brief Confirm Reception of Indication.
554  *
555  * @note Confirm indication which has been correctly received from the peer.
556  *
557  * @param[in] conn_idx:     Current connection index.
558  * @param[in] handle:       Value handle.
559  *
560  * @retval ::SDK_SUCCESS: Successfully send indication confirm.
561  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
562  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
563  ****************************************************************************************
564  */
565 uint16_t ble_gattc_indicate_cfm(uint8_t conn_idx, uint16_t handle);
566 
567 /** @} */
568 
569 #endif
570 
571 /** @} */
572 
573 /** @} */
574 /** @} */
575 
576