gatt_api.h 47 KB

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