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