esp_gatts_api.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_GATTS_API_H__
  14. #define __ESP_GATTS_API_H__
  15. #include "esp_bt_defs.h"
  16. #include "esp_gatt_defs.h"
  17. #include "esp_err.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /// GATT Server callback function events
  22. typedef enum {
  23. ESP_GATTS_REG_EVT = 0, /*!< When register application id, the event comes */
  24. ESP_GATTS_READ_EVT = 1, /*!< When gatt client request read operation, the event comes */
  25. ESP_GATTS_WRITE_EVT = 2, /*!< When gatt client request write operation, the event comes */
  26. ESP_GATTS_EXEC_WRITE_EVT = 3, /*!< When gatt client request execute write, the event comes */
  27. ESP_GATTS_MTU_EVT = 4, /*!< When set mtu complete, the event comes */
  28. ESP_GATTS_CONF_EVT = 5, /*!< When receive confirm, the event comes */
  29. ESP_GATTS_UNREG_EVT = 6, /*!< When unregister application id, the event comes */
  30. ESP_GATTS_CREATE_EVT = 7, /*!< When create service complete, the event comes */
  31. ESP_GATTS_ADD_INCL_SRVC_EVT = 8, /*!< When add included service complete, the event comes */
  32. ESP_GATTS_ADD_CHAR_EVT = 9, /*!< When add characteristic complete, the event comes */
  33. ESP_GATTS_ADD_CHAR_DESCR_EVT = 10, /*!< When add descriptor complete, the event comes */
  34. ESP_GATTS_DELETE_EVT = 11, /*!< When delete service complete, the event comes */
  35. ESP_GATTS_START_EVT = 12, /*!< When start service complete, the event comes */
  36. ESP_GATTS_STOP_EVT = 13, /*!< When stop service complete, the event comes */
  37. ESP_GATTS_CONNECT_EVT = 14, /*!< When gatt client connect, the event comes */
  38. ESP_GATTS_DISCONNECT_EVT = 15, /*!< When gatt client disconnect, the event comes */
  39. ESP_GATTS_OPEN_EVT = 16, /*!< When connect to peer, the event comes */
  40. ESP_GATTS_CANCEL_OPEN_EVT = 17, /*!< When disconnect from peer, the event comes */
  41. ESP_GATTS_CLOSE_EVT = 18, /*!< When gatt server close, the event comes */
  42. ESP_GATTS_LISTEN_EVT = 19, /*!< When gatt listen to be connected the event comes */
  43. ESP_GATTS_CONGEST_EVT = 20, /*!< When congest happen, the event comes */
  44. /* following is extra event */
  45. ESP_GATTS_RESPONSE_EVT = 21, /*!< When gatt send response complete, the event comes */
  46. ESP_GATTS_CREAT_ATTR_TAB_EVT = 22,
  47. ESP_GATTS_SET_ATTR_VAL_EVT = 23,
  48. } esp_gatts_cb_event_t;
  49. /**
  50. * @brief Gatt server callback parameters union
  51. */
  52. typedef union {
  53. /**
  54. * @brief ESP_GATTS_REG_EVT
  55. */
  56. struct gatts_reg_evt_param {
  57. esp_gatt_status_t status; /*!< Operation status */
  58. uint16_t app_id; /*!< Application id which input in register API */
  59. } reg; /*!< Gatt server callback param of ESP_GATTS_REG_EVT */
  60. /**
  61. * @brief ESP_GATTS_READ_EVT
  62. */
  63. struct gatts_read_evt_param {
  64. uint16_t conn_id; /*!< Connection id */
  65. uint32_t trans_id; /*!< Transfer id */
  66. esp_bd_addr_t bda; /*!< The bluetooth device address which been read */
  67. uint16_t handle; /*!< The attribute handle */
  68. uint16_t offset; /*!< Offset of the value, if the value is too long */
  69. bool is_long; /*!< The value is too long or not */
  70. bool need_rsp; /*!< The read operation need to do response */
  71. } read; /*!< Gatt server callback param of ESP_GATTS_READ_EVT */
  72. /**
  73. * @brief ESP_GATTS_WRITE_EVT
  74. */
  75. struct gatts_write_evt_param {
  76. uint16_t conn_id; /*!< Connection id */
  77. uint32_t trans_id; /*!< Transfer id */
  78. esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
  79. uint16_t handle; /*!< The attribute handle */
  80. uint16_t offset; /*!< Offset of the value, if the value is too long */
  81. bool need_rsp; /*!< The write operation need to do response */
  82. bool is_prep; /*!< This write operation is prepare write */
  83. uint16_t len; /*!< The write attribute value length */
  84. uint8_t *value; /*!< The write attribute value */
  85. } write; /*!< Gatt server callback param of ESP_GATTS_WRITE_EVT */
  86. /**
  87. * @brief ESP_GATTS_EXEC_WRITE_EVT
  88. */
  89. struct gatts_exec_write_evt_param {
  90. uint16_t conn_id; /*!< Connection id */
  91. uint32_t trans_id; /*!< Transfer id */
  92. esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
  93. #define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Prepare write flag to indicate cancel prepare write */
  94. #define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Prepare write flag to indicate execute prepare write */
  95. uint8_t exec_write_flag; /*!< Execute write flag */
  96. } exec_write; /*!< Gatt server callback param of ESP_GATTS_EXEC_WRITE_EVT */
  97. /**
  98. * @brief ESP_GATTS_MTU_EVT
  99. */
  100. struct gatts_mtu_evt_param {
  101. uint16_t conn_id; /*!< Connection id */
  102. uint16_t mtu; /*!< MTU size */
  103. } mtu; /*!< Gatt server callback param of ESP_GATTS_MTU_EVT */
  104. /**
  105. * @brief ESP_GATTS_CONF_EVT
  106. */
  107. struct gatts_conf_evt_param {
  108. esp_gatt_status_t status; /*!< Operation status */
  109. uint16_t conn_id; /*!< Connection id */
  110. uint16_t len; /*!< The indication or notification value length, len is valid when send notification or indication failed */
  111. uint8_t *value; /*!< The indication or notification value , value is valid when send notification or indication failed */
  112. } conf; /*!< Gatt server callback param of ESP_GATTS_CONF_EVT (confirm) */
  113. /**
  114. * @brief ESP_GATTS_UNREG_EVT
  115. */
  116. /**
  117. * @brief ESP_GATTS_CREATE_EVT
  118. */
  119. struct gatts_create_evt_param {
  120. esp_gatt_status_t status; /*!< Operation status */
  121. uint16_t service_handle; /*!< Service attribute handle */
  122. esp_gatt_srvc_id_t service_id; /*!< Service id, include service uuid and other information */
  123. } create; /*!< Gatt server callback param of ESP_GATTS_CREATE_EVT */
  124. /**
  125. * @brief ESP_GATTS_ADD_INCL_SRVC_EVT
  126. */
  127. struct gatts_add_incl_srvc_evt_param {
  128. esp_gatt_status_t status; /*!< Operation status */
  129. uint16_t attr_handle; /*!< Included service attribute handle */
  130. uint16_t service_handle; /*!< Service attribute handle */
  131. } add_incl_srvc; /*!< Gatt server callback param of ESP_GATTS_ADD_INCL_SRVC_EVT */
  132. /**
  133. * @brief ESP_GATTS_ADD_CHAR_EVT
  134. */
  135. struct gatts_add_char_evt_param {
  136. esp_gatt_status_t status; /*!< Operation status */
  137. uint16_t attr_handle; /*!< Characteristic attribute handle */
  138. uint16_t service_handle; /*!< Service attribute handle */
  139. esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
  140. } add_char; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_EVT */
  141. /**
  142. * @brief ESP_GATTS_ADD_CHAR_DESCR_EVT
  143. */
  144. struct gatts_add_char_descr_evt_param {
  145. esp_gatt_status_t status; /*!< Operation status */
  146. uint16_t attr_handle; /*!< Descriptor attribute handle */
  147. uint16_t service_handle; /*!< Service attribute handle */
  148. esp_bt_uuid_t descr_uuid; /*!< Characteristic descriptor uuid */
  149. } add_char_descr; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */
  150. /**
  151. * @brief ESP_GATTS_DELETE_EVT
  152. */
  153. struct gatts_delete_evt_param {
  154. esp_gatt_status_t status; /*!< Operation status */
  155. uint16_t service_handle; /*!< Service attribute handle */
  156. } del; /*!< Gatt server callback param of ESP_GATTS_DELETE_EVT */
  157. /**
  158. * @brief ESP_GATTS_START_EVT
  159. */
  160. struct gatts_start_evt_param {
  161. esp_gatt_status_t status; /*!< Operation status */
  162. uint16_t service_handle; /*!< Service attribute handle */
  163. } start; /*!< Gatt server callback param of ESP_GATTS_START_EVT */
  164. /**
  165. * @brief ESP_GATTS_STOP_EVT
  166. */
  167. struct gatts_stop_evt_param {
  168. esp_gatt_status_t status; /*!< Operation status */
  169. uint16_t service_handle; /*!< Service attribute handle */
  170. } stop; /*!< Gatt server callback param of ESP_GATTS_STOP_EVT */
  171. /**
  172. * @brief ESP_GATTS_CONNECT_EVT
  173. */
  174. struct gatts_connect_evt_param {
  175. uint16_t conn_id; /*!< Connection id */
  176. esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
  177. } connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
  178. /**
  179. * @brief ESP_GATTS_DISCONNECT_EVT
  180. */
  181. struct gatts_disconnect_evt_param {
  182. uint16_t conn_id; /*!< Connection id */
  183. esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
  184. esp_gatt_conn_reason_t reason; /*!< Indicate the reason of disconnection */
  185. } disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */
  186. /**
  187. * @brief ESP_GATTS_OPEN_EVT
  188. */
  189. struct gatts_open_evt_param {
  190. esp_gatt_status_t status; /*!< Operation status */
  191. } open; /*!< Gatt server callback param of ESP_GATTS_OPEN_EVT */
  192. /**
  193. * @brief ESP_GATTS_CANCEL_OPEN_EVT
  194. */
  195. struct gatts_cancel_open_evt_param {
  196. esp_gatt_status_t status; /*!< Operation status */
  197. } cancel_open; /*!< Gatt server callback param of ESP_GATTS_CANCEL_OPEN_EVT */
  198. /**
  199. * @brief ESP_GATTS_CLOSE_EVT
  200. */
  201. struct gatts_close_evt_param {
  202. esp_gatt_status_t status; /*!< Operation status */
  203. uint16_t conn_id; /*!< Connection id */
  204. } close; /*!< Gatt server callback param of ESP_GATTS_CLOSE_EVT */
  205. /**
  206. * @brief ESP_GATTS_LISTEN_EVT
  207. */
  208. /**
  209. * @brief ESP_GATTS_CONGEST_EVT
  210. */
  211. struct gatts_congest_evt_param {
  212. uint16_t conn_id; /*!< Connection id */
  213. bool congested; /*!< Congested or not */
  214. } congest; /*!< Gatt server callback param of ESP_GATTS_CONGEST_EVT */
  215. /**
  216. * @brief ESP_GATTS_RESPONSE_EVT
  217. */
  218. struct gatts_rsp_evt_param {
  219. esp_gatt_status_t status; /*!< Operation status */
  220. uint16_t handle; /*!< Attribute handle which send response */
  221. } rsp; /*!< Gatt server callback param of ESP_GATTS_RESPONSE_EVT */
  222. /**
  223. * @brief ESP_GATTS_CREAT_ATTR_TAB_EVT
  224. */
  225. struct gatts_add_attr_tab_evt_param{
  226. esp_gatt_status_t status; /*!< Operation status */
  227. esp_bt_uuid_t svc_uuid; /*!< Service uuid type */
  228. uint16_t num_handle; /*!< The number of the attribute handle to be added to the gatts database */
  229. uint16_t *handles; /*!< The number to the handles */
  230. } add_attr_tab; /*!< Gatt server callback param of ESP_GATTS_CREAT_ATTR_TAB_EVT */
  231. /**
  232. * @brief ESP_GATTS_SET_ATTR_VAL_EVT
  233. */
  234. struct gatts_set_attr_val_evt_param{
  235. uint16_t srvc_handle; /*!< The service handle */
  236. uint16_t attr_handle; /*!< The attribute handle */
  237. esp_gatt_status_t status; /*!< Operation status*/
  238. } set_attr_val; /*!< Gatt server callback param of ESP_GATTS_SET_ATTR_VAL_EVT */
  239. } esp_ble_gatts_cb_param_t;
  240. /**
  241. * @brief GATT Server callback function type
  242. * @param event : Event type
  243. * @param gatts_if : GATT server access interface, normally
  244. * different gatts_if correspond to different profile
  245. * @param param : Point to callback parameter, currently is union type
  246. */
  247. typedef void (* esp_gatts_cb_t)(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
  248. /**
  249. * @brief This function is called to register application callbacks
  250. * with BTA GATTS module.
  251. *
  252. * @return
  253. * - ESP_OK : success
  254. * - other : failed
  255. *
  256. */
  257. esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback);
  258. /**
  259. * @brief This function is called to register application identifier
  260. *
  261. * @return
  262. * - ESP_OK : success
  263. * - other : failed
  264. *
  265. */
  266. esp_err_t esp_ble_gatts_app_register(uint16_t app_id);
  267. /**
  268. * @brief unregister with GATT Server.
  269. *
  270. * @param[in] gatts_if: GATT server access interface
  271. * @return
  272. * - ESP_OK : success
  273. * - other : failed
  274. *
  275. */
  276. esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if);
  277. /**
  278. * @brief Create a service. When service creation is done, a callback
  279. * event BTA_GATTS_CREATE_SRVC_EVT is called to report status
  280. * and service ID to the profile. The service ID obtained in
  281. * the callback function needs to be used when adding included
  282. * service and characteristics/descriptors into the service.
  283. *
  284. * @param[in] gatts_if: GATT server access interface
  285. * @param[in] service_id: service ID.
  286. * @param[in] num_handle: number of handle requested for this service.
  287. *
  288. * @return
  289. * - ESP_OK : success
  290. * - other : failed
  291. *
  292. */
  293. esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
  294. esp_gatt_srvc_id_t *service_id, uint16_t num_handle);
  295. /**
  296. * @brief Create a service attribute tab.
  297. * @param[in] gatts_attr_db: the pointer to the service attr tab
  298. * @param[in] gatts_if: GATT server access interface
  299. * @param[in] max_nb_attr: the number of attribute to be added to the service database.
  300. * @param[in] srvc_inst_id: the instance id of the service
  301. *
  302. * @return
  303. * - ESP_OK : success
  304. * - other : failed
  305. *
  306. */
  307. esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
  308. esp_gatt_if_t gatts_if,
  309. uint8_t max_nb_attr,
  310. uint8_t srvc_inst_id);
  311. /**
  312. * @brief This function is called to add an included service. After included
  313. * service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
  314. * is reported the included service ID.
  315. *
  316. * @param[in] service_handle: service handle to which this included service is to
  317. * be added.
  318. * @param[in] included_service_handle: the service ID to be included.
  319. *
  320. * @return
  321. * - ESP_OK : success
  322. * - other : failed
  323. *
  324. */
  325. esp_err_t esp_ble_gatts_add_included_service(uint16_t service_handle, uint16_t included_service_handle);
  326. /**
  327. * @brief This function is called to add a characteristic into a service.
  328. *
  329. * @param[in] service_handle: service handle to which this included service is to
  330. * be added.
  331. * @param[in] char_uuid : Characteristic UUID.
  332. * @param[in] perm : Characteristic value declaration attribute permission.
  333. * @param[in] property : Characteristic Properties
  334. * @param[in] char_val : Characteristic value
  335. * @param[in] control : attribute response control byte
  336. *
  337. * @return
  338. * - ESP_OK : success
  339. * - other : failed
  340. *
  341. */
  342. esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid,
  343. esp_gatt_perm_t perm, esp_gatt_char_prop_t property, esp_attr_value_t *char_val,
  344. esp_attr_control_t *control);
  345. /**
  346. * @brief This function is called to add characteristic descriptor. When
  347. * it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
  348. * to report the status and an ID number for this descriptor.
  349. *
  350. * @param[in] service_handle: service handle to which this characteristic descriptor is to
  351. * be added.
  352. * @param[in] perm: descriptor access permission.
  353. * @param[in] descr_uuid: descriptor UUID.
  354. * @param[in] char_descr_val : Characteristic descriptor value
  355. * @param[in] control : attribute response control byte
  356. * @return
  357. * - ESP_OK : success
  358. * - other : failed
  359. *
  360. */
  361. esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
  362. esp_bt_uuid_t *descr_uuid,
  363. esp_gatt_perm_t perm, esp_attr_value_t *char_descr_val,
  364. esp_attr_control_t *control);
  365. /**
  366. * @brief This function is called to delete a service. When this is done,
  367. * a callback event BTA_GATTS_DELETE_EVT is report with the status.
  368. *
  369. * @param[in] service_handle: service_handle to be deleted.
  370. *
  371. * @return
  372. * - ESP_OK : success
  373. * - other : failed
  374. *
  375. */
  376. esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle);
  377. /**
  378. * @brief This function is called to start a service.
  379. *
  380. * @param[in] service_handle: the service handle to be started.
  381. *
  382. * @return
  383. * - ESP_OK : success
  384. * - other : failed
  385. *
  386. */
  387. esp_err_t esp_ble_gatts_start_service(uint16_t service_handle);
  388. /**
  389. * @brief This function is called to stop a service.
  390. *
  391. * @param[in] service_handle - service to be topped.
  392. *
  393. * @return
  394. * - ESP_OK : success
  395. * - other : failed
  396. *
  397. */
  398. esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
  399. /**
  400. * @brief Send indicate or notify to GATT client.
  401. * Set param need_confirm as false will send notification, otherwise indication.
  402. *
  403. * @param[in] gatts_if: GATT server access interface
  404. * @param[in] conn_id - connection id to indicate.
  405. * @param[in] attr_handle - attribute handle to indicate.
  406. * @param[in] value_len - indicate value length.
  407. * @param[in] value: value to indicate.
  408. * @param[in] need_confirm - Whether a confirmation is required.
  409. * false sends a GATT notification, true sends a GATT indication.
  410. *
  411. * @return
  412. * - ESP_OK : success
  413. * - other : failed
  414. *
  415. */
  416. esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,
  417. uint16_t value_len, uint8_t *value, bool need_confirm);
  418. /**
  419. * @brief This function is called to send a response to a request.
  420. *
  421. * @param[in] gatts_if: GATT server access interface
  422. * @param[in] conn_id - connection identifier.
  423. * @param[in] trans_id - transfer id
  424. * @param[in] status - response status
  425. * @param[in] rsp - response data.
  426. *
  427. * @return
  428. * - ESP_OK : success
  429. * - other : failed
  430. *
  431. */
  432. esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id, uint32_t trans_id,
  433. esp_gatt_status_t status, esp_gatt_rsp_t *rsp);
  434. /**
  435. * @brief This function is called to set the attribute value by the application
  436. *
  437. * @param[in] attr_handle: the attribute handle which to be set
  438. * @param[in] length: the value length
  439. * @param[in] value: the pointer to the attribute value
  440. *
  441. * @return
  442. * - ESP_OK : success
  443. * - other : failed
  444. *
  445. */
  446. esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, const uint8_t *value);
  447. /**
  448. * @brief Retrieve attribute value
  449. *
  450. * @param[in] attr_handle: Attribute handle.
  451. * @param[out] length: pointer to the attribute value length
  452. * @param[out] value: Pointer to attribute value payload, the value cannot be modified by user
  453. *
  454. * @return
  455. * - ESP_GATT_OK : success
  456. * - other : failed
  457. *
  458. */
  459. esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
  460. /**
  461. * @brief Open a direct open connection or add a background auto connection
  462. *
  463. * @param[in] gatts_if: GATT server access interface
  464. * @param[in] remote_bda: remote device bluetooth device address.
  465. * @param[in] is_direct: direct connection or background auto connection
  466. *
  467. * @return
  468. * - ESP_OK : success
  469. * - other : failed
  470. *
  471. */
  472. esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, bool is_direct);
  473. /**
  474. * @brief Close a connection a remote device.
  475. *
  476. * @param[in] gatts_if: GATT server access interface
  477. * @param[in] conn_id: connection ID to be closed.
  478. *
  479. * @return
  480. * - ESP_OK : success
  481. * - other : failed
  482. *
  483. */
  484. esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id);
  485. #ifdef __cplusplus
  486. }
  487. #endif
  488. #endif /* __ESP_GATTS_API_H__ */