1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. * 14 * Description: BTS GATT CLIENT module. 15 */ 16 17 18 #ifndef BTS_GATT_CLIENT_H 19 #define BTS_GATT_CLIENT_H 20 21 #include <stdint.h> 22 #include "errcode.h" 23 #include "bts_def.h" 24 #include "bts_gatt_stru.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /** 31 * @defgroup bluetooth_bts_gatt_client BTS GATT CLIENT API 32 * @ingroup bluetooth 33 * @{ 34 */ 35 36 /** 37 * @if Eng 38 * @brief Struct of handle value information. 39 * @else 40 * @brief 句柄值信息。 41 * @endif 42 */ 43 typedef struct { 44 uint16_t handle; /*!< @if Eng attribute handle. 45 @else 属性句柄。@endif */ 46 uint16_t data_len; /*!< @if Eng data length. 47 @else 数据长度。@endif */ 48 uint8_t *data; /*!< @if Eng data. 49 @else 数据。@endif */ 50 } gattc_handle_value_t; 51 52 /** 53 * @if Eng 54 * @brief Struct of discovery character parameter. 55 * @else 56 * @brief 发现特征参数。 57 * @endif 58 */ 59 typedef struct { 60 uint16_t service_handle; /*!< @if Eng service start handle. 61 @else 服务起始句柄。@endif */ 62 bt_uuid_t uuid; /*!< @if Eng characteristic uuid, if uuid length is zero, discover all character in 63 the service, else filter by uuid. 64 @else 特征uuid,如果uuid长度为0,发现服务内的所有特征,否则按照uuid过滤。@endif */ 65 } gattc_discovery_character_param_t; 66 67 /** 68 * @if Eng 69 * @brief Struct of discovery service result. 70 * @else 71 * @brief 发现服务结果。 72 * @endif 73 */ 74 typedef struct { 75 uint16_t start_hdl; /*!< @if Eng service start handle. 76 @else 服务起始句柄。@endif */ 77 uint16_t end_hdl; /*!< @if Eng service stop handle. 78 @else 服务结束句柄。@endif */ 79 bt_uuid_t uuid; /*!< @if Eng service uuid. 80 @else 服务uuid。@endif */ 81 } gattc_discovery_service_result_t; 82 83 /** 84 * @if Eng 85 * @brief Struct of discovery character result. 86 * @else 87 * @brief 发现特征结果。 88 * @endif 89 */ 90 typedef struct { 91 bt_uuid_t uuid; /*!< @if Eng character uuid. 92 @else 特征uuid。@endif */ 93 uint16_t declare_handle; /*!< @if Eng character declare handle. 94 @else 特征声明句柄。@endif */ 95 uint16_t value_handle; /*!< @if Eng character value handle. 96 @else 特征值句柄。@endif */ 97 uint8_t properties; /*!< @if Eng character properties { @ref gatt_characteristic_property_t }. 98 @else 特征特性 { @ref gatt_characteristic_property_t }。@endif */ 99 } gattc_discovery_character_result_t; 100 101 /** 102 * @if Eng 103 * @brief Struct of discovery character descriptor result. 104 * @else 105 * @brief 发现特征描述符结果。 106 * @endif 107 */ 108 typedef struct { 109 uint16_t descriptor_hdl; /*!< @if Eng character descriptor handle. 110 @else 特征描述符句柄。@endif */ 111 bt_uuid_t uuid; /*!< @if Eng character descriptor uuid. 112 @else 特征描述符uuid。@endif */ 113 } gattc_discovery_descriptor_result_t; 114 115 /** 116 * @if Eng 117 * @brief Struct of send read request by uuid parameter. 118 * @else 119 * @brief 向对端发送按照uuid读取请求的参数。 120 * @endif 121 */ 122 typedef struct { 123 uint16_t start_hdl; /*!< @if Eng start handle. 124 @else 起始句柄。@endif */ 125 uint16_t end_hdl; /*!< @if Eng end handle. 126 @else 结束句柄。@endif */ 127 bt_uuid_t uuid; /*!< @if Eng uuid. 128 @else uuid。@endif */ 129 } gattc_read_req_by_uuid_param_t; 130 131 /** 132 * @if Eng 133 * @brief Callback invoked when service discovery. 134 * @par Callback invoked when service discovery. 135 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 136 * @attention 2.The memories of devices are requested and freed by the bts automatically. 137 * @param [in] client_id client ID. 138 * @param [in] conn_id connection ID. 139 * @param [in] service service information. 140 * @param [in] status error code. 141 * @par Dependency: 142 * @li bts_def.h 143 * @see gap_ble_callbacks_t 144 * @else 145 * @brief 服务发现的回调函数。 146 * @par 服务发现的回调函数。 147 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 148 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 149 * @param [in] client_id 客户端 ID。 150 * @param [in] conn_id 连接 ID。 151 * @param [in] service 发现的服务信息。 152 * @param [in] status 执行结果错误码。 153 * @par 依赖: 154 * @li bts_def.h 155 * @see gap_ble_callbacks_t 156 * @endif 157 */ 158 typedef void (*gattc_discovery_service_callback)(uint8_t client_id, uint16_t conn_id, 159 gattc_discovery_service_result_t *service, errcode_t status); 160 161 /** 162 * @if Eng 163 * @brief Callback invoked when service discovery completed. 164 * @par Callback invoked when service discovery completed. 165 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 166 * @attention 2.The memories of devices are requested and freed by the bts automatically. 167 * @param [in] client_id client ID. 168 * @param [in] conn_id connection ID. 169 * @param [in] uuid input parameter. 170 * @param [in] status error code. 171 * @par Dependency: 172 * @li bts_def.h 173 * @see gap_ble_callbacks_t 174 * @else 175 * @brief 服务发现完成的回调函数。 176 * @par 服务发现完成的回调函数。 177 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 178 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 179 * @param [in] client_id 客户端 ID。 180 * @param [in] conn_id 连接 ID。 181 * @param [in] uuid 入参回传。 182 * @param [in] status 执行结果错误码。 183 * @par 依赖: 184 * @li bts_def.h 185 * @see gap_ble_callbacks_t 186 * @endif 187 */ 188 typedef void (*gattc_discovery_service_complete_callback)(uint8_t client_id, uint16_t conn_id, 189 bt_uuid_t *uuid, errcode_t status); 190 191 /** 192 * @if Eng 193 * @brief Callback invoked when character discovery. 194 * @par Callback invoked when character discovery. 195 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 196 * @attention 2.The memories of devices are requested and freed by the bts automatically. 197 * @param [in] client_id client ID. 198 * @param [in] conn_id connection ID. 199 * @param [in] character character information. 200 * @param [in] status error code. 201 * @par Dependency: 202 * @li bts_def.h 203 * @see gap_ble_callbacks_t 204 * @else 205 * @brief 特征发现的回调函数。 206 * @par 特征发现的回调函数。 207 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 208 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 209 * @param [in] client_id 客户端 ID。 210 * @param [in] conn_id 连接 ID。 211 * @param [in] character 发现的特征信息。 212 * @param [in] status 执行结果错误码。 213 * @par 依赖: 214 * @li bts_def.h 215 * @see gap_ble_callbacks_t 216 * @endif 217 */ 218 typedef void (*gattc_discovery_character_callback)(uint8_t client_id, uint16_t conn_id, 219 gattc_discovery_character_result_t *character, errcode_t status); 220 221 /** 222 * @if Eng 223 * @brief Callback invoked when character discovery completed. 224 * @par Callback invoked when character discovery completed. 225 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 226 * @attention 2.The memories of devices are requested and freed by the bts automatically. 227 * @param [in] client_id client ID. 228 * @param [in] conn_id connection ID. 229 * @param [in] param input parameter. 230 * @param [in] status error code. 231 * @par Dependency: 232 * @li bts_def.h 233 * @see gap_ble_callbacks_t 234 * @else 235 * @brief 特征发现完成的回调函数。 236 * @par 特征发现完成的回调函数。 237 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 238 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 239 * @param [in] client_id 客户端 ID。 240 * @param [in] conn_id 连接 ID。 241 * @param [in] param 入参回传。 242 * @param [in] status 执行结果错误码。 243 * @par 依赖: 244 * @li bts_def.h 245 * @see gap_ble_callbacks_t 246 * @endif 247 */ 248 typedef void (*gattc_discovery_character_complete_callback)(uint8_t client_id, uint16_t conn_id, 249 gattc_discovery_character_param_t *param, errcode_t status); 250 251 /** 252 * @if Eng 253 * @brief Callback invoked when character descriptor discovery. 254 * @par Callback invoked when character descriptor discovery. 255 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 256 * @attention 2.The memories of devices are requested and freed by the bts automatically. 257 * @param [in] client_id client ID. 258 * @param [in] conn_id connection ID. 259 * @param [in] descriptor character descriptor information. 260 * @param [in] status error code. 261 * @par Dependency: 262 * @li bts_def.h 263 * @see gap_ble_callbacks_t 264 * @else 265 * @brief 特征描述符发现的回调函数。 266 * @par 特征描述符发现的回调函数。 267 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 268 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 269 * @param [in] client_id 客户端 ID。 270 * @param [in] conn_id 连接 ID。 271 * @param [in] descriptor 发现的特征描述符信息。 272 * @param [in] status 执行结果错误码。 273 * @par 依赖: 274 * @li bts_def.h 275 * @see gap_ble_callbacks_t 276 * @endif 277 */ 278 typedef void (*gattc_discovery_descriptor_callback)(uint8_t client_id, uint16_t conn_id, 279 gattc_discovery_descriptor_result_t *descriptor, errcode_t status); 280 281 /** 282 * @if Eng 283 * @brief Callback invoked when character descriptor discovery completed. 284 * @par Callback invoked when character descriptor discovery completed. 285 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 286 * @attention 2.The memories of devices are requested and freed by the bts automatically. 287 * @param [in] client_id client ID. 288 * @param [in] conn_id connection ID. 289 * @param [in] character_handle input parameter. 290 * @param [in] status error code. 291 * @par Dependency: 292 * @li bts_def.h 293 * @see gap_ble_callbacks_t 294 * @else 295 * @brief 特征描述符发现完成的回调函数。 296 * @par 特征描述符发现完成的回调函数。 297 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 298 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 299 * @param [in] client_id 客户端 ID。 300 * @param [in] conn_id 连接 ID。 301 * @param [in] character_handle 入参回传。 302 * @param [in] status 执行结果错误码。 303 * @par 依赖: 304 * @li bts_def.h 305 * @see gap_ble_callbacks_t 306 * @endif 307 */ 308 typedef void (*gattc_discovery_descriptor_complete_callback)(uint8_t client_id, uint16_t conn_id, 309 uint16_t character_handle, errcode_t status); 310 311 /** 312 * @if Eng 313 * @brief Callback invoked when receive read response. 314 * @par Callback invoked when receive read response. 315 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 316 * @attention 2.The memories of devices are requested and freed by the bts automatically. 317 * @param [in] client_id client ID. 318 * @param [in] conn_id connection ID. 319 * @param [in] read_result read result. 320 * @param [in] status GATT error code. 321 * @par Dependency: 322 * @li bts_def.h 323 * @see gap_ble_callbacks_t 324 * @else 325 * @brief 收到读响应的回调函数。 326 * @par 收到读响应的回调函数。 327 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 328 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 329 * @param [in] client_id 客户端 ID。 330 * @param [in] conn_id 连接 ID。 331 * @param [in] read_result 读取结果。 332 * @param [in] status GATT错误码。 333 * @par 依赖: 334 * @li bts_def.h 335 * @see gap_ble_callbacks_t 336 * @endif 337 */ 338 typedef void (*gattc_read_cfm_callback)(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *read_result, 339 gatt_status_t status); 340 341 /** 342 * @if Eng 343 * @brief Callback invoked when read by uuid is completed. 344 * @par Callback invoked when read by uuid is completed. 345 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 346 * @attention 2.The memories of devices are requested and freed by the bts automatically. 347 * @param [in] client_id client ID. 348 * @param [in] conn_id connection ID. 349 * @param [in] param input parameter. 350 * @param [in] status error code. 351 * @par Dependency: 352 * @li bts_def.h 353 * @see gap_ble_callbacks_t 354 * @else 355 * @brief 按照uuid读取完成的回调函数。 356 * @par 按照uuid读取完成的回调函数。 357 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 358 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 359 * @param [in] client_id 客户端 ID。 360 * @param [in] conn_id 连接 ID。 361 * @param [in] param 入参回传。 362 * @param [in] status 执行结果错误码。 363 * @par 依赖: 364 * @li bts_def.h 365 * @see gap_ble_callbacks_t 366 * @endif 367 */ 368 typedef void (*gattc_read_by_uuid_complete_callback)(uint8_t client_id, uint16_t conn_id, 369 gattc_read_req_by_uuid_param_t *param, errcode_t status); 370 371 /** 372 * @if Eng 373 * @brief Callback invoked when receive write response. 374 * @par Callback invoked when receive write response. 375 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 376 * @attention 2.The memories of devices are requested and freed by the bts automatically. 377 * @param [in] client_id client ID. 378 * @param [in] conn_id connection ID. 379 * @param [in] handle write attribute handle. 380 * @param [in] status GATT error code. 381 * @par Dependency: 382 * @li bts_def.h 383 * @see gap_ble_callbacks_t 384 * @else 385 * @brief 收到写响应的回调函数。 386 * @par 收到写响应的回调函数。 387 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 388 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 389 * @param [in] client_id 客户端 ID。 390 * @param [in] conn_id 连接 ID。 391 * @param [in] handle 请求写的句柄。 392 * @param [in] status GATT错误码。 393 * @par 依赖: 394 * @li bts_def.h 395 * @see gap_ble_callbacks_t 396 * @endif 397 */ 398 typedef void (*gattc_write_cfm_callback)(uint8_t client_id, uint16_t conn_id, uint16_t handle, gatt_status_t status); 399 400 /** 401 * @if Eng 402 * @brief Callback invoked when mtu changed. 403 * @par Callback invoked when mtu changed. 404 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 405 * @attention 2.The memories of devices are requested and freed by the bts automatically. 406 * @param [in] client_id client ID. 407 * @param [in] conn_id connection ID. 408 * @param [in] mtu_size mtu size. 409 * @param [in] status error code. 410 * @par Dependency: 411 * @li bts_def.h 412 * @see gap_ble_callbacks_t 413 * @else 414 * @brief mtu改变的回调函数。 415 * @par mtu改变的回调函数。 416 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 417 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 418 * @param [in] client_id 客户端 ID。 419 * @param [in] conn_id 连接 ID。 420 * @param [in] mtu_size mtu大小。 421 * @param [in] status 执行结果错误码。 422 * @par 依赖: 423 * @li bts_def.h 424 * @see gap_ble_callbacks_t 425 * @endif 426 */ 427 typedef void (*gattc_mtu_changed_callback)(uint8_t client_id, uint16_t conn_id, uint16_t mtu_size, errcode_t status); 428 429 /** 430 * @if Eng 431 * @brief Callback invoked when receive notification. 432 * @par Callback invoked when receive notification. 433 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 434 * @attention 2.The memories of devices are requested and freed by the bts automatically. 435 * @param [in] client_id client ID. 436 * @param [in] conn_id connection ID. 437 * @param [in] data data. 438 * @param [in] status error code. 439 * @par Dependency: 440 * @li bts_def.h 441 * @see gap_ble_callbacks_t 442 * @else 443 * @brief 收到通知的回调函数。 444 * @par 收到通知的回调函数。 445 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 446 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 447 * @param [in] client_id 客户端 ID。 448 * @param [in] conn_id 连接 ID。 449 * @param [in] data 数据。 450 * @param [in] status 执行结果错误码。 451 * @par 依赖: 452 * @li bts_def.h 453 * @see gap_ble_callbacks_t 454 * @endif 455 */ 456 typedef void (*gattc_notification_callback)(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data, 457 errcode_t status); 458 459 /** 460 * @if Eng 461 * @brief Callback invoked when receive indication. 462 * @par Callback invoked when receive indication. 463 * @attention 1.This function is called in bts context,should not be blocked or do long time waiting. 464 * @attention 2.The memories of devices are requested and freed by the bts automatically. 465 * @param [in] client_id client ID. 466 * @param [in] conn_id connection ID. 467 * @param [in] data data. 468 * @param [in] status error code. 469 * @par Dependency: 470 * @li bts_def.h 471 * @see gap_ble_callbacks_t 472 * @else 473 * @brief 收到指示的回调函数。 474 * @par 收到指示的回调函数。 475 * @attention 1. 该回调函数运行于bts线程,不能阻塞或长时间等待。 476 * @attention 2. devices由bts申请内存,也由bts释放,回调中不应释放。 477 * @param [in] client_id 客户端 ID。 478 * @param [in] conn_id 连接 ID。 479 * @param [in] data 数据。 480 * @param [in] status 执行结果错误码。 481 * @par 依赖: 482 * @li bts_def.h 483 * @see gap_ble_callbacks_t 484 * @endif 485 */ 486 typedef void (*gattc_indication_callback)(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *data, 487 errcode_t status); 488 489 /** 490 * @if Eng 491 * @brief Struct of GATT client callback function. 492 * @else 493 * @brief GATT client回调函数接口定义。 494 * @endif 495 */ 496 typedef struct ble_gattc_callbacks { 497 gattc_discovery_service_callback discovery_svc_cb; /*!< @if Eng Discovery service callback. 498 @else 发现服务回调函数。 @endif */ 499 gattc_discovery_service_complete_callback discovery_svc_cmp_cb; /*!< @if Eng Discovery service complete 500 callback. 501 @else 发现服务完成回调函数。 @endif */ 502 gattc_discovery_character_callback discovery_chara_cb; /*!< @if Eng Discovery character callback. 503 @else 发现特征回调函数。 @endif */ 504 gattc_discovery_character_complete_callback discovery_chara_cmp_cb; /*!< @if Eng Discovery character complete 505 callback. 506 @else 发现特征完成回调函数。 @endif */ 507 gattc_discovery_descriptor_callback discovery_desc_cb; /*!< @if Eng Discovery character descriptor 508 callback. 509 @else 发现特征描述符回调函数。 @endif */ 510 gattc_discovery_descriptor_complete_callback discovery_desc_cmp_cb; /*!< @if Eng Discovery character descriptor 511 complete callback. 512 @else 发现特征描述符完成回调函数。 513 @endif */ 514 gattc_read_cfm_callback read_cb; /*!< @if Eng Receive read response callback. 515 @else 收到读响应回调函数。 @endif */ 516 gattc_read_by_uuid_complete_callback read_cmp_cb; /*!< @if Eng Read by uuid complete callback. 517 @else 按照uuid读取完成回调函数。 518 @endif */ 519 gattc_write_cfm_callback write_cb; /*!< @if Eng Receive write response callback. 520 @else 收到写响应回调函数。 @endif */ 521 gattc_mtu_changed_callback mtu_changed_cb; /*!< @if Eng Mtu changed callback. 522 @else mtu改变回调函数。 @endif */ 523 gattc_notification_callback notification_cb; /*!< @if Eng Receive notification callback. 524 @else 收到通知回调函数。 @endif */ 525 gattc_indication_callback indication_cb; /*!< @if Eng Receive indication callback. 526 @else 收到指示回调函数。 @endif */ 527 } gattc_callbacks_t; 528 529 /** 530 * @if Eng 531 * @brief Register gatt client. 532 * @par Description: Register gatt client. 533 * @param [in] app_uuid App uuid. 534 * @param [out] client_id Client ID. 535 * @retval ERRCODE_SUCC Success. 536 * @retval Other Failure. For details, see @ref errcode_t 537 * @par Depends: 538 * @li bts_def.h 539 * @else 540 * @brief 注册gatt客户端。 541 * @par Description: 注册gatt客户端。 542 * @param [in] app_uuid 上层应用uuid。 543 * @param [out] client_id 客户端ID。 544 * @retval ERRCODE_SUCC 成功。 545 * @retval Other 失败。参考 @ref errcode_t 546 * @par 依赖: 547 * @li bts_def.h 548 * @endif 549 */ 550 errcode_t gattc_register_client(bt_uuid_t *app_uuid, uint8_t *client_id); 551 552 /** 553 * @if Eng 554 * @brief Unregister gatt client. 555 * @par Description: Unregister gatt client. 556 * @param [in] client_id Client ID. 557 * @retval ERRCODE_SUCC Success. 558 * @retval Other Failure. For details, see @ref errcode_t 559 * @par Depends: 560 * @li bts_def.h 561 * @else 562 * @brief 注销gatt客户端。 563 * @par Description: 注销gatt服务端。 564 * @param [in] client_id 客户端ID。 565 * @retval ERRCODE_SUCC 成功。 566 * @retval Other 失败。参考 @ref errcode_t 567 * @par 依赖: 568 * @li bts_def.h 569 * @endif 570 */ 571 errcode_t gattc_unregister_client(uint8_t client_id); 572 573 /** 574 * @if Eng 575 * @brief Discovery service. 576 * @par Description: Discovery service. 577 * @param [in] client_id Client ID. 578 * @param [in] conn_id Connection ID. 579 * @param [in] uuid Service uuid, if uuid length is zero, discover all service, else filter by uuid. 580 * @retval error code, discovery service result will be returned at { @ref gattc_discovery_service_callback } and 581 { @ref gattc_discovery_service_complete_callback }. 582 * @par Depends: 583 * @li bts_def.h 584 * @else 585 * @brief 发现服务。 586 * @par Description: 发现服务。 587 * @param [in] client_id 客户端 ID。 588 * @param [in] conn_id 连接 ID。 589 * @param [in] uuid 服务uuid,如果uuid长度为0,发现所有服务,否则按照uuid过滤。 590 * @retval 执行结果错误码, 服务发现结果将在 { @ref gattc_discovery_service_callback }和 591 { @ref gattc_discovery_service_complete_callback }中返回。 592 * @par 依赖: 593 * @li bts_def.h 594 * @endif 595 */ 596 errcode_t gattc_discovery_service(uint8_t client_id, uint16_t conn_id, bt_uuid_t *uuid); 597 598 /** 599 * @if Eng 600 * @brief Discovery character. 601 * @par Description: Discovery character. 602 * @param [in] client_id Client ID. 603 * @param [in] conn_id Connection ID. 604 * @param [in] param Parameter for discover character. 605 * @retval error code, discovery character result will be returned at { @ref gattc_discovery_character_callback } and 606 { @ref gattc_discovery_character_complete_callback }. 607 * @par Depends: 608 * @li bts_def.h 609 * @else 610 * @brief 发现特征。 611 * @par Description: 发现特征。 612 * @param [in] client_id 客户端 ID。 613 * @param [in] conn_id 连接 ID。 614 * @param [in] param 发现特征参数。 615 * @retval 执行结果错误码,特征发现结果将在 { @ref gattc_discovery_character_callback }和 616 { @ref gattc_discovery_character_complete_callback } 中返回。 617 * @par 依赖: 618 * @li bts_def.h 619 * @endif 620 */ 621 errcode_t gattc_discovery_character(uint8_t client_id, uint16_t conn_id, gattc_discovery_character_param_t *param); 622 623 /** 624 * @if Eng 625 * @brief Discovery character descriptor. 626 * @par Description: Discovery character descriptor. 627 * @param [in] client_id Client ID. 628 * @param [in] conn_id Connection ID. 629 * @param [in] character_handle Character declaration句柄. 630 * @retval error code, discovery character descriptor result will be returned at 631 { @ref gattc_discovery_descriptor_callback } and 632 { @ref gattc_discovery_descriptor_complete_callback }. 633 * @par Depends: 634 * @li bts_def.h 635 * @else 636 * @brief 发现特征描述符。 637 * @par Description: 发现特征描述符。 638 * @param [in] client_id 客户端 ID。 639 * @param [in] conn_id 连接 ID。 640 * @param [in] character_handle 特征声明句柄。 641 * @retval 执行结果错误码,特征描述符发现结果将在 { @ref gattc_discovery_descriptor_callback }和 642 { @ref gattc_discovery_descriptor_complete_callback } 中返回。 643 * @par 依赖: 644 * @li bts_def.h 645 * @endif 646 */ 647 errcode_t gattc_discovery_descriptor(uint8_t client_id, uint16_t conn_id, uint16_t character_handle); 648 649 /** 650 * @if Eng 651 * @brief Send read by handle request. 652 * @par Description: Send read by handle request. 653 * @param [in] client_id Client ID. 654 * @param [in] conn_id Connection ID. 655 * @param [in] handle handle. 656 * @retval error code, read result will be returned at { @ref gattc_read_cfm_callback }. 657 * @par Depends: 658 * @li bts_def.h 659 * @else 660 * @brief 发起按照句柄读取请求。 661 * @par Description: 发起按照句柄读取请求。 662 * @param [in] client_id 客户端 ID。 663 * @param [in] conn_id 连接 ID。 664 * @param [in] handle 句柄。 665 * @retval 执行结果错误码,读取结果将在 { @ref gattc_read_cfm_callback }中返回。 666 * @par 依赖: 667 * @li bts_def.h 668 * @endif 669 */ 670 errcode_t gattc_read_req_by_handle(uint8_t client_id, uint16_t conn_id, uint16_t handle); 671 672 /** 673 * @if Eng 674 * @brief Send read by uuid request. 675 * @par Description: Send read by uuid request. 676 * @param [in] client_id Client ID. 677 * @param [in] conn_id Connection ID. 678 * @param [in] param Parameter for read request by uuid. 679 * @retval error code, read result will be returned at { @ref gattc_read_cfm_callback } and 680 { @ref gattc_read_by_uuid_complete_callback }. 681 * @par Depends: 682 * @li bts_def.h 683 * @else 684 * @brief 发起按照uuid读取请求。 685 * @par Description: 发起按照uuid读取请求。 686 * @param [in] client_id 客户端 ID。 687 * @param [in] conn_id 连接 ID。 688 * @param [in] param 按照uuid读取请求参数。 689 * @retval 执行结果错误码,读取结果将在 { @ref gattc_read_cfm_callback }和 690 { @ref gattc_read_by_uuid_complete_callback }中返回。 691 * @par 依赖: 692 * @li bts_def.h 693 * @endif 694 */ 695 errcode_t gattc_read_req_by_uuid(uint8_t client_id, uint16_t conn_id, gattc_read_req_by_uuid_param_t *param); 696 697 /** 698 * @if Eng 699 * @brief Send write request. 700 * @par Description: Send write request. 701 * @param [in] client_id Client ID. 702 * @param [in] conn_id Connection ID. 703 * @param [in] param Parameter for write request. 704 * @retval error code, write result will be returned at { @ref gattc_write_cfm_callback }. 705 * @par Depends: 706 * @li bts_def.h 707 * @else 708 * @brief 发起写请求。 709 * @par Description: 发起写请求。 710 * @param [in] client_id 客户端 ID。 711 * @param [in] conn_id 连接 ID。 712 * @param [in] param 写请求参数。 713 * @retval 执行结果错误码,写结果将在 { @ref gattc_write_cfm_callback }中返回。 714 * @par 依赖: 715 * @li bts_def.h 716 * @endif 717 */ 718 errcode_t gattc_write_req(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *param); 719 720 /** 721 * @if Eng 722 * @brief Send write command. 723 * @par Description: Send write command. 724 * @param [in] client_id Client ID. 725 * @param [in] conn_id Connection ID. 726 * @param [in] param Parameter for write command. 727 * @retval ERRCODE_SUCC Success. 728 * @retval Other Failure. For details, see @ref errcode_t 729 * @par Depends: 730 * @li bts_def.h 731 * @else 732 * @brief 发起写命令。 733 * @par Description: 发起写命令。 734 * @param [in] client_id 客户端 ID。 735 * @param [in] conn_id 连接 ID。 736 * @param [in] param 写命令参数。 737 * @retval ERRCODE_SUCC 成功。 738 * @retval Other 失败。参考 @ref errcode_t 739 * @par 依赖: 740 * @li bts_def.h 741 * @endif 742 */ 743 errcode_t gattc_write_cmd(uint8_t client_id, uint16_t conn_id, gattc_handle_value_t *param); 744 745 /** 746 * @if Eng 747 * @brief Send exchange mtu request. 748 * @par Description: Send exchange mtu request. 749 * @param [in] client_id Client ID. 750 * @param [in] conn_id Connection ID. 751 * @param [in] mtu_size Client rx mtu. 752 * @retval error code, mtu change result will be returned at { @ref gattc_mtu_changed_callback }. 753 * @par Depends: 754 * @li bts_def.h 755 * @else 756 * @brief 发送交换mtu请求。 757 * @par Description: 发送交换mtu请求。 758 * @param [in] client_id 客户端 ID。 759 * @param [in] conn_id 连接 ID。 760 * @param [in] mtu_size 客户端接收mtu。 761 * @retval 执行结果错误码, mtu改变结果将在 { @ref gattc_mtu_changed_callback }中返回。 762 * @par 依赖: 763 * @li bts_def.h 764 * @endif 765 */ 766 errcode_t gattc_exchange_mtu_req(uint8_t client_id, uint16_t conn_id, uint16_t mtu_size); 767 768 /** 769 * @if Eng 770 * @brief Register gatt client callbacks. 771 * @par Description: Register gatt client callbacks. 772 * @param [in] func Callback function. 773 * @retval ERRCODE_SUCC Success. 774 * @retval Other Failure. For details, see @ref errcode_t 775 * @par Depends: 776 * @li bts_def.h 777 * @else 778 * @brief 注册gatt客户端回调函数。 779 * @par Description: 注册gatt客户端回调函数。 780 * @param [in] func 回调函数。 781 * @retval ERRCODE_SUCC 成功。 782 * @retval Other 失败。参考 @ref errcode_t 783 * @par 依赖: 784 * @li bts_def.h 785 * @endif 786 */ 787 errcode_t gattc_register_callbacks(gattc_callbacks_t *func); 788 789 /** 790 * @} 791 */ 792 793 #ifdef __cplusplus 794 } 795 #endif 796 #endif 797 798