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 #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 {
74 BLE_GATTC_BROWSE_NONE, /**< No Attribute Information. */
75 BLE_GATTC_BROWSE_INC_SRVC, /**< Included Service information. */
76 BLE_GATTC_BROWSE_ATTR_CHAR, /**< Characteristic Declaration. */
77 BLE_GATTC_BROWSE_ATTR_VAL, /**< Attribute Value definition. */
78 BLE_GATTC_BROWSE_ATTR_DESC, /**< Attribute Descriptor. */
79 } ble_gattc_attr_type_t;
80
81 /** @} */
82
83 /** @addtogroup BLE_GATTC_STRUCTURES Structures
84 * @{ */
85
86 /**
87 * @brief GATTC discovery characteristic structure.
88 */
89 typedef struct
90 {
91 uint16_t start_hdl; /**< Start handle. */
92 uint16_t end_hdl; /**< End handle. */
93 ble_uuid_t *p_uuid; /**< Characteristic UUID. */
94 } ble_gattc_disc_char_t;
95
96 /**
97 * @brief GATTC read by characteristic UUID structure.
98 */
99 typedef struct
100 {
101 uint16_t start_hdl; /**< Start handle. */
102 uint16_t end_hdl; /**< End handle. */
103 ble_uuid_t *p_uuid; /**< Characteristic UUID. */
104 } ble_gattc_read_by_uuid_t;
105
106 /**
107 * @brief GATTC write attribute value structure.
108 */
109 typedef struct
110 {
111 uint16_t handle; /**< Attribute handle. */
112 uint16_t offset; /**< value offset to start with. */
113 uint16_t length; /**< Write length. */
114 uint8_t *p_value; /**< Value to write. */
115 } ble_gattc_write_attr_value_t;
116
117 /**
118 * @brief GATTC write without response structure.
119 */
120 typedef struct
121 {
122 bool signed_write; /**< True if signed write should be used when possible/applicable. */
123 uint16_t handle; /**< Attribute handle. */
124 uint16_t length; /**< Write length. */
125 uint8_t *p_value; /**< Value to write. */
126 } ble_gattc_write_no_resp_t;
127
128 /**@brief Read Multiple Handles. */
129 typedef struct
130 {
131 uint16_t handle; /**< Attribute handle. */
132 uint16_t len; /**< Known value: length of the handle (len shall not be set to 0). */
133 } ble_gattc_multiple_att_t;
134
135 /**@brief GATTC Read Multiple. */
136 typedef struct
137 {
138 uint16_t handle_count; /**< Handle count of the multiple attributes to be read. */
139 ble_gattc_multiple_att_t *p_read_multiple; /**< Pointer to the multiple attributes to be read. */
140 } ble_gattc_read_multiple_t;
141
142 /**@brief GATTC Browse information about Characteristic. */
143 typedef struct
144 {
145 ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref BLE_GATTC_BROWSE_ATTR_CHAR for Characteristic Declaration. */
146 uint8_t prop; /**< Value property. */
147 uint16_t handle; /**< Value handle. */
148 uint8_t uuid_len; /**< Characteristic UUID length. */
149 uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Characteristic UUID. */
150 } ble_gattc_browse_attr_char_t;
151
152 /**@brief GATTC Browse information about Included Service. */
153 typedef struct
154 {
155 ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref BLE_GATTC_BROWSE_INC_SRVC for Included Service Information. */
156 uint8_t uuid_len; /**< Included Service UUID length. */
157 uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Included Service UUID. */
158 uint16_t start_hdl; /**< Included Service start handle. */
159 uint16_t end_hdl; /**< Included Service end handle. */
160 } ble_gattc_browse_inc_srvc_t;
161
162 /**@brief GATTC Browse information about Attribute. */
163 typedef struct
164 {
165 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. */
166 uint8_t uuid_len; /**< Attribute UUID length. */
167 uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Characteristic UUID or Characteristic Descriptor UUID. */
168 } ble_gattc_browse_attr_t;
169
170 /**@brief GATTC Browse attribute information. */
171 union ble_gattc_browse_attr_info
172 {
173 ble_gattc_attr_type_t attr_type; /**< Attribute type. See @ref ble_gattc_attr_type_t. */
174 ble_gattc_browse_attr_char_t attr_char; /**< Information about Characteristic. When union attr_type is @ref BLE_GATTC_BROWSE_ATTR_CHAR */
175 ble_gattc_browse_inc_srvc_t inc_srvc; /**< Information about Included Service. When union attr_type is @ref BLE_GATTC_BROWSE_INC_SRVC */
176 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. */
177 };
178
179 /**@brief GATT service. */
180 typedef struct
181 {
182 uint16_t start_hdl; /**< Start handle. */
183 uint16_t end_hdl; /**< End handle. */
184 uint8_t uuid_len; /**< Service UUID length. */
185 uint8_t *p_uuid; /**< Service UUID. */
186 } ble_gattc_service_t;
187
188 /**@brief GATT include. */
189 typedef struct
190 {
191 uint16_t attr_hdl; /**< Attribute handle. */
192 uint16_t start_hdl; /**< Start handle. */
193 uint16_t end_hdl; /**< End handle. */
194 uint8_t uuid_len; /**< Service UUID length. */
195 uint8_t *p_uuid; /**< Service UUID. */
196 } ble_gattc_include_t;
197
198 /**@brief GATT characteristic. */
199 typedef struct
200 {
201 uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
202 uint16_t handle_value; /**< Handle of the Characteristic Value. */
203 uint8_t prop; /**< Properties. */
204 uint8_t uuid_len; /**< Characteristic UUID length. */
205 uint8_t *p_uuid; /**< Characteristic UUID. */
206 } ble_gattc_char_t;
207
208 /**@brief GATT descriptor. */
209 typedef struct
210 {
211 uint16_t attr_hdl; /**< Attribute handle. */
212 uint8_t uuid_len; /**< Descriptor UUID length. */
213 uint8_t *p_uuid; /**< Descriptor UUID. */
214 } ble_gattc_desc_t;
215
216 /**@brief GATT Client Read value. */
217 typedef struct
218 {
219 uint16_t handle; /**< Attribute handle. */
220 uint16_t offset; /**< Offset of the attribute value. */
221 uint16_t length; /**< Attribute value length. */
222 uint8_t *p_value; /**< Pointer to the attribute value data. */
223 } ble_gattc_read_value_t;
224
225 /**@brief GATTC Browse service(s) event for @ref BLE_GATTC_EVT_SRVC_BROWSE. */
226 typedef struct
227 {
228 uint8_t uuid_len; /**< Service UUID length. */
229 uint8_t uuid[BLE_ATT_UUID_128_LEN]; /**< Service UUID. */
230 uint16_t start_hdl; /**< Service start handle. */
231 uint16_t end_hdl; /**< Service end handle. */
232 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. */
233 } ble_gattc_evt_browse_srvc_t;
234
235 /**@brief GATT service discovery event for @ref BLE_GATTC_EVT_PRIMARY_SRVC_DISC. */
236 typedef struct
237 {
238 uint16_t count; /**< Service count. */
239 ble_gattc_service_t *services; /**< Service data. */
240 }ble_gattc_evt_srvc_disc_t;
241
242 /**@brief GATT include discovery event for @ref BLE_GATTC_EVT_INCLUDE_SRVC_DISC. */
243 typedef struct
244 {
245 uint16_t count; /**< Include count. */
246 ble_gattc_include_t *includes; /**< Include data. */
247 }ble_gattc_evt_incl_disc_t;
248
249 /**@brief GATT characteristic discovery event for @ref BLE_GATTC_EVT_CHAR_DISC. */
250 typedef struct
251 {
252 uint16_t count; /**< Characteristic count. */
253 ble_gattc_char_t *chars; /**< Characteristic data. */
254 }ble_gattc_evt_char_disc_t;
255
256 /**@brief GATT characteristic descriptor discovery event for @ref BLE_GATTC_EVT_CHAR_DESC_DISC. */
257 typedef struct
258 {
259 uint16_t count; /**< Descriptor count. */
260 ble_gattc_desc_t *char_descs; /**< Descriptor data. */
261 }ble_gattc_evt_char_desc_disc_t;
262
263 /**@brief GATT Client Read response event for @ref BLE_GATTC_EVT_READ_RSP. */
264 typedef struct
265 {
266 uint16_t count; /**< Value Count. */
267 ble_gattc_read_value_t *value; /**< Value(s) list. */
268 }ble_gattc_evt_read_t;
269
270
271 /**@brief GATT Client Write Response event for @ref BLE_GATTC_EVT_WRITE_RSP. */
272 typedef struct
273 {
274 uint16_t handle; /**< Attribute handle. */
275 } ble_gattc_evt_write_t;
276
277
278 /**@brief GATTC Notification and Indication event for @ref BLE_GATTC_EVT_NTF_IND. */
279 typedef struct
280 {
281 ble_gatt_evt_type_t type; /**< Event type. */
282 uint16_t length; /**< Attribute value length. */
283 uint16_t handle; /**< Attribute handle. */
284 uint8_t *p_value; /**< Pointer to the attribute value data. */
285 } ble_gattc_evt_ntf_ind_t;
286
287 /**@brief BLE GATTC event structure. */
288 typedef struct
289 {
290 uint8_t index; /**< Index of connection. */
291 union
292 {
293 ble_gattc_evt_browse_srvc_t srvc_browse; /**< Browce service discovery response event. */
294 ble_gattc_evt_srvc_disc_t prim_srvc_disc; /**< Primary service discovery response event. */
295 ble_gattc_evt_incl_disc_t inc_srvc_disc; /**< Include service discovery response event. */
296 ble_gattc_evt_char_disc_t char_disc; /**< Characteristic discovery response event. */
297 ble_gattc_evt_char_desc_disc_t char_desc_disc; /**< Characteristic descriptor discovery response event. */
298 ble_gattc_evt_read_t read_rsp; /**< Read response event. */
299 ble_gattc_evt_write_t write_rsp; /**< Write response event. */
300 ble_gattc_evt_ntf_ind_t ntf_ind; /**< Handle value Notification/Indication response. */
301 } params; /**< Event Parameters. */
302 } ble_gattc_evt_t;
303 /** @} */
304
305 /** @addtogroup BLE_GATTC_FUNCTIONS Functions
306 * @{ */
307
308 /**
309 ****************************************************************************************
310 * @brief Perform MTU Exchange.
311 *
312 * @param[in] conn_idx: Current connection index.
313 *
314 * @retval ::SDK_SUCCESS: Successfully send an MTU Exchange request.
315 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
316 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
317 ****************************************************************************************
318 */
319 uint16_t ble_gattc_mtu_exchange(uint8_t conn_idx);
320
321 /**
322 ****************************************************************************************
323 * @brief Browse all Primary Services or specific Primary Service information on remote GATT server.
324 *
325 * @note This discovery automatically searches for Primary Services, Included Services, Characteristics and Descriptors of each service.
326 * To discover one or more services only, use ble_gattc_primary_services_discover() instead.
327 * This discovery is able to search all Primary Services or a specific one.
328 * If srvc_uuid is NULL, all services are returned.
329 *
330 * @param[in] conn_idx: Current connection index.
331 * @param[in] p_srvc_uuid: Pointer to Service UUID. If it is NULL, all services will be returned.
332 *
333 * @retval ::SDK_SUCCESS: Successfully start the Browse Service(s) procedure.
334 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
335 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
336 ****************************************************************************************
337 */
338 uint16_t ble_gattc_services_browse(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
339
340 /**
341 ****************************************************************************************
342 * @brief Discover Primary Services on remote GATT server.
343 *
344 * @param[in] conn_idx: Current connection index.
345 * @param[in] p_srvc_uuid: Pointer to Service UUID. If it is NULL, all Primary Services will be returned.
346 *
347 * @retval ::SDK_SUCCESS: Successfully start the Primary Service Discovery procedure.
348 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
349 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
350 ****************************************************************************************
351 */
352 uint16_t ble_gattc_primary_services_discover(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
353
354 /**
355 ****************************************************************************************
356 * @brief Discover Included Services on remote GATT server.
357 *
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 *
373 * @param[in] conn_idx: Current connection index.
374 * @param[in] start_hdl: Start handle.
375 * @param[in] end_hdl: End handle.
376 * @param[in] p_char_uuid: Pointer to Characteristic UUID.If it is NULL, all characteristics are returned.
377 *
378 * @retval ::SDK_SUCCESS: Successfully start the Characteristic Discovery procedure.
379 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
380 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
381 ****************************************************************************************
382 */
383 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);
384
385 /**
386 ****************************************************************************************
387 * @brief Discover Characteristics Descriptors on remote GATT server.
388 *
389 * @param[in] conn_idx: Current connection index.
390 * @param[in] start_hdl: Start handle.
391 * @param[in] end_hdl: End handle.
392 *
393 * @retval ::SDK_SUCCESS: Successfully start the Descriptor Discovery procedure.
394 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
395 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
396 ****************************************************************************************
397 */
398 uint16_t ble_gattc_char_desc_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
399
400 /**
401 ****************************************************************************************
402 * @brief Read Attribute from remote GATT server.
403 *
404 * @note This uses either the "Read Characteristic Value" procedure or the "Read Characteristic Descriptor"
405 * procedure, depending on the attribute pointed by handle. If offset is non-zero or the
406 * attribute length is larger than the MTU, the "Read Long Characteristic Value" procedure or the
407 * "Read Long Characteristic Descriptor" procedure will be used respectively.
408 *
409 * @param[in] conn_idx: Current connection index.
410 * @param[in] handle: Attribute handle.
411 * @param[in] offset: Value offset to start with.
412 *
413 * @retval ::SDK_SUCCESS: Successfully start the Read (Long) procedure.
414 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
415 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
416 ****************************************************************************************
417 */
418 uint16_t ble_gattc_read(uint8_t conn_idx, uint16_t handle, uint16_t offset);
419
420 /**
421 ****************************************************************************************
422 * @brief Read Attribute by UUID.
423 *
424 * @param[in] conn_idx: Current connection index.
425 * @param[in] start_hdl: Start handle.
426 * @param[in] end_hdl: End handle.
427 * @param[in] p_char_uuid: Pointer to Characteristic UUID.
428 *
429 *
430 * @retval ::SDK_SUCCESS: Successfully start the Read using Characteristic UUID procedure.
431 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
432 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
433 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
434 ****************************************************************************************
435 */
436 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);
437
438 /**
439 ****************************************************************************************
440 * @brief Initiate a Read Multiple Characteristic Values procedure
441 *
442 * @param[in] conn_idx: Current connection index.
443 * @param[in] p_param: Pointer to the parameters of the value.
444 *
445 * @retval ::SDK_SUCCESS: Successfully start the Read Multiple Characteristic Values procedure.
446 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
447 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
448 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
449 ****************************************************************************************
450 */
451 uint16_t ble_gattc_read_multiple(uint8_t conn_idx, const ble_gattc_read_multiple_t *p_param);
452
453 /**
454 ****************************************************************************************
455 * @brief Write (long) Characteristic (Descriptor) Value.
456 *
457 * @note This uses either the "Write Characteristic Value" procedure or the "Write Characteristic
458 * Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero
459 * or the attribute length is larger than the MTU, the "Write Long Characteristic Value" procedure
460 * or the "Write Long Characteristic Descriptor" procedure will be used respectively.
461 *
462 * @param[in] conn_idx: Current connection index.
463 * @param[in] handle: The handle of the attribute to be written.
464 * @param[in] offset: Offset into the attribute value to be written.
465 * @param[in] length: Length of the value data in bytes.
466 * @param[in] p_value: Pointer to the value data.
467 *
468 * @retval ::SDK_SUCCESS: Successfully start the Write procedure.
469 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
470 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
471 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
472 ****************************************************************************************
473 */
474 uint16_t ble_gattc_write(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
475
476 /**
477 ****************************************************************************************
478 * @brief Prepare Long/Reliable Write to remote GATT server.
479 *
480 * @param[in] conn_idx: Current connection index.
481 * @param[in] handle: Attribute handle.
482 * @param[in] offset: Value offset to start with.
483 * @param[in] length: Value length.
484 * @param[in] p_value: Value data.
485 *
486 * @retval ::SDK_SUCCESS: Successfully send a Prepare Write request.
487 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
488 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
489 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
490 ****************************************************************************************
491 */
492 uint16_t ble_gattc_write_prepare(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
493
494 /**
495 ****************************************************************************************
496 * @brief Execute Reliable/Long Write to remote GATT server.
497 *
498 * @param[in] conn_idx: Current connection index.
499 * @param[in] execute: True if data shall be written; false if cancel all prepared writes.
500 *
501 * @retval ::SDK_SUCCESS: Successfully send an Execute Write request.
502 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
503 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
504 ****************************************************************************************
505 */
506 uint16_t ble_gattc_write_execute(uint8_t conn_idx, bool execute);
507
508 /**
509 ****************************************************************************************
510 * @brief Write Attribute to remote GATT server (without response).
511 *
512 * @note If signed_write is set to false, the "Write Without Response" procedure will be used.
513 * If signed_write is set to true, the "Signed Write Without Response" procedure will be used on
514 * a link which is not encrypted.
515 * If a link is already encrypted, "Write Without Response" procedure shall be used instead of "Signed Write Without Response".
516 *
517 * @param[in] conn_idx: Current connection index.
518 * @param[in] handle: Attribute handle.
519 * @param[in] signed_write: True if signed write should be used, false write without response.
520 * @param[in] length: Value length.
521 * @param[in] p_value: Value data.
522 *
523 * @retval ::SDK_SUCCESS: Successfully start the (Signed) Write Without Response procedure.
524 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
525 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
526 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
527 ****************************************************************************************
528 */
529 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);
530
531 /**
532 ****************************************************************************************
533 * @brief Confirm Reception of Indication.
534 *
535 * @note Confirm indication which has been correctly received from the peer.
536 *
537 * @param[in] conn_idx: Current connection index.
538 * @param[in] handle: Value handle.
539 *
540 * @retval ::SDK_SUCCESS: Successfully send indication confirm.
541 * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
542 * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
543 ****************************************************************************************
544 */
545 uint16_t ble_gattc_indicate_cfm(uint8_t conn_idx, uint16_t handle);
546
547 /** @} */
548
549 #endif
550
551 /** @} */
552
553 /** @} */
554 /** @} */
555
ble_gattc_browse_attr_char_t::handle
uint16_t handle
Value handle.
Definition: ble_gattc.h:147
ble_gattc_browse_attr_t::uuid_len
uint8_t uuid_len
Attribute UUID length.
Definition: ble_gattc.h:166
ble_gattc_evt_ntf_ind_t
GATTC Notification and Indication event for BLE_GATTC_EVT_NTF_IND.
Definition: ble_gattc.h:280
BLE_GATTC_BROWSE_NONE
@ BLE_GATTC_BROWSE_NONE
No Attribute Information.
Definition: ble_gattc.h:74
ble_gattc_evt_read_t
GATT Client Read response event for BLE_GATTC_EVT_READ_RSP.
Definition: ble_gattc.h:265
BLE_GATTC_BROWSE_ATTR_VAL
@ BLE_GATTC_BROWSE_ATTR_VAL
Attribute Value definition.
Definition: ble_gattc.h:77
ble_gattc_evt_char_desc_disc_t::count
uint16_t count
Descriptor count.
Definition: ble_gattc.h:259
ble_gattc_evt_browse_srvc_t
GATTC Browse service(s) event for BLE_GATTC_EVT_SRVC_BROWSE.
Definition: ble_gattc.h:227
BLE_ATT_UUID_128_LEN
#define BLE_ATT_UUID_128_LEN
UUID length: 16 bytes.
Definition: ble_att.h:65
ble_gattc_evt_t::ntf_ind
ble_gattc_evt_ntf_ind_t ntf_ind
Handle value Notification/Indication response.
Definition: ble_gattc.h:300
ble_gattc_char_t::handle_value
uint16_t handle_value
Handle of the Characteristic Value.
Definition: ble_gattc.h:202
ble_gattc_service_t::p_uuid
uint8_t * p_uuid
Service UUID.
Definition: ble_gattc.h:185
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
Included Service end handle.
Definition: ble_gattc.h:159
ble_gattc_read_by_uuid_t::start_hdl
uint16_t start_hdl
Start handle.
Definition: ble_gattc.h:101
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
Service start handle.
Definition: ble_gattc.h:230
ble_gattc_read_multiple_t::handle_count
uint16_t handle_count
Handle count of the multiple attributes to be read.
Definition: ble_gattc.h:138
ble_gattc_evt_read_t::value
ble_gattc_read_value_t * value
Value(s) list.
Definition: ble_gattc.h:267
ble_gattc_write_attr_value_t::length
uint16_t length
Write length.
Definition: ble_gattc.h:113
ble_gattc_write_attr_value_t::p_value
uint8_t * p_value
Value to write.
Definition: ble_gattc.h:114
ble_gattc_include_t::end_hdl
uint16_t end_hdl
End handle.
Definition: ble_gattc.h:193
ble_gattc_evt_t::inc_srvc_disc
ble_gattc_evt_incl_disc_t inc_srvc_disc
Include service discovery response event.
Definition: ble_gattc.h:295
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
Known value: length of the handle (len shall not be set to 0).
Definition: ble_gattc.h:132
ble_gattc_evt_read_t::count
uint16_t count
Value Count.
Definition: ble_gattc.h:266
ble_gattc_evt_write_t
GATT Client Write Response event for BLE_GATTC_EVT_WRITE_RSP.
Definition: ble_gattc.h:273
BLE_GATTC_BROWSE_ATTR_CHAR
@ BLE_GATTC_BROWSE_ATTR_CHAR
Characteristic Declaration.
Definition: ble_gattc.h:76
ble_gattc_write_attr_value_t::offset
uint16_t offset
value offset to start with.
Definition: ble_gattc.h:112
ble_gattc_char_t::handle_decl
uint16_t handle_decl
Handle of the Characteristic Declaration.
Definition: ble_gattc.h:201
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
Attribute handle.
Definition: ble_gattc.h:131
ble_gattc_desc_t::uuid_len
uint8_t uuid_len
Descriptor UUID length.
Definition: ble_gattc.h:212
ble_gattc_service_t::uuid_len
uint8_t uuid_len
Service UUID length.
Definition: ble_gattc.h:184
ble_gattc_evt_t::write_rsp
ble_gattc_evt_write_t write_rsp
Write response event.
Definition: ble_gattc.h:299
ble_gattc_char_t::uuid_len
uint8_t uuid_len
Characteristic UUID length.
Definition: ble_gattc.h:204
ble_gattc_evt_srvc_disc_t
GATT service discovery event for BLE_GATTC_EVT_PRIMARY_SRVC_DISC.
Definition: ble_gattc.h:237
ble_gattc_evt_browse_srvc_t::uuid_len
uint8_t uuid_len
Service UUID length.
Definition: ble_gattc.h:228
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
Descriptor data.
Definition: ble_gattc.h:260
ble_gatt.h
BLE GATT.
ble_gattc_browse_attr_info::attr
ble_gattc_browse_attr_t attr
Information about Attribute.
Definition: ble_gattc.h:176
ble_gattc_attr_type_t
ble_gattc_attr_type_t
GATT Client Service Discover Attribute type IDs.
Definition: ble_gattc.h:73
ble_gattc_read_multiple_t::p_read_multiple
ble_gattc_multiple_att_t * p_read_multiple
Pointer to the multiple attributes to be read.
Definition: ble_gattc.h:139
ble_gattc_browse_attr_char_t
GATTC Browse information about Characteristic.
Definition: ble_gattc.h:144
gr55xx_sys_cfg.h
Define the chip configuration.
ble_gattc_evt_t::char_disc
ble_gattc_evt_char_disc_t char_disc
Characteristic discovery response event.
Definition: ble_gattc.h:296
ble_gattc_browse_attr_info::inc_srvc
ble_gattc_browse_inc_srvc_t inc_srvc
Information about Included Service.
Definition: ble_gattc.h:175
ble_gattc_char_t
GATT characteristic.
Definition: ble_gattc.h:200
ble_gattc_browse_inc_srvc_t::uuid_len
uint8_t uuid_len
Included Service UUID length.
Definition: ble_gattc.h:156
ble_gattc_evt_ntf_ind_t::handle
uint16_t handle
Attribute handle.
Definition: ble_gattc.h:283
ble_gattc_read_value_t
GATT Client Read value.
Definition: ble_gattc.h:218
ble_gattc_write_no_resp_t
GATTC write without response structure.
Definition: ble_gattc.h:121
ble_gattc_evt_write_t::handle
uint16_t handle
Attribute handle.
Definition: ble_gattc.h:274
ble_gattc_multiple_att_t
Read Multiple Handles.
Definition: ble_gattc.h:130
ble_gattc_write_attr_value_t::handle
uint16_t handle
Attribute handle.
Definition: ble_gattc.h:111
ble_gattc_char_t::prop
uint8_t prop
Properties.
Definition: ble_gattc.h:203
ble_gattc_evt_incl_disc_t::includes
ble_gattc_include_t * includes
Include data.
Definition: ble_gattc.h:246
ble_gattc_evt_browse_srvc_t::end_hdl
uint16_t end_hdl
Service end handle.
Definition: ble_gattc.h:231
ble_error.h
File that contains error codes.
ble_gattc_browse_inc_srvc_t::attr_type
ble_gattc_attr_type_t attr_type
Attribute type.
Definition: ble_gattc.h:155
ble_gattc_service_t::end_hdl
uint16_t end_hdl
End handle.
Definition: ble_gattc.h:183
BLE_GATTC_BROWSE_INC_SRVC
@ BLE_GATTC_BROWSE_INC_SRVC
Included Service information.
Definition: ble_gattc.h:75
ble_gattc_write_no_resp_t::p_value
uint8_t * p_value
Value to write.
Definition: ble_gattc.h:125
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
Service UUID length.
Definition: ble_gattc.h:194
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
Attribute type.
Definition: ble_gattc.h:173
ble_gattc_write_no_resp_t::length
uint16_t length
Write length.
Definition: ble_gattc.h:124
ble_gattc_browse_attr_char_t::attr_type
ble_gattc_attr_type_t attr_type
Attribute type.
Definition: ble_gattc.h:145
ble_gattc_evt_char_disc_t
GATT characteristic discovery event for BLE_GATTC_EVT_CHAR_DISC.
Definition: ble_gattc.h:251
ble_gattc_disc_char_t::p_uuid
ble_uuid_t * p_uuid
Characteristic UUID.
Definition: ble_gattc.h:93
ble_gattc_evt_char_disc_t::count
uint16_t count
Characteristic count.
Definition: ble_gattc.h:252
ble_gattc_read_value_t::offset
uint16_t offset
Offset of the attribute value.
Definition: ble_gattc.h:220
ble_gattc_evt_incl_disc_t::count
uint16_t count
Include count.
Definition: ble_gattc.h:245
ble_gattc_desc_t
GATT descriptor.
Definition: ble_gattc.h:210
ble_gattc_evt_ntf_ind_t::type
ble_gatt_evt_type_t type
Event type.
Definition: ble_gattc.h:281
ble_gatt_evt_type_t
ble_gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
ble_gattc_service_t
GATT service.
Definition: ble_gattc.h:181
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
Characteristic UUID.
Definition: ble_gattc.h:103
ble_gattc_browse_inc_srvc_t::start_hdl
uint16_t start_hdl
Included Service start handle.
Definition: ble_gattc.h:158
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
Pointer to the attribute value data.
Definition: ble_gattc.h:222
ble_gattc_write_attr_value_t
GATTC write attribute value structure.
Definition: ble_gattc.h:110
ble_gattc_desc_t::p_uuid
uint8_t * p_uuid
Descriptor UUID.
Definition: ble_gattc.h:213
ble_gattc_include_t
GATT include.
Definition: ble_gattc.h:190
BLE_GATTC_BROWSE_ATTR_DESC
@ BLE_GATTC_BROWSE_ATTR_DESC
Attribute Descriptor.
Definition: ble_gattc.h:78
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
Service count.
Definition: ble_gattc.h:238
ble_gattc_write_no_resp_t::signed_write
bool signed_write
True if signed write should be used when possible/applicable.
Definition: ble_gattc.h:122
ble_gattc_evt_t::prim_srvc_disc
ble_gattc_evt_srvc_disc_t prim_srvc_disc
Primary service discovery response event.
Definition: ble_gattc.h:294
ble_gattc_browse_attr_char_t::prop
uint8_t prop
Value property.
Definition: ble_gattc.h:146
ble_gattc_char_t::p_uuid
uint8_t * p_uuid
Characteristic UUID.
Definition: ble_gattc.h:205
ble_gattc_read_by_uuid_t
GATTC read by characteristic UUID structure.
Definition: ble_gattc.h:100
ble_gattc_read_by_uuid_t::end_hdl
uint16_t end_hdl
End handle.
Definition: ble_gattc.h:102
ble_gattc_evt_browse_srvc_t::info
union ble_gattc_browse_attr_info * info
Attribute information presented in the service(array length = end_hdl - start_hdl);If attr_type is eq...
Definition: ble_gattc.h:232
ble_gattc_evt_t::index
uint8_t index
Index of connection.
Definition: ble_gattc.h:290
ble_gattc_disc_char_t::start_hdl
uint16_t start_hdl
Start handle.
Definition: ble_gattc.h:91
ble_gattc_evt_char_desc_disc_t
GATT characteristic descriptor discovery event for BLE_GATTC_EVT_CHAR_DESC_DISC.
Definition: ble_gattc.h:258
ble_att.h
Attribute Protocol.
ble_gattc_evt_t::char_desc_disc
ble_gattc_evt_char_desc_disc_t char_desc_disc
Characteristic descriptor discovery response event.
Definition: ble_gattc.h:297
ble_gattc_evt_char_disc_t::chars
ble_gattc_char_t * chars
Characteristic data.
Definition: ble_gattc.h:253
ble_gattc_browse_inc_srvc_t
GATTC Browse information about Included Service.
Definition: ble_gattc.h:154
ble_gattc_browse_attr_info
GATTC Browse attribute information.
Definition: ble_gattc.h:172
ble_gattc_include_t::p_uuid
uint8_t * p_uuid
Service UUID.
Definition: ble_gattc.h:195
ble_gattc_evt_t::srvc_browse
ble_gattc_evt_browse_srvc_t srvc_browse
Browce service discovery response event.
Definition: ble_gattc.h:293
ble_gattc_evt_srvc_disc_t::services
ble_gattc_service_t * services
Service data.
Definition: ble_gattc.h:239
ble_gattc_evt_t::read_rsp
ble_gattc_evt_read_t read_rsp
Read response event.
Definition: ble_gattc.h:298
ble_uuid_t
GATT UUID structure.
Definition: ble_gatt.h:81
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_browse_attr_char_t::uuid_len
uint8_t uuid_len
Characteristic UUID length.
Definition: ble_gattc.h:148
ble_gattc_browse_attr_info::attr_char
ble_gattc_browse_attr_char_t attr_char
Information about Characteristic.
Definition: ble_gattc.h:174
ble_gattc_evt_incl_disc_t
GATT include discovery event for BLE_GATTC_EVT_INCLUDE_SRVC_DISC.
Definition: ble_gattc.h:244
ble_gattc_read_multiple_t
GATTC Read Multiple.
Definition: ble_gattc.h:137
ble_gattc_include_t::start_hdl
uint16_t start_hdl
Start handle.
Definition: ble_gattc.h:192
ble_gattc_desc_t::attr_hdl
uint16_t attr_hdl
Attribute handle.
Definition: ble_gattc.h:211
ble_gattc_include_t::attr_hdl
uint16_t attr_hdl
Attribute handle.
Definition: ble_gattc.h:191
ble_gattc_evt_ntf_ind_t::p_value
uint8_t * p_value
Pointer to the attribute value data.
Definition: ble_gattc.h:284
ble_gattc_read_value_t::length
uint16_t length
Attribute value length.
Definition: ble_gattc.h:221
ble_gattc_read_value_t::handle
uint16_t handle
Attribute handle.
Definition: ble_gattc.h:219
ble_gattc_write_no_resp_t::handle
uint16_t handle
Attribute handle.
Definition: ble_gattc.h:123
ble_gattc_browse_attr_t
GATTC Browse information about Attribute.
Definition: ble_gattc.h:164
ble_gattc_browse_attr_t::attr_type
ble_gattc_attr_type_t attr_type
Attribute type.
Definition: ble_gattc.h:165
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
Attribute value length.
Definition: ble_gattc.h:282
ble_gattc_disc_char_t::end_hdl
uint16_t end_hdl
End handle.
Definition: ble_gattc.h:92
ble_gattc_service_t::start_hdl
uint16_t start_hdl
Start handle.
Definition: ble_gattc.h:182
ble_gattc_evt_t
BLE GATTC event structure.
Definition: ble_gattc.h:289
ble_gattc_disc_char_t
GATTC discovery characteristic structure.
Definition: ble_gattc.h:90