bt_app_api.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. /**
  2. ****************************************************************************************
  3. *
  4. * @file bt_app_api.h
  5. *
  6. * @brief Application entry point
  7. *
  8. * Copyright (C) Espressif 2016
  9. * Created by Yulong at 2016/10/13
  10. *
  11. *
  12. ****************************************************************************************
  13. */
  14. #include "bt_types.h"
  15. #include "bt_app_defs.h"
  16. #include "bta_gatt_api.h"
  17. #include "bt_prf_sys.h"
  18. /*******************************************************************************
  19. **
  20. ** @function esp_ble_config_adv_data
  21. **
  22. ** @brief This function is called to override the BTA default ADV parameters.
  23. **
  24. ** @param[in] adv_data: Pointer to User defined ADV data structure. This
  25. ** memory space can not be freed until p_adv_data_cback
  26. ** is received.
  27. ** @param[in|out] adv_data_cback: set adv data complete callback.
  28. **
  29. ** @return None
  30. **
  31. *******************************************************************************/
  32. void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data,
  33. esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback);
  34. /*******************************************************************************
  35. **
  36. ** @function esp_ble_set_scan_params
  37. **
  38. ** @brief This function is called to set scan parameters
  39. **
  40. ** @param[in] esp_ble_scan_params: Pointer to User defined scan_params data structure. This
  41. ** memory space can not be freed until scan_param_setup_cback
  42. ** @param[in] client_if: Client interface ID
  43. ** @param[in|out] scan_param_setup_status_cback - Set scan param status callback
  44. **
  45. ** @return None
  46. **
  47. *******************************************************************************/
  48. void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if,
  49. esp_scan_param_setup_cb_t scan_param_setup_cback);
  50. /*******************************************************************************
  51. **
  52. ** @function esp_ble_start_scanning
  53. **
  54. ** @brief This procedure keep the device scanning the peer device whith advertising on the air
  55. **
  56. ** @param[in] duration: Keeping the scaning time, the unit is second.
  57. ** @param[in|out] results_cb: The scanning function callback when the peer device has been scan
  58. ** which advertising on the air
  59. **
  60. ** @return None
  61. **
  62. *******************************************************************************/
  63. void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb);
  64. /*******************************************************************************
  65. **
  66. ** @function esp_ble_start_advertising
  67. **
  68. ** @brief This function is called to start advertising.
  69. **
  70. ** @param[in] esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.
  71. **
  72. ** @return None
  73. **
  74. *******************************************************************************/
  75. void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params);
  76. /*******************************************************************************
  77. **
  78. ** @function esp_ble_stop_advertising
  79. **
  80. ** @brief This function is called to stop advertising.
  81. **
  82. ** @param None
  83. **
  84. ** @return None
  85. **
  86. *******************************************************************************/
  87. void esp_ble_stop_advertising (void);
  88. /*******************************************************************************
  89. **
  90. ** @function esp_ble_update_conn_params
  91. **
  92. ** @brief Update connection parameters, can only be used when connection is up.
  93. **
  94. ** @param[in] bd_addr - BD address of the peer
  95. ** @param[in] min_int - minimum connection interval, [0x0004~ 0x4000]
  96. ** @param[in] max_int - maximum connection interval, [0x0004~ 0x4000]
  97. ** @param[in] latency - slave latency [0 ~ 500]
  98. ** @param[in] timeout - supervision timeout [0x000a ~ 0xc80]
  99. **
  100. ** @return None
  101. **
  102. *******************************************************************************/
  103. void esp_ble_update_conn_params (BD_ADDR bd_addr, uint16_t min_int,
  104. uint16_t max_int, uint16_t latency, uint16_t timeout);
  105. /*******************************************************************************
  106. **
  107. ** @function esp_ble_set_pkt_data_len
  108. **
  109. ** @brief This function is to set maximum LE data packet size
  110. **
  111. ** @return None
  112. **
  113. **
  114. *******************************************************************************/
  115. void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length);
  116. /*******************************************************************************
  117. **
  118. ** @function esp_ble_set_rand_addr
  119. **
  120. ** @brief This function set the random address for the appliction
  121. **
  122. ** @param[in] rand_addr: the random address whith should be setting
  123. **
  124. ** @return None
  125. **
  126. **
  127. *******************************************************************************/
  128. void esp_ble_set_rand_addr (BD_ADDR rand_addr);
  129. /*******************************************************************************
  130. **
  131. ** @function esp_ble_config_local_privacy
  132. **
  133. ** @brief Enable/disable privacy on the local device
  134. **
  135. ** @param[in] privacy_enable - enable/disabe privacy on remote device.
  136. **
  137. ** @return None
  138. **
  139. *******************************************************************************/
  140. void esp_ble_config_local_privacy (BOOLEAN privacy_enable);
  141. /*******************************************************************************
  142. ** @function esp_gattc_disable
  143. ** @brief This function is called by application to disable GATTC module
  144. **
  145. ** @param NULL
  146. **
  147. ** @return None.
  148. **
  149. *******************************************************************************/
  150. void esp_gattc_disable(void);
  151. /*******************************************************************************
  152. **
  153. ** @function esp_ble_gattc_app_register
  154. **
  155. ** @brief This function is called to register application callbacks
  156. ** with GATTC module.
  157. **
  158. ** @param[in] app_uuid - applicaiton UUID
  159. ** @param[in] client_cb - pointer to the application callback function.
  160. **
  161. ** @return None
  162. **
  163. *******************************************************************************/
  164. void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb);
  165. /*******************************************************************************
  166. **
  167. ** @function esp_ble_gattc_app_unregister
  168. **
  169. ** @brief This function is called to unregister an application
  170. ** from GATTC module.
  171. **
  172. ** @param[in] client_if - client interface identifier.
  173. **
  174. ** @return None
  175. **
  176. *******************************************************************************/
  177. void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if);
  178. /*******************************************************************************
  179. **
  180. ** @function esp_ble_gattc_conn
  181. **
  182. ** @brief Open a direct connection or add a background auto connection
  183. ** bd address
  184. **
  185. ** @param[in] client_if: server interface.
  186. ** @param[in] remote_bda: remote device BD address.
  187. ** @param[in] is_direct: direct connection or background auto connection
  188. **
  189. ** @return None
  190. **
  191. *******************************************************************************/
  192. void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
  193. /*******************************************************************************
  194. **
  195. ** @function esp_ble_gattc_cancel_conn
  196. **
  197. ** @brief Cancel a direct open connection or remove a background auto connection
  198. ** bd address
  199. **
  200. ** @param[in] client_if: server interface.
  201. ** @param[in] remote_bda: remote device BD address.
  202. ** @param[in] is_direct: direct connection or background auto connection
  203. **
  204. ** @return None
  205. **
  206. *******************************************************************************/
  207. void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
  208. /*******************************************************************************
  209. **
  210. ** @function esp_ble_gattc_close
  211. **
  212. ** @brief Close a connection to a GATT server.
  213. **
  214. ** @param[in] conn_id: connectino ID to be closed.
  215. **
  216. ** @return None
  217. **
  218. *******************************************************************************/
  219. void esp_ble_gattc_close (uint16_t conn_id);
  220. /*******************************************************************************
  221. **
  222. ** @function esp_ble_gattc_config_mtu
  223. **
  224. ** @brief Configure the MTU size in the GATT channel. This can be done
  225. ** only once per connection.
  226. **
  227. ** @param[in] conn_id: connection ID.
  228. ** mtu: desired MTU size to use.
  229. **
  230. ** @return Command status code:
  231. ** - @ref ESP_GATT_OK: If request succeeds
  232. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid
  233. **
  234. *******************************************************************************/
  235. esp_gatt_status_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu);
  236. /*******************************************************************************
  237. **
  238. ** @function esp_ble_gattc_svc_search_req
  239. **
  240. ** @brief This function is called to request a GATT service discovery
  241. ** on a GATT server. This function report service search result
  242. ** by a callback event, and followed by a service search complete
  243. ** event.
  244. **
  245. ** @param[in] conn_id: connection ID.
  246. ** @param[in] srvc_uuid: a UUID of the service application is interested in.
  247. ** If Null, discover for all services.
  248. **
  249. ** @return None
  250. **
  251. *******************************************************************************/
  252. void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid);
  253. /****************************************************************************************************
  254. **
  255. ** @function esp_ble_gattc_get_first_char
  256. **
  257. ** @brief This function is called to find the first characteristic of the
  258. ** service on the given server.
  259. **
  260. ** @param[in] conn_id: connection ID which identify the server.
  261. ** @param[in] srvc_id: the service ID of which the characteristic is belonged to.
  262. ** @param[in] char_uuid_cond: Characteristic UUID, if NULL find the first available
  263. ** characteristic.
  264. ** @param[in] char_result: output parameter which will store the GATT
  265. ** characteristic ID.
  266. ** @param[in] property: output parameter to carry the characteristic property.
  267. **
  268. ** @return Command status code:
  269. ** - @ref ESP_GATT_OK: If request succeeds
  270. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL.
  271. **
  272. *****************************************************************************************************/
  273. esp_gatt_status_t esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
  274. esp_bt_uuid_t *char_uuid_cond,
  275. esp_gattc_char_id_t *char_result,
  276. esp_gatt_char_prop_t *property);
  277. /*******************************************************************************
  278. **
  279. ** @function esp_ble_gattc_get_first_char_descr
  280. **
  281. ** @brief This function is called to find the first characteristic descriptor of the
  282. ** characteristic on the given server.
  283. **
  284. ** @param[in] conn_id: connection ID which identify the server.
  285. ** @param[in] char_id: the characteristic ID of which the descriptor is belonged to.
  286. ** @param[in] descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
  287. ** characteristic.
  288. ** @param[in] descr_result: output parameter which will store the GATT
  289. ** characteristic descriptor ID.
  290. **
  291. ** @return Command status code:
  292. ** - @ref ESP_GATT_OK: If request succeeds
  293. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL.
  294. **
  295. *******************************************************************************/
  296. esp_gatt_status_t esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id,
  297. esp_bt_uuid_t *descr_uuid_cond,
  298. esp_gattc_char_descr_id_t *descr_result);
  299. /*******************************************************************************
  300. **
  301. ** @function esp_ble_gattc_get_next_inclu_srvc
  302. **
  303. ** @brief This function is called to find the next included service of the
  304. ** service on the given server.
  305. **
  306. ** @param[in] conn_id: connection ID which identify the server.
  307. ** @param[in] start_id: start the search from the next record
  308. ** after the one identified by p_start_id.
  309. ** @param[in] uuid_cond: Included service UUID, if NULL find the first available
  310. ** included service.
  311. ** @param[in] result: output parameter which will store the GATT ID
  312. ** of the included service found.
  313. **
  314. ** @return Command status code:
  315. ** - @ref ESP_GATT_OK: If request succeeds
  316. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL.
  317. *******************************************************************************/
  318. esp_gatt_status_t esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id,
  319. esp_gattc_incl_srvc_id_t *start_id,
  320. esp_bt_uuid_t *uuid_cond,
  321. esp_gattc_incl_srvc_id_t *result);
  322. /*******************************************************************************
  323. **
  324. ** @function esp_ble_gattc_get_next_char
  325. **
  326. ** @brief This function is called to find the next characteristic of the
  327. ** service on the given server.
  328. **
  329. ** @param[in] conn_id: connection ID which identify the server.
  330. ** @param[in] start_char_id: start the characteristic search from the next record
  331. ** after the one identified by char_id.
  332. ** @param[in] char_uuid_cond: Characteristic UUID, if NULL find the first available
  333. ** characteristic.
  334. ** @param[in] char_result: output parameter which will store the GATT
  335. ** characteristic ID.
  336. ** @param[in] property: output parameter to carry the characteristic property.
  337. **
  338. ** @return Command status code:
  339. ** - @ref ESP_GATT_OK: If request succeeds
  340. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL.
  341. **
  342. *******************************************************************************/
  343. esp_gatt_status_t esp_ble_gattc_get_next_char (uint16_t conn_id,
  344. esp_gattc_char_id_t *start_char_id,
  345. esp_bt_uuid_t *char_uuid_cond,
  346. esp_gattc_char_id_t *char_result,
  347. esp_gatt_char_prop_t *property);
  348. /*******************************************************************************
  349. **
  350. ** @function esp_ble_gattc_get_next_char_descr
  351. **
  352. ** @brief This function is called to find the next characteristic descriptor
  353. ** of the characterisctic.
  354. **
  355. ** @param[in] conn_id: connection ID which identify the server.
  356. ** @param[in] start_descr_id: start the descriptor search from the next record
  357. ** after the one identified by p_start_descr_id.
  358. ** @param[in] descr_uuid_cond: Characteristic descriptor UUID, if NULL find
  359. ** the first available characteristic descriptor.
  360. ** @param[in] descr_result: output parameter which will store the GATT
  361. ** characteristic descriptor ID.
  362. **
  363. ** @return Command status code:
  364. ** - @ref ESP_GATT_OK: If request succeeds
  365. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL.
  366. **
  367. *******************************************************************************/
  368. esp_gatt_status_t esp_ble_gattc_get_next_char_descr (uint16_t conn_id,
  369. esp_gattc_char_descr_id_t *start_descr_id,
  370. esp_bt_uuid_t *descr_uuid_cond,
  371. esp_gattc_char_descr_id_t *descr_result);
  372. /*******************************************************************************
  373. **
  374. ** @function esp_ble_gattc_get_first_inclu_srvc
  375. **
  376. ** @brief This function is called to find the first included service of the
  377. ** service on the given server.
  378. **
  379. ** @param[in] conn_id: connection ID which identify the server.
  380. ** @param[in] srvc_id: the service ID of which the characteristic is belonged to.
  381. ** @param[in] uuid_cond: Characteristic UUID, if NULL find the first available
  382. ** characteristic.
  383. ** @param[in] result: output parameter which will store the GATT ID
  384. ** of the included service found.
  385. **
  386. ** @return Command status code:
  387. ** - @ref ESP_GATT_OK: If request succeeds
  388. ** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL.
  389. **
  390. *******************************************************************************/
  391. esp_gatt_status_t esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
  392. esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result);
  393. /*******************************************************************************
  394. **
  395. ** @function esp_ble_gattc_read_char
  396. **
  397. ** @brief This function is called to read a service's characteristics of
  398. ** the given characteritisc ID.
  399. **
  400. ** @param[in] conn_id - connectino ID.
  401. ** @param[in] char_id - characteritic ID to read.
  402. **
  403. ** @return None
  404. **
  405. *******************************************************************************/
  406. void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id,
  407. esp_gatt_auth_req_t auth_req);
  408. /*******************************************************************************
  409. **
  410. ** @function esp_ble_gattc_read_char_descr
  411. **
  412. ** @brief This function is called to read a characteristics descriptor.
  413. **
  414. ** @param[in] conn_id - connection ID.
  415. ** @param[in] descr_id - characteritic descriptor ID to read.
  416. **
  417. ** @return None
  418. **
  419. *******************************************************************************/
  420. void esp_ble_gattc_read_char_descr (uint16_t conn_id,
  421. esp_gattc_char_descr_id_t *descr_id,
  422. esp_gatt_auth_req_t auth_req);
  423. /*******************************************************************************
  424. **
  425. ** @function esp_ble_gattc_read_multi
  426. **
  427. ** @brief This function is called to read multiple characteristic or
  428. ** characteristic descriptors.
  429. **
  430. ** @param[in] conn_id - connectino ID.
  431. ** @param[in] read_multi - pointer to the read multiple parameter.
  432. **
  433. ** @return None
  434. **
  435. *******************************************************************************/
  436. void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi,
  437. esp_gatt_auth_req_t auth_req);
  438. /*******************************************************************************
  439. **
  440. ** @function esp_ble_gattc_write_char_val
  441. **
  442. ** @brief This function is called to write characteristic value.
  443. **
  444. ** @param[in] conn_id - connection ID.
  445. ** @param[in] char_id - characteristic ID to write.
  446. ** @param[in] write_type - type of write.
  447. ** @param[in] len: length of the data to be written.
  448. ** @param[in] value - the value to be written.
  449. **
  450. ** @return None
  451. **
  452. *******************************************************************************/
  453. void esp_ble_gattc_write_char_val ( uint16_t conn_id,
  454. esp_gattc_char_id_t *char_id,
  455. esp_gattc_write_type_t write_type,
  456. uint16_t len,
  457. uint8_t *value,
  458. esp_gatt_auth_req_t auth_req);
  459. /*******************************************************************************
  460. **
  461. ** @function esp_ble_gattc_write_char_descr
  462. **
  463. ** @brief This function is called to write characteristic descriptor value.
  464. **
  465. ** @param[in] conn_id - connection ID
  466. ** @param[in] char_descr_id - characteristic descriptor ID to write.
  467. ** @param[in] write_type - write type.
  468. ** @param[in] data - the value to be written.
  469. **
  470. ** @return None
  471. **
  472. *******************************************************************************/
  473. void esp_ble_gattc_write_char_descr (uint16_t conn_id,
  474. esp_gattc_char_descr_id_t *char_descr_id,
  475. esp_gattc_write_type_t write_type,
  476. esp_gatt_unfmt_t *data,
  477. esp_gatt_auth_req_t auth_req);
  478. /*******************************************************************************
  479. **
  480. ** @function esp_ble_gattc_prepa_write
  481. **
  482. ** @brief This function is called to prepare write a characteristic value.
  483. **
  484. ** @param[in] conn_id - connection ID.
  485. ** @param[in] char_id - GATT characteritic ID of the service.
  486. ** @param[in] offset - offset of the write value.
  487. ** @param[in] len: length of the data to be written.
  488. ** @param[in] value - the value to be written.
  489. **
  490. ** @return None
  491. **
  492. *******************************************************************************/
  493. void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id,
  494. uint16_t offset, uint16_t len, uint8_t *value,
  495. esp_gatt_auth_req_t auth_req);
  496. /*******************************************************************************
  497. **
  498. ** @function esp_ble_gattc_execu_write
  499. **
  500. ** @brief This function is called to execute write a prepare write sequence.
  501. **
  502. ** @param[in] conn_id - connection ID.
  503. ** @param[in] is_execute - execute or cancel.
  504. **
  505. ** @return None
  506. **
  507. *******************************************************************************/
  508. void esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute);
  509. /*******************************************************************************
  510. **
  511. ** @function esp_ble_gattc_send_ind_cfm
  512. **
  513. ** @brief This function is called to send handle value confirmation.
  514. **
  515. ** @param[in] conn_id - connection ID.
  516. ** @param[in] char_id - characteristic ID to confirm.
  517. **
  518. ** @return None
  519. **
  520. *******************************************************************************/
  521. void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id);
  522. /*******************************************************************************
  523. **
  524. ** @function esp_ble_gattc_register_ntf
  525. **
  526. ** @brief This function is called to register for notification of a service.
  527. **
  528. ** @param[in] client_if - client interface.
  529. ** @param[in] bda - target GATT server.
  530. ** @param[in] char_id - pointer to GATT characteristic ID.
  531. **
  532. ** @return OK if registration succeed, otherwise failed.
  533. **
  534. *******************************************************************************/
  535. esp_gatt_status_t esp_ble_gattc_register_ntf (esp_gattc_if_t client_if,
  536. BD_ADDR bda,
  537. esp_gattc_char_id_t *char_id);
  538. /*******************************************************************************
  539. **
  540. ** @function esp_ble_gattc_unregister_ntf
  541. **
  542. ** @brief This function is called to de-register for notification of a service.
  543. **
  544. ** @param[in] client_if - client interface.
  545. ** @param[in] bda - target GATT server.
  546. ** @param[in] char_id - pointer to GATT characteristic ID.
  547. **
  548. ** @return OK if deregistration succeed, otherwise failed.
  549. **
  550. *******************************************************************************/
  551. tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if,
  552. BD_ADDR bda,
  553. esp_gattc_char_id_t *char_id);
  554. /*******************************************************************************
  555. **
  556. ** @function esp_ble_gatts_disale
  557. **
  558. ** @brief This function is called to disable GATTS module
  559. **
  560. ** @param[in] None.
  561. **
  562. ** @return None
  563. **
  564. *******************************************************************************/
  565. void esp_ble_gatts_disale(void);
  566. /*******************************************************************************
  567. **
  568. ** @function esp_ble_gatts_app_register
  569. **
  570. ** @brief This function is called to register application callbacks
  571. ** with BTA GATTS module.
  572. **
  573. ** @param[in] app_uuid - applicaiton UUID
  574. ** @param[in] cback - pointer to the application callback function.
  575. **
  576. ** @return None
  577. **
  578. *******************************************************************************/
  579. void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback);
  580. /*******************************************************************************
  581. **
  582. ** @function esp_ble_gatts_app_unregister
  583. **
  584. ** @brief un-register with GATT Server.
  585. **
  586. ** @param[in] server_if: service interface id.
  587. **
  588. ** @return None
  589. **
  590. *******************************************************************************/
  591. void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if);
  592. /*******************************************************************************
  593. **
  594. ** @function esp_ble_gatts_create_srvc
  595. **
  596. ** @brief Create a service. When service creation is done, a callback
  597. ** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
  598. ** and service ID to the profile. The service ID obtained in
  599. ** the callback function needs to be used when adding included
  600. ** service and characteristics/descriptors into the service.
  601. **
  602. ** @param[in] server_if: Profile ID this service is belonged to.
  603. ** @param[in] service_uuid: service UUID.
  604. ** @param[in] inst: instance ID number of this service.
  605. ** @param[in] num_handle: numble of handle requessted for this service.
  606. ** @param[in] is_primary: is this service a primary one or not.
  607. **
  608. ** @return None
  609. **
  610. *******************************************************************************/
  611. void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst,
  612. uint16_t num_handle, BOOLEAN is_primary);
  613. /*******************************************************************************
  614. **
  615. ** @function esp_ble_gatts_add_inclu_srvc
  616. **
  617. ** @brief This function is called to add an included service. After included
  618. ** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
  619. ** is reported the included service ID.
  620. **
  621. ** @param[in] service_id: service ID to which this included service is to
  622. ** be added.
  623. ** @param[in] included_service_id: the service ID to be included.
  624. **
  625. ** @return None
  626. **
  627. *******************************************************************************/
  628. void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id);
  629. /*******************************************************************************
  630. **
  631. ** @function esp_ble_gatts_add_char
  632. **
  633. ** @brief This function is called to add a characteristic into a service.
  634. **
  635. ** @param[in] service_id: service ID to which this included service is to
  636. ** be added.
  637. ** @param[in] char_uuid : Characteristic UUID.
  638. ** @param[in] perm : Characteristic value declaration attribute permission.
  639. ** @param[in] property : Characteristic Properties
  640. **
  641. ** @return None
  642. **
  643. *******************************************************************************/
  644. void esp_ble_gatts_add_char (uint16_t service_id, esp_bt_uuid_t *char_uuid,
  645. esp_gatt_perm_t perm, esp_gatt_char_prop_t property);
  646. /*******************************************************************************
  647. **
  648. ** @function esp_ble_gatts_add_char_descr
  649. **
  650. ** @brief This function is called to add characteristic descriptor. When
  651. ** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
  652. ** to report the status and an ID number for this descriptor.
  653. **
  654. ** @param[in] service_id: service ID to which this charatceristic descriptor is to
  655. ** be added.
  656. ** @param[in] perm: descriptor access permission.
  657. ** @param[in] descr_uuid: descriptor UUID.
  658. **
  659. ** @return None
  660. **
  661. *******************************************************************************/
  662. void esp_ble_gatts_add_char_descr (uint16_t service_id,
  663. esp_gatt_perm_t perm,
  664. esp_bt_uuid_t * descr_uuid);
  665. /*******************************************************************************
  666. **
  667. ** @function esp_ble_gatts_dele_srvc
  668. **
  669. ** @brief This function is called to delete a service. When this is done,
  670. ** a callback event BTA_GATTS_DELETE_EVT is report with the status.
  671. **
  672. ** @param[in] service_id: service_id to be deleted.
  673. **
  674. ** @return None
  675. **
  676. *******************************************************************************/
  677. void esp_ble_gatts_dele_srvc (uint16_t service_id);
  678. /*******************************************************************************
  679. **
  680. ** @function esp_ble_gatts_start_srvc
  681. **
  682. ** @brief This function is called to start a service.
  683. **
  684. ** @param[in] service_id: the service ID to be started.
  685. ** @param[in] sup_transport: supported trasnport.
  686. **
  687. ** @return None
  688. **
  689. *******************************************************************************/
  690. void esp_ble_gatts_start_srvc(uint16_t service_id);
  691. /*******************************************************************************
  692. **
  693. ** @function esp_ble_gatts_stop_srvc
  694. **
  695. ** @brief This function is called to stop a service.
  696. **
  697. ** @param[in] service_id - service to be topped.
  698. **
  699. ** @return None
  700. **
  701. *******************************************************************************/
  702. void esp_ble_gatts_stop_srvc(uint16_t service_id);
  703. /*******************************************************************************
  704. **
  705. ** @function esp_ble_gatts_hdl_val_indica
  706. **
  707. ** @brief This function is called to read a characteristics descriptor.
  708. **
  709. ** @param[in] bda - remote device bd address to indicate.
  710. ** @param[in] attr_id - attribute ID to indicate.
  711. ** @param[in] data_len - indicate data length.
  712. ** @param[in] data: data to indicate.
  713. ** @param[in] need_confirm - if this indication expects a confirmation or not.
  714. **
  715. ** @return None
  716. **
  717. *******************************************************************************/
  718. void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len,
  719. uint8_t *data, BOOLEAN need_confirm);
  720. /*******************************************************************************
  721. **
  722. ** @function esp_ble_gatts_send_rsp
  723. **
  724. ** @brief This function is called to send a response to a request.
  725. **
  726. ** @param[in] conn_id - connection identifier.
  727. ** @param[in] trans_id - transaction ID.
  728. ** @param[in] status - response status
  729. ** @param[in] msg - response data.
  730. **
  731. ** @return None
  732. **
  733. *******************************************************************************/
  734. void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id,
  735. esp_gatt_status_t status, esp_gatts_rsp_t *msg);
  736. /*******************************************************************************
  737. **
  738. ** @function esp_ble_gatts_conn
  739. **
  740. ** @brief Open a direct open connection or add a background auto connection
  741. ** bd address
  742. **
  743. ** @param[in] server_if: server interface.
  744. ** @param[in] remote_bda: remote device BD address.
  745. ** @param[in] is_direct: direct connection or background auto connection
  746. **
  747. ** @return None
  748. **
  749. *******************************************************************************/
  750. void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
  751. /*******************************************************************************
  752. **
  753. ** @function esp_ble_gatts_cancel_conn
  754. **
  755. ** @brief Cancel a direct open connection or remove a background auto connection
  756. ** bd address
  757. **
  758. ** @param[in] server_if: server interface.
  759. ** @param[in] remote_bda: remote device BD address.
  760. ** @param[in] is_direct: direct connection or background auto connection
  761. **
  762. ** @return None
  763. **
  764. *******************************************************************************/
  765. void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
  766. /*******************************************************************************
  767. **
  768. ** @function esp_ble_gatts_close
  769. **
  770. ** @brief Close a connection a remote device.
  771. **
  772. ** @param[in] conn_id: connectino ID to be closed.
  773. **
  774. ** @return None
  775. **
  776. *******************************************************************************/
  777. void esp_ble_gatts_close(uint16_t conn_id);
  778. /*******************************************************************************
  779. **
  780. ** @function esp_prf_app_register
  781. **
  782. ** @brief This function is called to register application callbacks
  783. ** with BTA GATTS module.
  784. **
  785. ** @param[in] prf_id - the profile identification
  786. ** @param[in] p_cback - pointer to the application callback function.
  787. **
  788. ** @return None
  789. **
  790. *******************************************************************************/
  791. void esp_prf_app_register(uint8_t prf_id, void *p_cback);