gatt_api.h 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 1999-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. #ifndef GATT_API_H
  19. #define GATT_API_H
  20. #include "common/bt_target.h"
  21. #include "stack/gattdefs.h"
  22. #include "stack/btm_ble_api.h"
  23. /*****************************************************************************
  24. ** Constants
  25. *****************************************************************************/
  26. /* Success code and error codes */
  27. #define GATT_SUCCESS 0x00
  28. #define GATT_INVALID_HANDLE 0x01
  29. #define GATT_READ_NOT_PERMIT 0x02
  30. #define GATT_WRITE_NOT_PERMIT 0x03
  31. #define GATT_INVALID_PDU 0x04
  32. #define GATT_INSUF_AUTHENTICATION 0x05
  33. #define GATT_REQ_NOT_SUPPORTED 0x06
  34. #define GATT_INVALID_OFFSET 0x07
  35. #define GATT_INSUF_AUTHORIZATION 0x08
  36. #define GATT_PREPARE_Q_FULL 0x09
  37. #define GATT_NOT_FOUND 0x0a
  38. #define GATT_NOT_LONG 0x0b
  39. #define GATT_INSUF_KEY_SIZE 0x0c
  40. #define GATT_INVALID_ATTR_LEN 0x0d
  41. #define GATT_ERR_UNLIKELY 0x0e
  42. #define GATT_INSUF_ENCRYPTION 0x0f
  43. #define GATT_UNSUPPORT_GRP_TYPE 0x10
  44. #define GATT_INSUF_RESOURCE 0x11
  45. #define GATT_NO_RESOURCES 0x80
  46. #define GATT_INTERNAL_ERROR 0x81
  47. #define GATT_WRONG_STATE 0x82
  48. #define GATT_DB_FULL 0x83
  49. #define GATT_BUSY 0x84
  50. #define GATT_ERROR 0x85
  51. #define GATT_CMD_STARTED 0x86
  52. #define GATT_ILLEGAL_PARAMETER 0x87
  53. #define GATT_PENDING 0x88
  54. #define GATT_AUTH_FAIL 0x89
  55. #define GATT_MORE 0x8a
  56. #define GATT_INVALID_CFG 0x8b
  57. #define GATT_SERVICE_STARTED 0x8c
  58. #define GATT_ENCRYPED_MITM GATT_SUCCESS
  59. #define GATT_ENCRYPED_NO_MITM 0x8d
  60. #define GATT_NOT_ENCRYPTED 0x8e
  61. #define GATT_CONGESTED 0x8f
  62. #define GATT_DUP_REG 0x90
  63. #define GATT_ALREADY_OPEN 0x91
  64. #define GATT_CANCEL 0x92
  65. /* 0xE0 ~ 0xFC reserved for future use */
  66. #define GATT_STACK_RSP 0xE0
  67. #define GATT_APP_RSP 0xE1
  68. //Error caused by customer application or stack bug
  69. #define GATT_UNKNOWN_ERROR 0XEF
  70. #define GATT_CCC_CFG_ERR 0xFD /* Client Characteristic Configuration Descriptor Improperly Configured */
  71. #define GATT_PRC_IN_PROGRESS 0xFE /* Procedure Already in progress */
  72. #define GATT_OUT_OF_RANGE 0xFF /* Attribute value out of range */
  73. typedef UINT8 tGATT_STATUS;
  74. #define GATT_RSP_ERROR 0x01
  75. #define GATT_REQ_MTU 0x02
  76. #define GATT_RSP_MTU 0x03
  77. #define GATT_REQ_FIND_INFO 0x04
  78. #define GATT_RSP_FIND_INFO 0x05
  79. #define GATT_REQ_FIND_TYPE_VALUE 0x06
  80. #define GATT_RSP_FIND_TYPE_VALUE 0x07
  81. #define GATT_REQ_READ_BY_TYPE 0x08
  82. #define GATT_RSP_READ_BY_TYPE 0x09
  83. #define GATT_REQ_READ 0x0A
  84. #define GATT_RSP_READ 0x0B
  85. #define GATT_REQ_READ_BLOB 0x0C
  86. #define GATT_RSP_READ_BLOB 0x0D
  87. #define GATT_REQ_READ_MULTI 0x0E
  88. #define GATT_RSP_READ_MULTI 0x0F
  89. #define GATT_REQ_READ_BY_GRP_TYPE 0x10
  90. #define GATT_RSP_READ_BY_GRP_TYPE 0x11
  91. #define GATT_REQ_WRITE 0x12 /* 0001-0010 (write)*/
  92. #define GATT_RSP_WRITE 0x13
  93. #define GATT_CMD_WRITE 0x52 /* changed in V4.0 01001-0010(write cmd)*/
  94. #define GATT_REQ_PREPARE_WRITE 0x16
  95. #define GATT_RSP_PREPARE_WRITE 0x17
  96. #define GATT_REQ_EXEC_WRITE 0x18
  97. #define GATT_RSP_EXEC_WRITE 0x19
  98. #define GATT_HANDLE_VALUE_NOTIF 0x1B
  99. #define GATT_HANDLE_VALUE_IND 0x1D
  100. #define GATT_HANDLE_VALUE_CONF 0x1E
  101. #define GATT_SIGN_CMD_WRITE 0xD2 /* changed in V4.0 1101-0010 (signed write) see write cmd above*/
  102. #define GATT_OP_CODE_MAX GATT_HANDLE_VALUE_CONF + 1 /* 0x1E = 30 + 1 = 31*/
  103. #define GATT_COMMAND_FLAG 0x40 /* Command Flag: set to one means commond */
  104. #define GATT_HANDLE_IS_VALID(x) ((x) != 0)
  105. #define GATT_CONN_UNKNOWN 0
  106. #define GATT_CONN_L2C_FAILURE 1 /* general L2cap failure */
  107. #define GATT_CONN_TIMEOUT HCI_ERR_CONNECTION_TOUT /* 0x08 connection timeout */
  108. #define GATT_CONN_TERMINATE_PEER_USER HCI_ERR_PEER_USER /* 0x13 connection terminate by peer user */
  109. #define GATT_CONN_TERMINATE_LOCAL_HOST HCI_ERR_CONN_CAUSE_LOCAL_HOST /* 0x16 connectionterminated by local host */
  110. #define GATT_CONN_FAIL_ESTABLISH HCI_ERR_CONN_FAILED_ESTABLISHMENT/* 0x03E connection fail to establish */
  111. #define GATT_CONN_LMP_TIMEOUT HCI_ERR_LMP_RESPONSE_TIMEOUT /* 0x22 connection fail for LMP response tout */
  112. #define GATT_CONN_CANCEL L2CAP_CONN_CANCEL /* 0x0100 L2CAP connection cancelled */
  113. typedef UINT16 tGATT_DISCONN_REASON;
  114. /* MAX GATT MTU size
  115. */
  116. #ifndef GATT_MAX_MTU_SIZE
  117. #define GATT_MAX_MTU_SIZE 517
  118. #endif
  119. /* max legth of an attribute value
  120. */
  121. #ifndef GATT_MAX_ATTR_LEN
  122. #define GATT_MAX_ATTR_LEN 600
  123. #endif
  124. /* default GATT MTU size over LE link
  125. */
  126. #define GATT_DEF_BLE_MTU_SIZE 23
  127. /* invalid connection ID
  128. */
  129. #define GATT_INVALID_CONN_ID 0xFFFF
  130. #ifndef GATT_CL_MAX_LCB
  131. #define GATT_CL_MAX_LCB 12 // 22
  132. #endif
  133. #ifndef GATT_MAX_SCCB
  134. #define GATT_MAX_SCCB 10
  135. #endif
  136. /* GATT notification caching timer, default to be three seconds
  137. */
  138. #ifndef GATTC_NOTIF_TIMEOUT
  139. #define GATTC_NOTIF_TIMEOUT 3
  140. #endif
  141. /*****************************************************************************
  142. ** GATT Structure Definition
  143. *****************************************************************************/
  144. /* Attribute permissions
  145. */
  146. #define GATT_PERM_READ (1 << 0) /* bit 0 */
  147. #define GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 */
  148. #define GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 */
  149. #define GATT_PERM_WRITE (1 << 4) /* bit 4 */
  150. #define GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 */
  151. #define GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 */
  152. #define GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 */
  153. #define GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 */
  154. typedef UINT16 tGATT_PERM;
  155. #define GATT_ENCRYPT_KEY_SIZE_MASK (0xF000) /* the MS nibble of tGATT_PERM; key size 7=0; size 16=9 */
  156. #define GATT_READ_ALLOWED (GATT_PERM_READ | GATT_PERM_READ_ENCRYPTED | GATT_PERM_READ_ENC_MITM)
  157. #define GATT_READ_AUTH_REQUIRED (GATT_PERM_READ_ENCRYPTED)
  158. #define GATT_READ_MITM_REQUIRED (GATT_PERM_READ_ENC_MITM)
  159. #define GATT_READ_ENCRYPTED_REQUIRED (GATT_PERM_READ_ENCRYPTED | GATT_PERM_READ_ENC_MITM)
  160. #define GATT_WRITE_ALLOWED (GATT_PERM_WRITE | GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM | \
  161. GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM)
  162. #define GATT_WRITE_AUTH_REQUIRED (GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_SIGNED)
  163. #define GATT_WRITE_MITM_REQUIRED (GATT_PERM_WRITE_ENC_MITM | GATT_PERM_WRITE_SIGNED_MITM)
  164. #define GATT_WRITE_ENCRYPTED_PERM (GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM)
  165. #define GATT_WRITE_SIGNED_PERM (GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM)
  166. /* Characteristic properties
  167. */
  168. #define GATT_CHAR_PROP_BIT_BROADCAST (1 << 0)
  169. #define GATT_CHAR_PROP_BIT_READ (1 << 1)
  170. #define GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2)
  171. #define GATT_CHAR_PROP_BIT_WRITE (1 << 3)
  172. #define GATT_CHAR_PROP_BIT_NOTIFY (1 << 4)
  173. #define GATT_CHAR_PROP_BIT_INDICATE (1 << 5)
  174. #define GATT_CHAR_PROP_BIT_AUTH (1 << 6)
  175. #define GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7)
  176. typedef UINT8 tGATT_CHAR_PROP;
  177. /* Format of the value of a characteristic. enumeration type
  178. */
  179. enum {
  180. GATT_FORMAT_RES, /* rfu */
  181. GATT_FORMAT_BOOL, /* 0x01 boolean */
  182. GATT_FORMAT_2BITS, /* 0x02 2 bit */
  183. GATT_FORMAT_NIBBLE, /* 0x03 nibble */
  184. GATT_FORMAT_UINT8, /* 0x04 uint8 */
  185. GATT_FORMAT_UINT12, /* 0x05 uint12 */
  186. GATT_FORMAT_UINT16, /* 0x06 uint16 */
  187. GATT_FORMAT_UINT24, /* 0x07 uint24 */
  188. GATT_FORMAT_UINT32, /* 0x08 uint32 */
  189. GATT_FORMAT_UINT48, /* 0x09 uint48 */
  190. GATT_FORMAT_UINT64, /* 0x0a uint64 */
  191. GATT_FORMAT_UINT128, /* 0x0B uint128 */
  192. GATT_FORMAT_SINT8, /* 0x0C signed 8 bit integer */
  193. GATT_FORMAT_SINT12, /* 0x0D signed 12 bit integer */
  194. GATT_FORMAT_SINT16, /* 0x0E signed 16 bit integer */
  195. GATT_FORMAT_SINT24, /* 0x0F signed 24 bit integer */
  196. GATT_FORMAT_SINT32, /* 0x10 signed 32 bit integer */
  197. GATT_FORMAT_SINT48, /* 0x11 signed 48 bit integer */
  198. GATT_FORMAT_SINT64, /* 0x12 signed 64 bit integer */
  199. GATT_FORMAT_SINT128, /* 0x13 signed 128 bit integer */
  200. GATT_FORMAT_FLOAT32, /* 0x14 float 32 */
  201. GATT_FORMAT_FLOAT64, /* 0x15 float 64*/
  202. GATT_FORMAT_SFLOAT, /* 0x16 IEEE-11073 16 bit SFLOAT */
  203. GATT_FORMAT_FLOAT, /* 0x17 IEEE-11073 32 bit SFLOAT */
  204. GATT_FORMAT_DUINT16, /* 0x18 IEEE-20601 format */
  205. GATT_FORMAT_UTF8S, /* 0x19 UTF-8 string */
  206. GATT_FORMAT_UTF16S, /* 0x1a UTF-16 string */
  207. GATT_FORMAT_STRUCT, /* 0x1b Opaque structure*/
  208. GATT_FORMAT_MAX /* 0x1c or above reserved */
  209. };
  210. typedef UINT8 tGATT_FORMAT;
  211. /* Characteristic Presentation Format Descriptor value
  212. */
  213. typedef struct {
  214. UINT16 unit; /* as UUIUD defined by SIG */
  215. UINT16 descr; /* as UUID as defined by SIG */
  216. tGATT_FORMAT format;
  217. INT8 exp;
  218. UINT8 name_spc; /* The name space of the description */
  219. } tGATT_CHAR_PRES;
  220. /* Characteristic Report reference Descriptor format
  221. */
  222. typedef struct {
  223. UINT8 rpt_id; /* report ID */
  224. UINT8 rpt_type; /* report type */
  225. } tGATT_CHAR_RPT_REF;
  226. #define GATT_VALID_RANGE_MAX_SIZE 16
  227. typedef struct {
  228. UINT8 format;
  229. UINT16 len;
  230. UINT8 lower_range[GATT_VALID_RANGE_MAX_SIZE]; /* in little endian format */
  231. UINT8 upper_range[GATT_VALID_RANGE_MAX_SIZE];
  232. } tGATT_VALID_RANGE;
  233. /* Characteristic Aggregate Format attribute value
  234. */
  235. #define GATT_AGGR_HANDLE_NUM_MAX 10
  236. typedef struct {
  237. UINT8 num_handle;
  238. UINT16 handle_list[GATT_AGGR_HANDLE_NUM_MAX];
  239. } tGATT_CHAR_AGGRE;
  240. /* Characteristic descriptor: Extended Properties value
  241. */
  242. #define GATT_CHAR_BIT_REL_WRITE 0x0001 /* permits reliable writes of the Characteristic Value */
  243. #define GATT_CHAR_BIT_WRITE_AUX 0x0002 /* permits writes to the characteristic descriptor */
  244. /* characteristic descriptor: client configuration value
  245. */
  246. #define GATT_CLT_CONFIG_NONE 0x0000
  247. #define GATT_CLT_CONFIG_NOTIFICATION 0x0001
  248. #define GATT_CLT_CONFIG_INDICATION 0x0002
  249. typedef UINT16 tGATT_CLT_CHAR_CONFIG;
  250. /* characteristic descriptor: server configuration value
  251. */
  252. #define GATT_SVR_CONFIG_NONE 0x0000
  253. #define GATT_SVR_CONFIG_BROADCAST 0x0001
  254. typedef UINT16 tGATT_SVR_CHAR_CONFIG;
  255. /* Characteristic descriptor: Extended Properties value
  256. */
  257. #define GATT_CHAR_BIT_REL_WRITE 0x0001 /* permits reliable writes of the Characteristic Value */
  258. #define GATT_CHAR_BIT_WRITE_AUX 0x0002 /* permits writes to the characteristic descriptor */
  259. /* authentication requirement
  260. */
  261. #define GATT_AUTH_REQ_NONE 0
  262. #define GATT_AUTH_REQ_NO_MITM 1 /* unauthenticated encryption */
  263. #define GATT_AUTH_REQ_MITM 2 /* authenticated encryption */
  264. #define GATT_AUTH_REQ_SIGNED_NO_MITM 3
  265. #define GATT_AUTH_REQ_SIGNED_MITM 4
  266. typedef UINT8 tGATT_AUTH_REQ;
  267. /* Attribute Value structure
  268. */
  269. typedef struct {
  270. UINT16 conn_id;
  271. UINT16 handle; /* attribute handle */
  272. UINT16 offset; /* attribute value offset, if no offfset is needed for the command, ignore it */
  273. UINT16 len; /* length of attribute value */
  274. tGATT_AUTH_REQ auth_req; /* authentication request */
  275. UINT8 value[GATT_MAX_ATTR_LEN]; /* the actual attribute value */
  276. } tGATT_VALUE;
  277. typedef struct{
  278. UINT16 attr_max_len;
  279. UINT16 attr_len;
  280. UINT8 *attr_val;
  281. }tGATT_ATTR_VAL;
  282. typedef struct{
  283. uint8_t auto_rsp;
  284. }tGATTS_ATTR_CONTROL;
  285. /* Mask for gatt server attribute */
  286. #define GATT_ATTR_VALUE_ALLOCATED 0x01
  287. typedef UINT8 tGATT_ATTR_MASK;
  288. /* Union of the event data which is used in the server respond API to carry the server response information
  289. */
  290. typedef union {
  291. /* data type member event */
  292. tGATT_VALUE attr_value; /* READ, HANDLE_VALUE_IND, PREPARE_WRITE */
  293. /* READ_BLOB, READ_BY_TYPE */
  294. UINT16 handle; /* WRITE, WRITE_BLOB */
  295. } tGATTS_RSP;
  296. /* Transports for the primary service */
  297. #define GATT_TRANSPORT_LE BT_TRANSPORT_LE
  298. #define GATT_TRANSPORT_BR_EDR BT_TRANSPORT_BR_EDR
  299. #define GATT_TRANSPORT_LE_BR_EDR (BT_TRANSPORT_LE|BT_TRANSPORT_BR_EDR)
  300. typedef UINT8 tGATT_TRANSPORT;
  301. #define GATT_PREP_WRITE_CANCEL 0x00
  302. #define GATT_PREP_WRITE_EXEC 0x01
  303. typedef UINT8 tGATT_EXEC_FLAG;
  304. /* read request always based on UUID */
  305. typedef struct {
  306. UINT16 handle;
  307. UINT16 offset;
  308. BOOLEAN is_long;
  309. BOOLEAN need_rsp;
  310. } tGATT_READ_REQ;
  311. /* write request data */
  312. typedef struct {
  313. UINT16 handle; /* attribute handle */
  314. UINT16 offset; /* attribute value offset, if no offfset is needed for the command, ignore it */
  315. UINT16 len; /* length of attribute value */
  316. UINT8 value[GATT_MAX_ATTR_LEN]; /* the actual attribute value */
  317. BOOLEAN need_rsp; /* need write response */
  318. BOOLEAN is_prep; /* is prepare write */
  319. } tGATT_WRITE_REQ;
  320. /* callback data for server access request from client */
  321. typedef union {
  322. tGATT_READ_REQ read_req; /* read request, read by Type, read blob */
  323. tGATT_WRITE_REQ write_req; /* write */
  324. /* prepare write */
  325. /* write blob */
  326. UINT16 handle; /* handle value confirmation */
  327. UINT16 mtu; /* MTU exchange request */
  328. tGATT_EXEC_FLAG exec_write; /* execute write */
  329. } tGATTS_DATA;
  330. typedef UINT8 tGATT_SERV_IF; /* GATT Service Interface */
  331. enum {
  332. GATTS_REQ_TYPE_READ = 1, /* Attribute read request */
  333. GATTS_REQ_TYPE_WRITE, /* Attribute write request */
  334. GATTS_REQ_TYPE_WRITE_EXEC, /* Execute write */
  335. GATTS_REQ_TYPE_MTU, /* MTU exchange information */
  336. GATTS_REQ_TYPE_CONF /* handle value confirmation */
  337. };
  338. typedef UINT8 tGATTS_REQ_TYPE;
  339. /* Client Used Data Structure
  340. */
  341. /* definition of different discovery types */
  342. enum {
  343. GATT_DISC_SRVC_ALL = 1, /* discover all services */
  344. GATT_DISC_SRVC_BY_UUID, /* discover service of a special type */
  345. GATT_DISC_INC_SRVC, /* discover the included service within a service */
  346. GATT_DISC_CHAR, /* discover characteristics of a service with/without type requirement */
  347. GATT_DISC_CHAR_DSCPT, /* discover characteristic descriptors of a character */
  348. GATT_DISC_MAX /* maximnun discover type */
  349. };
  350. typedef UINT8 tGATT_DISC_TYPE;
  351. /* Discover parameters of different discovery types
  352. */
  353. typedef struct {
  354. tBT_UUID service;
  355. UINT16 s_handle;
  356. UINT16 e_handle;
  357. } tGATT_DISC_PARAM;
  358. /* GATT read type enumeration
  359. */
  360. enum {
  361. GATT_READ_BY_TYPE = 1,
  362. GATT_READ_BY_HANDLE,
  363. GATT_READ_MULTIPLE,
  364. GATT_READ_CHAR_VALUE,
  365. GATT_READ_PARTIAL,
  366. GATT_READ_MAX
  367. };
  368. typedef UINT8 tGATT_READ_TYPE;
  369. /* Read By Type Request (GATT_READ_BY_TYPE) Data
  370. */
  371. typedef struct {
  372. tGATT_AUTH_REQ auth_req;
  373. UINT16 s_handle;
  374. UINT16 e_handle;
  375. tBT_UUID uuid;
  376. } tGATT_READ_BY_TYPE;
  377. /* GATT_READ_MULTIPLE request data
  378. */
  379. #define GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
  380. typedef struct {
  381. tGATT_AUTH_REQ auth_req;
  382. UINT16 num_handles; /* number of handles to read */
  383. UINT16 handles[GATT_MAX_READ_MULTI_HANDLES]; /* handles list to be read */
  384. } tGATT_READ_MULTI;
  385. /* Read By Handle Request (GATT_READ_BY_HANDLE) data */
  386. typedef struct {
  387. tGATT_AUTH_REQ auth_req;
  388. UINT16 handle;
  389. } tGATT_READ_BY_HANDLE;
  390. /* READ_BT_HANDLE_Request data */
  391. typedef struct {
  392. tGATT_AUTH_REQ auth_req;
  393. UINT16 handle;
  394. UINT16 offset;
  395. } tGATT_READ_PARTIAL;
  396. /* Read Request Data
  397. */
  398. typedef union {
  399. tGATT_READ_BY_TYPE service;
  400. tGATT_READ_BY_TYPE char_type; /* characterisitc type */
  401. tGATT_READ_MULTI read_multiple;
  402. tGATT_READ_BY_HANDLE by_handle;
  403. tGATT_READ_PARTIAL partial;
  404. } tGATT_READ_PARAM;
  405. /* GATT write type enumeration */
  406. enum {
  407. GATT_WRITE_NO_RSP = 1,
  408. GATT_WRITE ,
  409. GATT_WRITE_PREPARE
  410. };
  411. typedef UINT8 tGATT_WRITE_TYPE;
  412. /* Client Operation Complete Callback Data
  413. */
  414. typedef union {
  415. tGATT_VALUE att_value;
  416. UINT16 mtu;
  417. UINT16 handle;
  418. } tGATT_CL_COMPLETE;
  419. /* GATT client operation type, used in client callback function
  420. */
  421. #define GATTC_OPTYPE_NONE 0
  422. #define GATTC_OPTYPE_DISCOVERY 1
  423. #define GATTC_OPTYPE_READ 2
  424. #define GATTC_OPTYPE_WRITE 3
  425. #define GATTC_OPTYPE_EXE_WRITE 4
  426. #define GATTC_OPTYPE_CONFIG 5
  427. #define GATTC_OPTYPE_NOTIFICATION 6
  428. #define GATTC_OPTYPE_INDICATION 7
  429. typedef UINT8 tGATTC_OPTYPE;
  430. /* characteristic declaration
  431. */
  432. typedef struct {
  433. tGATT_CHAR_PROP char_prop; /* characterisitc properties */
  434. UINT16 val_handle; /* characteristic value attribute handle */
  435. tBT_UUID char_uuid; /* characteristic UUID type */
  436. } tGATT_CHAR_DCLR_VAL;
  437. /* primary service group data
  438. */
  439. typedef struct {
  440. UINT16 e_handle; /* ending handle of the group */
  441. tBT_UUID service_type; /* group type */
  442. } tGATT_GROUP_VALUE;
  443. /* included service attribute value
  444. */
  445. typedef struct {
  446. tBT_UUID service_type; /* included service UUID */
  447. UINT16 s_handle; /* starting handle */
  448. UINT16 e_handle; /* ending handle */
  449. } tGATT_INCL_SRVC;
  450. typedef union {
  451. tGATT_INCL_SRVC incl_service; /* include service value */
  452. tGATT_GROUP_VALUE group_value; /* Service UUID type.
  453. This field is used with GATT_DISC_SRVC_ALL
  454. or GATT_DISC_SRVC_BY_UUID
  455. type of discovery result callback. */
  456. UINT16 handle; /* When used with GATT_DISC_INC_SRVC type discovery result,
  457. it is the included service starting handle.*/
  458. tGATT_CHAR_DCLR_VAL dclr_value; /* Characteristic declaration value.
  459. This field is used with GATT_DISC_CHAR type discovery.*/
  460. } tGATT_DISC_VALUE;
  461. /* discover result record
  462. */
  463. typedef struct {
  464. tBT_UUID type;
  465. UINT16 handle;
  466. tGATT_DISC_VALUE value;
  467. } tGATT_DISC_RES;
  468. #define GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP 0 /* start a idle timer for this duration
  469. when no application need to use the link */
  470. #define GATT_LINK_NO_IDLE_TIMEOUT 0xFFFF
  471. #define GATT_INVALID_ACL_HANDLE 0xFFFF
  472. /* discover result callback function */
  473. typedef void (tGATT_DISC_RES_CB) (UINT16 conn_id, tGATT_DISC_TYPE disc_type,
  474. tGATT_DISC_RES *p_data);
  475. /* discover complete callback function */
  476. typedef void (tGATT_DISC_CMPL_CB) (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
  477. /* Define a callback function for when read/write/disc/config operation is completed. */
  478. typedef void (tGATT_CMPL_CBACK) (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
  479. tGATT_CL_COMPLETE *p_data);
  480. /* Define a callback function when an initialized connection is established. */
  481. typedef void (tGATT_CONN_CBACK) (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected,
  482. tGATT_DISCONN_REASON reason, tBT_TRANSPORT transport);
  483. /* attribute request callback for ATT server */
  484. typedef void (tGATT_REQ_CBACK )(UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
  485. tGATTS_DATA *p_data);
  486. /* channel congestion/uncongestion callback */
  487. typedef void (tGATT_CONGESTION_CBACK )(UINT16 conn_id, BOOLEAN congested);
  488. /* Define a callback function when encryption is established. */
  489. typedef void (tGATT_ENC_CMPL_CB)(tGATT_IF gatt_if, BD_ADDR bda);
  490. /* Define the structure that applications use to register with
  491. ** GATT. This structure includes callback functions. All functions
  492. ** MUST be provided.
  493. */
  494. typedef struct {
  495. tGATT_CONN_CBACK *p_conn_cb;
  496. tGATT_CMPL_CBACK *p_cmpl_cb;
  497. tGATT_DISC_RES_CB *p_disc_res_cb;
  498. tGATT_DISC_CMPL_CB *p_disc_cmpl_cb;
  499. tGATT_REQ_CBACK *p_req_cb;
  500. tGATT_ENC_CMPL_CB *p_enc_cmpl_cb;
  501. tGATT_CONGESTION_CBACK *p_congestion_cb;
  502. } tGATT_CBACK;
  503. /*********************** Start Handle Management Definitions **********************
  504. */
  505. typedef struct {
  506. tBT_UUID app_uuid128;
  507. tBT_UUID svc_uuid;
  508. UINT16 svc_inst;
  509. UINT16 s_handle;
  510. UINT16 e_handle;
  511. BOOLEAN is_primary; /* primary service or secondary */
  512. } tGATTS_HNDL_RANGE;
  513. #define GATTS_SRV_CHG_CMD_ADD_CLIENT 1
  514. #define GATTS_SRV_CHG_CMD_UPDATE_CLIENT 2
  515. #define GATTS_SRV_CHG_CMD_REMOVE_CLIENT 3
  516. #define GATTS_SRV_CHG_CMD_READ_NUM_CLENTS 4
  517. #define GATTS_SRV_CHG_CMD_READ_CLENT 5
  518. typedef UINT8 tGATTS_SRV_CHG_CMD;
  519. typedef struct {
  520. BD_ADDR bda;
  521. BOOLEAN srv_changed;
  522. } tGATTS_SRV_CHG;
  523. typedef union {
  524. tGATTS_SRV_CHG srv_chg;
  525. UINT8 client_read_index; /* only used for sequential reading client srv chg info */
  526. } tGATTS_SRV_CHG_REQ;
  527. typedef union {
  528. tGATTS_SRV_CHG srv_chg;
  529. UINT8 num_clients;
  530. } tGATTS_SRV_CHG_RSP;
  531. typedef struct {
  532. tGATTS_HNDL_RANGE *p_new_srv_start;
  533. } tGATTS_PENDING_NEW_SRV_START;
  534. /* Attibute server handle ranges NV storage callback functions
  535. */
  536. typedef void (tGATTS_NV_SAVE_CBACK)(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
  537. typedef BOOLEAN (tGATTS_NV_SRV_CHG_CBACK)(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
  538. tGATTS_SRV_CHG_RSP *p_rsp);
  539. typedef struct {
  540. tGATTS_NV_SAVE_CBACK *p_nv_save_callback;
  541. tGATTS_NV_SRV_CHG_CBACK *p_srv_chg_callback;
  542. } tGATT_APPL_INFO;
  543. /*
  544. *********************** End Handle Management Definitions **********************/
  545. /*****************************************************************************
  546. ** External Function Declarations
  547. *****************************************************************************/
  548. #ifdef __cplusplus
  549. extern "C"
  550. {
  551. #endif
  552. /*******************************************************************************
  553. **
  554. ** Function GATT_SetTraceLevel
  555. **
  556. ** Description This function sets the trace level. If called with
  557. ** a value of 0xFF, it simply returns the current trace level.
  558. **
  559. ** Returns The new or current trace level
  560. **
  561. *******************************************************************************/
  562. extern UINT8 GATT_SetTraceLevel (UINT8 new_level);
  563. /*******************************************************************************/
  564. /* GATT Profile API Functions */
  565. /*******************************************************************************/
  566. /* GATT Profile Server Functions */
  567. /*******************************************************************************/
  568. /*******************************************************************************
  569. **
  570. ** Function GATTS_AddHandleRange
  571. **
  572. ** Description This function add the allocated handles range for the specifed
  573. ** application UUID, service UUID and service instance
  574. **
  575. ** Parameter p_hndl_range: pointer to allocated handles information
  576. **
  577. ** Returns TRUE if handle range is added sucessfully; otherwise FALSE.
  578. **
  579. *******************************************************************************/
  580. extern BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range);
  581. /*******************************************************************************
  582. **
  583. ** Function GATTS_NVRegister
  584. **
  585. ** Description Application manager calls this function to register for
  586. ** NV save callback function. There can be one and only one
  587. ** NV save callback function.
  588. **
  589. ** Parameter p_cb_info : callback informaiton
  590. **
  591. ** Returns TRUE if registered OK, else FALSE
  592. **
  593. *******************************************************************************/
  594. extern BOOLEAN GATTS_NVRegister (tGATT_APPL_INFO *p_cb_info);
  595. /*******************************************************************************
  596. **
  597. ** Function GATTS_CreateService
  598. **
  599. ** Description This function is called to reserve a block of handles for a service.
  600. **
  601. ** *** It should be called only once per service instance ***
  602. **
  603. ** Parameter gatt_if : application if
  604. ** p_svc_uuid : service UUID
  605. ** svc_inst : instance of the service inside the application
  606. ** num_handles : number of handles needed by the service.
  607. ** is_pri : is a primary service or not.
  608. **
  609. ** Returns service handle if sucessful, otherwise 0.
  610. **
  611. *******************************************************************************/
  612. extern UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
  613. UINT16 svc_inst, UINT16 num_handles, BOOLEAN is_pri);
  614. /*******************************************************************************
  615. **
  616. ** Function GATTS_AddIncludeService
  617. **
  618. ** Description This function is called to add an included service.
  619. **
  620. ** Parameter service_handle : To which service this included service is added to.
  621. ** include_svc_handle : included service handle.
  622. **
  623. ** Returns included service attribute handle. If 0, add included service
  624. ** fail.
  625. **
  626. *******************************************************************************/
  627. extern UINT16 GATTS_AddIncludeService (UINT16 service_handle,
  628. UINT16 include_svc_handle);
  629. /*******************************************************************************
  630. **
  631. ** Function GATTS_AddCharacteristic
  632. **
  633. ** Description This function is called to add a characteristic into a service.
  634. ** It will add a characteristic declaration and characteristic
  635. ** value declaration into the service database identified by the
  636. ** service handle.
  637. **
  638. ** Parameter service_handle : To which service this included service is added to.
  639. ** char_uuid : Characteristic UUID.
  640. ** perm : Characteristic value declaration attribute permission.
  641. ** property : Characteristic Properties
  642. **
  643. ** Returns Characteristic value declaration attribute handle. 0 if add
  644. ** characteristic failed.
  645. **
  646. *******************************************************************************/
  647. extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
  648. tGATT_PERM perm, tGATT_CHAR_PROP property,
  649. tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control);
  650. /*******************************************************************************
  651. **
  652. ** Function GATTS_AddCharDescriptor
  653. **
  654. ** Description This function is called to add a characteristic descriptor
  655. ** into a service database. Add descriptor should follow add char
  656. ** to which it belongs, and next add char should be done only
  657. ** after all add descriptors for the previous char.
  658. **
  659. ** Parameter service_handle : To which service this characteristic descriptor
  660. ** is added to.
  661. ** perm : Characteristic value declaration attribute
  662. ** permission.
  663. ** p_descr_uuid : Characteristic descriptor UUID.
  664. **
  665. ** Returns Characteristic descriptor attribute handle. 0 if add
  666. ** characteristic descriptor failed.
  667. **
  668. *******************************************************************************/
  669. extern UINT16 GATTS_AddCharDescriptor (UINT16 service_handle, tGATT_PERM perm,
  670. tBT_UUID *p_descr_uuid, tGATT_ATTR_VAL *attr_val,
  671. tGATTS_ATTR_CONTROL *control);
  672. /*******************************************************************************
  673. **
  674. ** Function GATTS_DeleteService
  675. **
  676. ** Description This function is called to delete a service.
  677. **
  678. ** Parameter gatt_if : application interface
  679. ** p_svc_uuid : service UUID
  680. ** svc_inst : instance of the service inside the application
  681. **
  682. ** Returns TRUE if operation succeed, FALSE if handle block was not found.
  683. **
  684. *******************************************************************************/
  685. extern BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
  686. UINT16 svc_inst);
  687. /*******************************************************************************
  688. **
  689. ** Function GATTS_StartService
  690. **
  691. ** Description This function is called to start a service with GATT
  692. **
  693. ** Parameter gatt_if : service handle.
  694. ** p_cback : application service callback functions.
  695. ** sup_transport : supported transport(s) for this primary service
  696. **
  697. ** return GATT_SUCCESS if sucessfully started; otherwise error code.
  698. **
  699. *******************************************************************************/
  700. extern tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
  701. tGATT_TRANSPORT sup_transport);
  702. /*******************************************************************************
  703. **
  704. ** Function GATTS_StopService
  705. **
  706. ** Description This function is called to stop a service
  707. **
  708. ** Parameter service_handle : this is the start handle of a service
  709. **
  710. ** Returns None.
  711. **
  712. *******************************************************************************/
  713. extern void GATTS_StopService (UINT16 service_handle);
  714. /*******************************************************************************
  715. **
  716. ** Function GATTs_HandleValueIndication
  717. **
  718. ** Description This function sends a handle value indication to a client.
  719. **
  720. ** Parameter conn_id: connection identifier.
  721. ** attr_handle: Attribute handle of this handle value indication.
  722. ** val_len: Length of the indicated attribute value.
  723. ** p_val: Pointer to the indicated attribute value data.
  724. **
  725. ** Returns GATT_SUCCESS if sucessfully sent or queued; otherwise error code.
  726. **
  727. *******************************************************************************/
  728. extern tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id,
  729. UINT16 attr_handle,
  730. UINT16 val_len, UINT8 *p_val);
  731. /*******************************************************************************
  732. **
  733. ** Function GATTS_HandleValueNotification
  734. **
  735. ** Description This function sends a handle value notification to a client.
  736. **
  737. ** Parameter conn_id: connection identifier.
  738. ** attr_handle: Attribute handle of this handle value indication.
  739. ** val_len: Length of the indicated attribute value.
  740. ** p_val: Pointer to the indicated attribute value data.
  741. **
  742. ** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
  743. **
  744. *******************************************************************************/
  745. extern tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
  746. UINT16 val_len, UINT8 *p_val);
  747. /*******************************************************************************
  748. **
  749. ** Function GATTS_SendRsp
  750. **
  751. ** Description This function sends the server response to client.
  752. **
  753. ** Parameter conn_id: connection identifier.
  754. ** trans_id: transaction id
  755. ** status: response status
  756. ** p_msg: pointer to message parameters structure.
  757. **
  758. ** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
  759. **
  760. *******************************************************************************/
  761. extern tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
  762. tGATT_STATUS status, tGATTS_RSP *p_msg);
  763. /*******************************************************************************
  764. **
  765. ** Function GATTS_SetAttributeValue
  766. **
  767. ** Description This function sends to set the attribute value .
  768. **
  769. ** Parameter attr_handle:the attribute handle
  770. ** length: the attribute length
  771. ** value: the value to be set to the attribute in the database
  772. **
  773. ** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
  774. **
  775. *******************************************************************************/
  776. tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *value);
  777. /*******************************************************************************
  778. **
  779. ** Function GATTS_GetAttributeValue
  780. **
  781. ** Description This function sends to set the attribute value .
  782. **
  783. ** Parameter attr_handle: the attribute handle
  784. ** length:the attribute value length in the database
  785. ** value: the attribute value out put
  786. **
  787. ** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
  788. **
  789. *******************************************************************************/
  790. tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
  791. /*******************************************************************************/
  792. /* GATT Profile Client Functions */
  793. /*******************************************************************************/
  794. /*******************************************************************************
  795. **
  796. ** Function GATTC_ConfigureMTU
  797. **
  798. ** Description This function is called to configure the ATT MTU size for
  799. ** a connection on an LE transport.
  800. **
  801. ** Parameters conn_id: connection identifier.
  802. ** mtu - attribute MTU size..
  803. **
  804. ** Returns GATT_SUCCESS if command started successfully.
  805. **
  806. *******************************************************************************/
  807. extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id);
  808. /*******************************************************************************
  809. **
  810. ** Function GATTC_Discover
  811. **
  812. ** Description This function is called to do a discovery procedure on ATT server.
  813. **
  814. ** Parameters conn_id: connection identifier.
  815. ** disc_type:discovery type.
  816. ** p_param: parameters of discovery requirement.
  817. **
  818. ** Returns GATT_SUCCESS if command received/sent successfully.
  819. **
  820. *******************************************************************************/
  821. extern tGATT_STATUS GATTC_Discover (UINT16 conn_id,
  822. tGATT_DISC_TYPE disc_type,
  823. tGATT_DISC_PARAM *p_param );
  824. /*******************************************************************************
  825. **
  826. ** Function GATTC_Read
  827. **
  828. ** Description This function is called to read the value of an attribute from
  829. ** the server.
  830. **
  831. ** Parameters conn_id: connection identifier.
  832. ** type - attribute read type.
  833. ** p_read - read operation parameters.
  834. **
  835. ** Returns GATT_SUCCESS if command started successfully.
  836. **
  837. *******************************************************************************/
  838. extern tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type,
  839. tGATT_READ_PARAM *p_read);
  840. /*******************************************************************************
  841. **
  842. ** Function GATTC_Write
  843. **
  844. ** Description This function is called to read the value of an attribute from
  845. ** the server.
  846. **
  847. ** Parameters conn_id: connection identifier.
  848. ** type - attribute write type.
  849. ** p_write - write operation parameters.
  850. **
  851. ** Returns GATT_SUCCESS if command started successfully.
  852. **
  853. *******************************************************************************/
  854. extern tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type,
  855. tGATT_VALUE *p_write);
  856. /*******************************************************************************
  857. **
  858. ** Function GATTC_ExecuteWrite
  859. **
  860. ** Description This function is called to send an Execute write request to
  861. ** the server.
  862. **
  863. ** Parameters conn_id: connection identifier.
  864. ** is_execute - to execute or cancel the prepare write requet(s)
  865. **
  866. ** Returns GATT_SUCCESS if command started successfully.
  867. **
  868. *******************************************************************************/
  869. extern tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute);
  870. /*******************************************************************************
  871. **
  872. ** Function GATTC_SendHandleValueConfirm
  873. **
  874. ** Description This function is called to send a handle value confirmation
  875. ** as response to a handle value notification from server.
  876. **
  877. ** Parameters conn_id: connection identifier.
  878. ** handle: the handle of the attribute confirmation.
  879. **
  880. ** Returns GATT_SUCCESS if command started successfully.
  881. **
  882. *******************************************************************************/
  883. extern tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle);
  884. /*******************************************************************************
  885. **
  886. ** Function GATT_SetIdleTimeout
  887. **
  888. ** Description This function (common to both client and server) sets the idle
  889. ** timeout for a tansport connection
  890. **
  891. ** Parameter bd_addr: target device bd address.
  892. ** idle_tout: timeout value in seconds.
  893. ** transport: trasnport option.
  894. **
  895. ** Returns void
  896. **
  897. *******************************************************************************/
  898. extern void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout,
  899. tGATT_TRANSPORT transport);
  900. /*******************************************************************************
  901. **
  902. ** Function GATT_Register
  903. **
  904. ** Description This function is called to register an application
  905. ** with GATT
  906. **
  907. ** Parameter p_app_uuid128: Application UUID
  908. ** p_cb_info: callback functions.
  909. **
  910. ** Returns 0 for error, otherwise the index of the client registered with GATT
  911. **
  912. *******************************************************************************/
  913. extern tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, tGATT_CBACK *p_cb_info);
  914. /*******************************************************************************
  915. **
  916. ** Function GATT_Deregister
  917. **
  918. ** Description This function deregistered the application from GATT.
  919. **
  920. ** Parameters gatt_if: applicaiton interface.
  921. **
  922. ** Returns None.
  923. **
  924. *******************************************************************************/
  925. extern void GATT_Deregister (tGATT_IF gatt_if);
  926. /*******************************************************************************
  927. **
  928. ** Function GATT_StartIf
  929. **
  930. ** Description This function is called after registration to start receiving
  931. ** callbacks for registered interface. Function may call back
  932. ** with connection status and queued notifications
  933. **
  934. ** Parameter gatt_if: applicaiton interface.
  935. **
  936. ** Returns None
  937. **
  938. *******************************************************************************/
  939. extern void GATT_StartIf (tGATT_IF gatt_if);
  940. /*******************************************************************************
  941. **
  942. ** Function GATT_Connect
  943. **
  944. ** Description This function initiate a connecttion to a remote device on GATT
  945. ** channel.
  946. **
  947. ** Parameters gatt_if: applicaiton interface
  948. ** bd_addr: peer device address.
  949. ** bd_addr_type: peer device address type.
  950. ** is_direct: is a direct conenection or a background auto connection
  951. ** transport : Physical transport for GATT connection (BR/EDR or LE)
  952. **
  953. ** Returns TRUE if connection started; FALSE if connection start failure.
  954. **
  955. *******************************************************************************/
  956. extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type,
  957. BOOLEAN is_direct, tBT_TRANSPORT transport);
  958. /*******************************************************************************
  959. **
  960. ** Function GATT_CancelConnect
  961. **
  962. ** Description This function terminate the connection initaition to a remote
  963. ** device on GATT channel.
  964. **
  965. ** Parameters gatt_if: client interface. If 0 used as unconditionally disconnect,
  966. ** typically used for direct connection cancellation.
  967. ** bd_addr: peer device address.
  968. ** is_direct: is a direct conenection or a background auto connection
  969. **
  970. ** Returns TRUE if connection started; FALSE if connection start failure.
  971. **
  972. *******************************************************************************/
  973. extern BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr,
  974. BOOLEAN is_direct);
  975. /*******************************************************************************
  976. **
  977. ** Function GATT_Disconnect
  978. **
  979. ** Description This function disconnect the GATT channel for this registered
  980. ** application.
  981. **
  982. ** Parameters conn_id: connection identifier.
  983. **
  984. ** Returns GATT_SUCCESS if disconnected.
  985. **
  986. *******************************************************************************/
  987. extern tGATT_STATUS GATT_Disconnect (UINT16 conn_id);
  988. /*******************************************************************************
  989. **
  990. ** Function GATT_GetConnectionInfor
  991. **
  992. ** Description This function use conn_id to find its associated BD address and applciation
  993. ** interface
  994. **
  995. ** Parameters conn_id: connection id (input)
  996. ** p_gatt_if: applicaiton interface (output)
  997. ** bd_addr: peer device address. (output)
  998. ** transport : physical transport of the GATT connection (BR/EDR or LE)
  999. **
  1000. ** Returns TRUE the ligical link information is found for conn_id
  1001. **
  1002. *******************************************************************************/
  1003. extern BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if,
  1004. BD_ADDR bd_addr, tBT_TRANSPORT *p_transport);
  1005. /*******************************************************************************
  1006. **
  1007. ** Function GATT_GetConnIdIfConnected
  1008. **
  1009. ** Description This function find the conn_id if the logical link for BD address
  1010. ** and applciation interface is connected
  1011. **
  1012. ** Parameters gatt_if: applicaiton interface (input)
  1013. ** bd_addr: peer device address. (input)
  1014. ** p_conn_id: connection id (output)
  1015. ** transport : physical transport of the GATT connection (BR/EDR or LE)
  1016. **
  1017. ** Returns TRUE the ligical link is connected
  1018. **
  1019. *******************************************************************************/
  1020. extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr,
  1021. UINT16 *p_conn_id, tBT_TRANSPORT transport);
  1022. /*******************************************************************************
  1023. **
  1024. ** Function GATT_Listen
  1025. **
  1026. ** Description This function start or stop LE advertisement and listen for
  1027. ** connection.
  1028. **
  1029. ** Parameters gatt_if: applicaiton interface
  1030. ** p_bd_addr: listen for specific address connection, or NULL for
  1031. ** listen to all device connection.
  1032. ** start: is a direct conenection or a background auto connection
  1033. **
  1034. ** Returns TRUE if advertisement is started; FALSE if adv start failure.
  1035. **
  1036. *******************************************************************************/
  1037. extern BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr);
  1038. /*******************************************************************************
  1039. **
  1040. ** Function GATT_ConfigServiceChangeCCC
  1041. **
  1042. ** Description Configure service change indication on remote device
  1043. **
  1044. ** Returns None.
  1045. **
  1046. *******************************************************************************/
  1047. extern void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable,
  1048. tBT_TRANSPORT transport);
  1049. #ifdef __cplusplus
  1050. }
  1051. #endif
  1052. #endif /* GATT_API_H */