gatt_api.h 47 KB

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