ble_prf.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file ble_prf.h
5  *
6  * @brief BLE PRF 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_PRF Profile
45  @{
46  @brief Definitions and prototypes for the profile interface.
47  */
48 
49 #ifndef __BLE_PRF_H__
50 #define __BLE_PRF_H__
51 
52 #include "ble_error.h"
53 #include "ble_att.h"
54 #include "ble_gatts.h"
55 #include "ble_gattc.h"
56 #include "ble_gatt.h"
57 
58 
59 /**
60  @addtogroup BLE_PRF_COMMON Profile Common
61  @{
62  @brief Definitions and prototypes for Profile Common interface.
63  */
64 
65 /** @addtogroup BLE_PRF_MANAGER_TYPEDEFS Typedefs
66  * @{ */
67 /**
68 ****************************************************************************************
69 * @brief Initialization of the Profile module.
70 * @note This function performs all the initializations of the Profile module, and it will be automatically called after the ble_server_prf_add() or ble_client_prf_add() function.
71 * - Creation of database (if it's a service) and ble_gatts_srvc_db_create should be called.
72 * - Allocation of profile-required memory.
73 *
74 * @retval status code to know if profile initialization succeeds or not.
75  ****************************************************************************************
76  */
77 typedef uint8_t (*prf_init_func_t)(void);
78 
79 /**
80 ****************************************************************************************
81 * @brief Handles Connection creation. There is no need to recovery CCCD because stack will do that.
82 *
83 * @param[in] conn_idx: Connection index.
84  ****************************************************************************************
85  */
86 typedef void (*prf_on_connect_func_t)(uint8_t conn_idx);
87 
88 /**
89 ****************************************************************************************
90 * @brief Handles Disconnection. There is no need to recovery CCCD because stack will do that.
91 *
92 * @param[in] conn_idx: Connection index.
93 * @param[in] reason: Disconnection reason.
94  ****************************************************************************************
95  */
96 typedef void (*prf_on_disconnect_func_t)(uint8_t conn_idx, uint8_t reason);
97 
98  /** @addtogroup BLE_PRF_MANAGER_STRUCTURES Structures
99  * @{ */
100  /**
101  * @brief Profile manager callbacks.
102  */
103 /** @} */
104 typedef struct
105 {
106  prf_init_func_t init; /**< Initialization callback. See @ref prf_init_func_t. */
107  prf_on_connect_func_t on_connect; /**< Connection callback. See @ref prf_on_connect_func_t. */
108  prf_on_disconnect_func_t on_disconnect; /**< Disconnection callback. See @ref prf_on_disconnect_func_t. */
110 
111 /** @} */
112 
113 /** @} */
114 
115 
116 /**
117  @addtogroup BLE_PRF_SERVER Profile Server
118  @{
119  @brief Definitions and prototypes for Profile Server interface.
120  */
121 
122 /** @addtogroup BLE_PRF_SERVER_STRUCTURES Structures
123  * @{ */
124 /**
125  * @brief GATT read request struct.
126  */
127 typedef struct
128 {
129  uint16_t handle; /**< Handle of the attribute to be read. */
131 
132 /**
133  * @brief GATT write request struct.
134  */
135 typedef struct
136 {
137  uint16_t handle; /**< Handle of the attribute to be written. */
138  uint16_t offset; /**< Offset at which the data has to be written. */
139  uint16_t length; /**< Data length to be written. */
140  uint8_t value[__ARRAY_EMPTY]; /**< Data to be written to characteristic value. */
142 
143 /**
144  * @brief GATT prepare write request struct.
145  */
146 typedef struct
147 {
148  uint16_t handle; /**< Handle of the attribute for whose value is requested. */
150 
151 /**
152  * @brief GATTS Operation Complete event structure.
153  */
154 typedef struct
155 {
156  gatt_evt_type_t type; /**< Notification or indication event type. */
157  uint16_t handle; /**< Handle of the write operation, or notification/indication operation. */
159 
160 /**
161  * @brief GATT server callback function in relation to a profile.
162  */
163 typedef struct
164 {
165  void (*app_gatts_read_cb)(uint8_t conidx, const gatts_read_req_cb_t *p_read_req); /**< Read attribute value callback which is used when value is present in user space.
166  Function @ref ble_gatts_read_cfm should be called to send attribute value to stack.*/
167  void (*app_gatts_write_cb)(uint8_t conidx, const gatts_write_req_cb_t *p_write_req); /**< Write attribute value callback.
168  Function @ref ble_gatts_write_cfm should be called to send write attribute value status to stack no matter the value is in user's zone or BLE stack.*/
169  void (*app_gatts_prep_write_cb)(uint8_t conidx, const gatts_prep_write_req_cb_t *p_prep_req); /**< Prepare write value callback function.
170  Function @ref ble_gatts_prepare_write_cfm should be called to send prepare write attribute value status to stack no matter the value is in user's zone or BLE stack.*/
171  void (*app_gatts_ntf_ind_cb)(uint8_t conidx, uint8_t status, const ble_gatts_ntf_ind_t *p_ntf_ind); /**< Notification or indication callback function. */
172 
173  void (*app_gatts_cccd_set_cb)(uint8_t conidx, uint16_t handle, uint16_t cccd_val); /**< Set CCCD value callback is called when connected with peer device. If bonded, recovery CCCD; otherwise, set default value(0x0000) for CCCD. */
174 
176 
177 /**
178  * @brief Profile server register information structure.
179  */
180 typedef struct
181 {
182  uint16_t max_connection_nb; /**< Maximum connections the profile supports. */
183  ble_prf_manager_cbs_t* manager_cbs; /**< Profile manager callbacks. */
184  gatts_prf_cbs_t *gatts_prf_cbs; /**< GATT server callback function in relation to the specific profile. */
186 
187 /** @} */
188 
189 /** @addtogroup BLE_PRF_FUNCTIONS Functions
190 * @{ */
191 
192 /**
193  ****************************************************************************************
194  * @brief Add a server profile by providing its detailed information, including manager callback functions and GATT server callback functions.
195  * This API should be called in application initialization function.
196  *
197  * @param[in] p_server_prf_info: Pointer to the prf_info. See @ref prf_server_info_t.
198  *
199  * @note If there are several profiles which need to be added, this function should be called corresponding times.
200  *
201  * @retval ::SDK_SUCCESS: The profile info is recorded successfully, and the database will be created in profile initialization callback function.
202  * @retval ::SDK_ERR_POINTER_NULL: The parameter prf_info is NULL, or input parameters that prf_info points to are invalid.
203  * @retval ::SDK_ERR_NO_RESOURCES: The profile number is up to the maximum number the system can support.
204  ****************************************************************************************
205  */
206 uint16_t ble_server_prf_add(const prf_server_info_t *p_server_prf_info);
207 /** @} */
208 
209 /** @} */
210 
211 
212 
213 /**
214  @addtogroup BLE_PRF_CLIENT Profile Client
215  @{
216  @brief Definitions and prototypes for Profile Client interface.
217  */
218 
219 /** @addtogroup BLE_PRF_CLIENT_STRUCTURES Structures
220  * @{ */
221 
222 /**
223  * @brief GATTC profile register to peer event info structure.
224  */
225 typedef struct
226 {
227  uint16_t start_hdl; /**< Attribute start handle. */
228  uint16_t end_hdl; /**< Attribute end handle. */
230 
231 /**
232  * @brief GATTC profile register enumeration.
233  */
234 typedef enum
235 {
236  GATTC_EVT_REGISTER, /**< GATT client event register. */
237  GATTC_EVT_UNREGISTER, /**< GATT client event unregister. */
239 
240 
241 /**@brief GATTC Profile callback Structures. */
242 typedef struct
243 {
244  void (*app_gattc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_srvc_disc_t * p_prim_srvc_disc); /**< Primary Service Discovery Response callback. */
245  void (*app_gattc_inc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_incl_disc_t * p_inc_srvc_disc); /**< Relationship Discovery Response callback. */
246  void (*app_gattc_char_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_char_disc_t * p_char_disc); /**< Characteristic Discovery Response callback. */
247  void (*app_gattc_char_desc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_char_desc_disc_t *p_char_desc_disc); /**< Descriptor Discovery Response callback. */
248  void (*app_gattc_read_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_read_rsp_t *p_read_rsp); /**< Read Response callback. */
249  void (*app_gattc_write_cb)(uint8_t conn_idx, uint8_t status, uint16_t handle); /**< Write complete callback. */
250  void (*app_gattc_ntf_ind_cb)(uint8_t conn_idx, const ble_gattc_ntf_ind_t *p_ntf_ind); /**< Handle Value Notification/Indication Event callback. */
251  void (*app_gattc_srvc_browse_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_browse_srvc_t *p_browse_srvc); /**< Service found callback during browsing procedure. */
252  void (*app_gattc_prf_reg_cb)(uint8_t conn_idx, uint8_t status, gattc_prf_reg_evt_t reg_evt); /**< GATT client event register complete callback. */
254 
255 /**
256  * @brief Profile client register information structure.
257  */
258 typedef struct
259 {
260  uint16_t max_connection_nb; /**< Maximum connections the profile supports. */
261  ble_prf_manager_cbs_t *manager_cbs; /**< Profile manager callbacks. */
262  gattc_prf_cbs_t *gattc_prf_cbs; /**< GATT client callback function in relation to the specific profile. */
264 
265 /** @} */
266 
267 
268 /**
269  @addtogroup BLE_PRF_CLIENT_FUNCTIONS Functions
270  @{
271  @brief Definitions and prototypes for Profile Client interface.
272  */
273 /**
274  ****************************************************************************************
275  * @brief Add a client profile by providing its detail information, including manager callback functions and GATT client callback functions.
276  * This API should be called in application initialization function.
277  *
278  * @param[in] p_client_prf_info: Pointer to the p_client_prf_info. See @ref prf_client_info_t.
279  * @param[out] p_client_prf_id: Pointer to the client profile id.
280  *
281  * @note If there are several profiles which need to be added, this function should be called corresponding times.
282  *
283  * @retval ::SDK_SUCCESS: The profile info is recorded successfully, and the profile ENV will be initialized in profile initialization callback function.
284  * @retval ::SDK_ERR_POINTER_NULL: The parameter p_client_prf_info or p_client_prf_id is NULL, or input parameters that prf_info points to are invalid.
285  * @retval ::SDK_ERR_NO_RESOURCES: The profile number is up to the maximum number the system can support.
286  ****************************************************************************************
287  */
288 uint16_t ble_client_prf_add(const prf_client_info_t *p_client_prf_info, uint8_t *p_client_prf_id);
289 
290 
291 /**
292  ****************************************************************************************
293  * @brief Profile client Browse Specific Primary Service information on remote GATT server.
294  *
295  * @note This discovery automatically searches for Primary Services, Included Services, Characteristics and Descriptors of each service.
296  * To discover one or more services only, use ble_gattc_primary_services_discover() instead.
297  * This discovery is able to search a specific Primary Service.
298  * If p_srvc_uuid is NULL, the invalid pointer error code will be returned immediately.
299  *
300  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_srvc_browse_cb will be called for all attributes of each service found.
301  * After completed service handle range registeration for receiving peer device indication/notification will be executed internally.
302  * Because secondary service can't be browsed, so handle range registeration for receiving peer device indication/notification to this client
303  * profile may be necessary. App can call function ble_gattc_prf_evt_handle_register for registeration, it depends on user app.
304  * If user don't call this function, user shall call ble_gattc_prf_evt_handle_register to register handle range for receiving
305  * peer device indication/notification in specific client profile callback.
306  *
307  *
308  * @param[in] prf_id: Profile id.
309  * @param[in] conn_idx: Current connection index.
310  * @param[in] p_srvc_uuid: Pointer to Service UUID.
311  *
312  * @retval ::SDK_SUCCESS: Successfully start the Browse Service(s) procedure.
313  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
314  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
315  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
316  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
317  ****************************************************************************************
318  */
319 uint16_t ble_gattc_prf_services_browse(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
320 
321 /**
322  ****************************************************************************************
323  * @brief Profile client Discover Primary Services on remote GATT server.
324  *
325  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_srvc_disc_cb will be called for service(s) found.
326  * If p_srvc_uuid is NULL, the invalid pointer error code will be returned immediately.
327  *
328  * @param[in] prf_id: Profile id.
329  * @param[in] conn_idx: Current connection index.
330  * @param[in] p_srvc_uuid: Pointer to Service UUID.
331  *
332  * @retval ::SDK_SUCCESS: Successfully start the Primary Service Discovery procedure.
333  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
334  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
335  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
336  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
337  ****************************************************************************************
338  */
339 uint16_t ble_gattc_prf_primary_services_discover(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
340 
341 /**
342  ****************************************************************************************
343  * @brief Profile client Discover Included Services on remote GATT server.
344  *
345  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_inc_srvc_disc_cb will be called for Included Service(s) found.
346  *
347  * @param[in] prf_id: Profile id.
348  * @param[in] conn_idx: Current connection index.
349  * @param[in] start_hdl: Start handle.
350  * @param[in] end_hdl: End handle.
351  *
352  * @retval ::SDK_SUCCESS: Successfully start the Relationship Discovery procedure.
353  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
354  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
355  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
356  ****************************************************************************************
357  */
358 uint16_t ble_gattc_prf_included_services_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
359 
360 /**
361  ****************************************************************************************
362  * @brief Profile client Discover Characteristics on remote GATT server.
363  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_char_disc_cb will be called for Characteristic Declaration(s) found.
364  * If p_disc_char is NULL, the invalid pointer error code will be returned immediately.
365  *
366  * @param[in] prf_id: Profile id.
367  * @param[in] conn_idx: Current connection index.
368  * @param[in] p_disc_char: Pointer to discover by characteristic UUID info.
369  *
370  * @retval ::SDK_SUCCESS: Successfully start the Characteristic Discovery procedure.
371  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
372  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
373  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
374  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
375  ****************************************************************************************
376  */
377 uint16_t ble_gattc_prf_char_discover(uint8_t prf_id, uint8_t conn_idx, gattc_disc_char_t *p_disc_char);
378 
379 /**
380  ****************************************************************************************
381  * @brief Profile client Discover Characteristics Descriptors on remote GATT server.
382  *
383  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_char_desc_disc_cb will be called for Characteristic Descriptor(s) found.
384  * If the last Descriptor has not been reached, this function must be called again with an updated handle range to continue the discovery.
385  *
386  * @param[in] prf_id: Profile id.
387  * @param[in] conn_idx: Current connection index.
388  * @param[in] start_hdl: Start handle.
389  * @param[in] end_hdl: End handle.
390  *
391  * @retval ::SDK_SUCCESS: Successfully start the Descriptor Discovery procedure.
392  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
393  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
394  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
395  ****************************************************************************************
396  */
397 uint16_t ble_gattc_prf_char_desc_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
398 
399 /**
400  ****************************************************************************************
401  * @brief Profile client Read Attribute from remote GATT server.
402  *
403  * @note This uses either the "Read Characteristic Value" procedure or the "Read Characteristic Descriptor"
404  * procedure, depending on the attribute pointed by handle. If offset is non-zero or the
405  * attribute length is larger than the MTU, the "Read Long Characteristic Value" procedure or the
406  * "Read Long Characteristic Descriptor" procedure will be used respectively.
407  *
408  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_read_cb will be called when Read is finished.
409  *
410  * @param[in] prf_id: Profile id.
411  * @param[in] conn_idx: Current connection index.
412  * @param[in] handle: Attribute handle.
413  * @param[in] offset: Value offset to start with.
414  *
415  * @retval ::SDK_SUCCESS: Successfully start the Read (Long) procedure.
416  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
417  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
418  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
419  ****************************************************************************************
420  */
421 uint16_t ble_gattc_prf_read(uint8_t prf_id, uint8_t conn_idx, uint16_t handle, uint16_t offset);
422 
423 /**
424  ****************************************************************************************
425  * @brief Profile client Read Attribute by UUID.
426  *
427  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_read_cb will be called when Read is finished.
428  *
429  * @param[in] prf_id: Profile id.
430  * @param[in] conn_idx: Current connection index.
431  * @param[in] p_read_by_uuid: Pointer to Read by Characteristic UUID info.
432  *
433  * @retval ::SDK_SUCCESS: Successfully start the Read Using Characteristic UUID procedure.
434  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
435  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
436  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
437  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
438  ****************************************************************************************
439  */
440 uint16_t ble_gattc_prf_read_by_uuid(uint8_t prf_id, uint8_t conn_idx, gattc_read_by_uuid_t *p_read_by_uuid);
441 
442 /**
443  ****************************************************************************************
444  * @brief Profile client Initiate a Read Multiple Characteristic Values procedure
445  *
446  * @note Function callback @ref gattc_prf_cbs_t::app_gattc_read_cb will be called for each handle value which is read.
447  * @param[in] prf_id: Profile id.
448  * @param[in] conn_idx: Current connection index.
449  * @param[in] p_param: Pointer to the parameters of the value.
450  *
451  * @retval ::SDK_SUCCESS: Successfully start the Read Multiple Characteristic Values procedure.
452  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
453  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
454  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
455  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
456  ****************************************************************************************
457  */
458 uint16_t ble_gattc_prf_read_multiple(uint8_t prf_id, uint8_t conn_idx, const gattc_read_multiple_t *p_param);
459 
460 /**
461  ****************************************************************************************
462  * @brief Profile client Write (Long) Characteristic (Descriptor) Value.
463  *
464  * @note This uses either the "Write Characteristic Value" procedure or the "Write Characteristic
465  * Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero
466  * or the attribute length is larger than the MTU, the "Write Long Characteristic Value" procedure
467  * or the "Write Long Characteristic Descriptor" procedure will be used respectively.
468  *
469  * @note Once completed @ref gattc_prf_cbs_t::app_gattc_write_cb will be called.
470  *
471  * @param[in] prf_id: Profile id.
472  * @param[in] conn_idx: Current connection index.
473  * @param[in] p_write_attr_value: Pointer to the write attribue value info.
474  *
475  * @retval ::SDK_SUCCESS: Successfully start the Write procedure.
476  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
477  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
478  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
479  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
480  ****************************************************************************************
481  */
482 uint16_t ble_gattc_prf_write(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value);
483 
484 /**
485  ****************************************************************************************
486  * @brief Profile client Prepare Long/Reliable Write to remote GATT server.
487  * @note Once completed @ref gattc_prf_cbs_t::app_gattc_write_cb will be called.
488  *
489  * @param[in] prf_id: Profile id.
490  * @param[in] conn_idx: Current connection index.
491  * @param[in] p_write_attr_value: Pointer to the write attribue value info.
492  *
493  * @retval ::SDK_SUCCESS: Successfully send prepare write request.
494  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
495  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
496  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
497  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
498  ****************************************************************************************
499  */
500  uint16_t ble_gattc_prf_write_prepare(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value);
501 
502 /**
503  ****************************************************************************************
504  * @brief Profile client Execute Reliable/Long Write to remote GATT server.
505  *
506  * @note Once completed @ref gattc_prf_cbs_t::app_gattc_write_cb will be called.
507  *
508  * @param[in] prf_id: Profile id.
509  * @param[in] conn_idx: Current connection index.
510  * @param[in] execute: True if data shall be written; False if cancel all prepared writes.
511  *
512  * @retval ::SDK_SUCCESS: Successfully send an Execute Write request.
513  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
514  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
515  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
516  ****************************************************************************************
517  */
518 uint16_t ble_gattc_prf_write_execute(uint8_t prf_id, uint8_t conn_idx, bool execute);
519 
520 /**
521  ****************************************************************************************
522  * @brief Profile client Write Attribute to remote GATT server (without response).
523  *
524  * @note If signed_write is set to false, the "Write Without Response" procedure will be used.
525  * If signed_write is set to true, the "Signed Write Without Response" procedure will be used on
526  * a link which is not encrypted.
527  * If a link is already encrypted, "Write Without Response" procedure shall be used instead of "Signed Write Without Response".
528  * @note Once completed @ref gattc_prf_cbs_t::app_gattc_write_cb will be called.
529  *
530  * @param[in] prf_id: Profile id.
531  * @param[in] conn_idx: Current connection index.
532  * @param[in] p_write_no_resp: Pointer to the write without response info.
533  *
534  * @retval ::SDK_SUCCESS Successfully: start the (Signed) Write Without Response procedure.
535  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
536  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
537  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
538  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
539  ****************************************************************************************
540  */
541 uint16_t ble_gattc_prf_write_no_resp(uint8_t prf_id, uint8_t conn_idx, gattc_write_no_resp_t *p_write_no_resp);
542 
543 /**
544  ****************************************************************************************
545  * @brief Profile client Confirm Reception of Indication.
546  *
547  * @note Confirm indication which has been correctly received from the peer.
548  *
549  * @param[in] prf_id Profile id.
550  * @param[in] conn_idx: Current connection index.
551  * @param[in] handle: Value handle.
552  *
553  * @retval ::SDK_SUCCESS: Successfully send a Confirm Reception of Indication request.
554  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
555  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
556  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
557  ****************************************************************************************
558  */
559 uint16_t ble_gattc_prf_indicate_cfm(uint8_t prf_id, uint8_t conn_idx, uint16_t handle);
560 
561 
562 /**
563  ****************************************************************************************
564  * @brief Profile client Register Indication/Notification event.
565  *
566  * @note Registration to peer device events (Indication/Notification) for specific client profile.
567  * Once completed @ref gattc_prf_cbs_t::app_gattc_prf_reg_cb with type: @ref GATTC_EVT_UNREGISTER will be called.
568  * If user don't call ble_gattc_prf_services_browse, user shall call this function to register handle range for receiving
569  * peer device indication/notification in specific client profile callback.
570  *
571  * @param[in] prf_id: Profile id.
572  * @param[in] conn_idx: Current connection index.
573  * @param[in] env: Pointer to the profile registeration event info.
574  *
575  * @retval ::SDK_SUCCESS: Successfully register Indication/Notification event.
576  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
577  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
578  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
579  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
580  ****************************************************************************************
581  */
582 uint16_t ble_gattc_prf_evt_handle_register(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env);
583 
584 /**
585  ****************************************************************************************
586  * @brief Profile client Unregister Indication/Notification event.
587  *
588  * @note Unregistration to peer device events (Indication/Notification) for specific client profile.
589  * Once completed @ref gattc_prf_cbs_t::app_gattc_prf_reg_cb with type: @ref GATTC_EVT_UNREGISTER will be called.
590  *
591  * @param[in] prf_id: Profile id.
592  * @param[in] conn_idx: Current connection index.
593  * @param[in] env: Pointer to the profile registeration event info.
594  *
595  * @retval ::SDK_SUCCESS: Successfully unregister Indication/Notification event.
596  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
597  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
598  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter(s) supplied.
599  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
600  ****************************************************************************************
601  */
602 uint16_t ble_gattc_prf_evt_handle_unregister(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env);
603 
604 /** @} */
605 /** @} */
606 
607 #endif
608 
609 /** @} */
610 /** @} */
ble_gattc_prf_read
uint16_t ble_gattc_prf_read(uint8_t prf_id, uint8_t conn_idx, uint16_t handle, uint16_t offset)
Profile client Read Attribute from remote GATT server.
ble_gatts_ntf_ind_t
GATTS Operation Complete event structure.
Definition: ble_prf.h:155
ble_gattc_ntf_ind_t
GATTC Notification and Indication value indication.
Definition: ble_gattc.h:284
ble_gatts_ntf_ind_t::type
gatt_evt_type_t type
Notification or indication event type.
Definition: ble_prf.h:156
prf_server_info_t::max_connection_nb
uint16_t max_connection_nb
Maximum connections the profile supports.
Definition: ble_prf.h:182
gattc_write_no_resp_t
GATTC write without response structure.
Definition: ble_gattc.h:121
gattc_read_multiple_t
GATTC Read Multiple.
Definition: ble_gattc.h:137
prf_client_info_t::max_connection_nb
uint16_t max_connection_nb
Maximum connections the profile supports.
Definition: ble_prf.h:260
ble_gattc_prf_write_prepare
uint16_t ble_gattc_prf_write_prepare(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value)
Profile client Prepare Long/Reliable Write to remote GATT server.
__ARRAY_EMPTY
#define __ARRAY_EMPTY
Empty Array.
Definition: gr55xx_sys_cfg.h:57
gattc_write_attr_value_t
GATTC write attribute value structure.
Definition: ble_gattc.h:110
gatts_read_req_cb_t::handle
uint16_t handle
Handle of the attribute to be read.
Definition: ble_prf.h:129
ble_gattc_prf_read_by_uuid
uint16_t ble_gattc_prf_read_by_uuid(uint8_t prf_id, uint8_t conn_idx, gattc_read_by_uuid_t *p_read_by_uuid)
Profile client Read Attribute by UUID.
ble_gattc_srvc_disc_t
GATT service discovery.
Definition: ble_gattc.h:232
prf_on_connect_func_t
void(* prf_on_connect_func_t)(uint8_t conn_idx)
Handles Connection creation.
Definition: ble_prf.h:86
ble_prf_manager_cbs_t
Profile manager callbacks.
Definition: ble_prf.h:105
prf_client_info_t
Profile client register information structure.
Definition: ble_prf.h:259
ble_gattc_prf_evt_handle_unregister
uint16_t ble_gattc_prf_evt_handle_unregister(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env)
Profile client Unregister Indication/Notification event.
ble_gattc_char_disc_t
GATT characteristic discovery.
Definition: ble_gattc.h:246
prf_on_disconnect_func_t
void(* prf_on_disconnect_func_t)(uint8_t conn_idx, uint8_t reason)
Handles Disconnection.
Definition: ble_prf.h:96
prf_server_info_t::manager_cbs
ble_prf_manager_cbs_t * manager_cbs
Profile manager callbacks.
Definition: ble_prf.h:183
GATTC_EVT_REGISTER
@ GATTC_EVT_REGISTER
GATT client event register.
Definition: ble_prf.h:236
ble_gattc_prf_primary_services_discover
uint16_t ble_gattc_prf_primary_services_discover(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Profile client Discover Primary Services on remote GATT server.
ble_prf_manager_cbs_t::on_connect
prf_on_connect_func_t on_connect
Connection callback.
Definition: ble_prf.h:107
ble_gatts.h
BLE GATTS API.
gattc_read_by_uuid_t
GATTC read by characteristic UUID structure.
Definition: ble_gattc.h:100
ble_prf_manager_cbs_t::on_disconnect
prf_on_disconnect_func_t on_disconnect
Disconnection callback.
Definition: ble_prf.h:108
ble_gattc_prf_write
uint16_t ble_gattc_prf_write(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value)
Profile client Write (Long) Characteristic (Descriptor) Value.
ble_gattc_prf_write_no_resp
uint16_t ble_gattc_prf_write_no_resp(uint8_t prf_id, uint8_t conn_idx, gattc_write_no_resp_t *p_write_no_resp)
Profile client Write Attribute to remote GATT server (without response).
gattc_disc_char_t
GATTC discovery characteristic structure.
Definition: ble_gattc.h:90
prf_client_info_t::gattc_prf_cbs
gattc_prf_cbs_t * gattc_prf_cbs
GATT client callback function in relation to the specific profile.
Definition: ble_prf.h:262
ble_gattc_prf_indicate_cfm
uint16_t ble_gattc_prf_indicate_cfm(uint8_t prf_id, uint8_t conn_idx, uint16_t handle)
Profile client Confirm Reception of Indication.
ble_gatt.h
BLE GATT.
gatt_evt_type_t
gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
ble_gattc_prf_read_multiple
uint16_t ble_gattc_prf_read_multiple(uint8_t prf_id, uint8_t conn_idx, const gattc_read_multiple_t *p_param)
Profile client Initiate a Read Multiple Characteristic Values procedure.
GATTC_EVT_UNREGISTER
@ GATTC_EVT_UNREGISTER
GATT client event unregister.
Definition: ble_prf.h:237
gatts_read_req_cb_t
GATT read request struct.
Definition: ble_prf.h:128
prf_init_func_t
uint8_t(* prf_init_func_t)(void)
Initialization of the Profile module.
Definition: ble_prf.h:77
ble_gattc_browse_srvc_t
GATTC Browse service(s) indication.
Definition: ble_gattc.h:182
prf_server_info_t
Profile server register information structure.
Definition: ble_prf.h:181
ble_gattc_prf_included_services_discover
uint16_t ble_gattc_prf_included_services_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Profile client Discover Included Services on remote GATT server.
ble_server_prf_add
uint16_t ble_server_prf_add(const prf_server_info_t *p_server_prf_info)
Add a server profile by providing its detailed information, including manager callback functions and ...
ble_gattc_prf_char_discover
uint16_t ble_gattc_prf_char_discover(uint8_t prf_id, uint8_t conn_idx, gattc_disc_char_t *p_disc_char)
Profile client Discover Characteristics on remote GATT server.
ble_gattc_incl_disc_t
GATT include discovery.
Definition: ble_gattc.h:239
ble_gattc_char_desc_disc_t
GATT characteristic descriptor discovery.
Definition: ble_gattc.h:253
ble_error.h
File that contains error codes.
gattc_prf_reg_peer_evt_t::start_hdl
uint16_t start_hdl
Attribute start handle.
Definition: ble_prf.h:227
ble_gattc_prf_evt_handle_register
uint16_t ble_gattc_prf_evt_handle_register(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env)
Profile client Register Indication/Notification event.
gattc_prf_reg_peer_evt_t
GATTC profile register to peer event info structure.
Definition: ble_prf.h:226
gatts_write_req_cb_t::handle
uint16_t handle
Handle of the attribute to be written.
Definition: ble_prf.h:137
gatts_write_req_cb_t::offset
uint16_t offset
Offset at which the data has to be written.
Definition: ble_prf.h:138
gatts_prep_write_req_cb_t
GATT prepare write request struct.
Definition: ble_prf.h:147
prf_server_info_t::gatts_prf_cbs
gatts_prf_cbs_t * gatts_prf_cbs
GATT server callback function in relation to the specific profile.
Definition: ble_prf.h:184
gattc_prf_reg_peer_evt_t::end_hdl
uint16_t end_hdl
Attribute end handle.
Definition: ble_prf.h:228
gatts_prep_write_req_cb_t::handle
uint16_t handle
Handle of the attribute for whose value is requested.
Definition: ble_prf.h:148
gattc_prf_reg_evt_t
gattc_prf_reg_evt_t
GATTC profile register enumeration.
Definition: ble_prf.h:235
ble_client_prf_add
uint16_t ble_client_prf_add(const prf_client_info_t *p_client_prf_info, uint8_t *p_client_prf_id)
Add a client profile by providing its detail information, including manager callback functions and GA...
ble_prf_manager_cbs_t::init
prf_init_func_t init
Initialization callback.
Definition: ble_prf.h:106
ble_gattc_prf_write_execute
uint16_t ble_gattc_prf_write_execute(uint8_t prf_id, uint8_t conn_idx, bool execute)
Profile client Execute Reliable/Long Write to remote GATT server.
gatts_write_req_cb_t::length
uint16_t length
Data length to be written.
Definition: ble_prf.h:139
ble_att.h
Attribute Protocol.
ble_gatts_ntf_ind_t::handle
uint16_t handle
Handle of the write operation, or notification/indication operation.
Definition: ble_prf.h:157
gatts_prf_cbs_t
GATT server callback function in relation to a profile.
Definition: ble_prf.h:164
ble_gattc.h
BLE GATTC API.
prf_client_info_t::manager_cbs
ble_prf_manager_cbs_t * manager_cbs
Profile manager callbacks.
Definition: ble_prf.h:261
ble_uuid_t
GATT UUID structure.
Definition: ble_gatt.h:80
ble_gattc_prf_char_desc_discover
uint16_t ble_gattc_prf_char_desc_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Profile client Discover Characteristics Descriptors on remote GATT server.
ble_gattc_read_rsp_t
GATT value Read response.
Definition: ble_gattc.h:269
ble_gattc_prf_services_browse
uint16_t ble_gattc_prf_services_browse(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Profile client Browse Specific Primary Service information on remote GATT server.
gattc_prf_cbs_t
GATTC Profile callback Structures.
Definition: ble_prf.h:243
gatts_write_req_cb_t
GATT write request struct.
Definition: ble_prf.h:136