bta_jv_api.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. /******************************************************************************
  2. *
  3. * Copyright 2006-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. /******************************************************************************
  19. *
  20. * This is the public interface file the BTA Java I/F
  21. *
  22. ******************************************************************************/
  23. #ifndef BTA_JV_API_H
  24. #define BTA_JV_API_H
  25. #include "bt_target.h"
  26. #include "bt_types.h"
  27. #include "bta_api.h"
  28. #include "btm_api.h"
  29. #include "l2c_api.h"
  30. /*****************************************************************************
  31. * Constants and data types
  32. ****************************************************************************/
  33. /* status values */
  34. #define BTA_JV_SUCCESS 0 /* Successful operation. */
  35. #define BTA_JV_FAILURE 1 /* Generic failure. */
  36. #define BTA_JV_BUSY 2 /* Temporarily can not handle this request. */
  37. #define BTA_JV_NO_DATA 3 /* no data. */
  38. #define BTA_JV_NO_RESOURCE 4 /* No more set pm control block */
  39. typedef uint8_t tBTA_JV_STATUS;
  40. #define BTA_JV_INTERNAL_ERR (-1) /* internal error. */
  41. #define BTA_JV_MAX_UUIDS SDP_MAX_UUID_FILTERS
  42. #define BTA_JV_MAX_ATTRS SDP_MAX_ATTR_FILTERS
  43. #define BTA_JV_MAX_SDP_REC SDP_MAX_RECORDS
  44. #define BTA_JV_MAX_L2C_CONN \
  45. GAP_MAX_CONNECTIONS /* GAP handle is used as index, hence do not change this \
  46. value */
  47. #define BTA_JV_MAX_SCN \
  48. PORT_MAX_RFC_PORTS /* same as BTM_MAX_SCN (in btm_int.h) */
  49. #define BTA_JV_MAX_RFC_CONN MAX_RFC_PORTS
  50. #ifndef BTA_JV_DEF_RFC_MTU
  51. #define BTA_JV_DEF_RFC_MTU (3 * 330)
  52. #endif
  53. #ifndef BTA_JV_MAX_RFC_SR_SESSION
  54. #define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS
  55. #endif
  56. /* BTA_JV_MAX_RFC_SR_SESSION can not be bigger than MAX_BD_CONNECTIONS */
  57. #if (BTA_JV_MAX_RFC_SR_SESSION > MAX_BD_CONNECTIONS)
  58. #undef BTA_JV_MAX_RFC_SR_SESSION
  59. #define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS
  60. #endif
  61. #define BTA_JV_FIRST_SERVICE_ID BTA_FIRST_JV_SERVICE_ID
  62. #define BTA_JV_LAST_SERVICE_ID BTA_LAST_JV_SERVICE_ID
  63. #define BTA_JV_NUM_SERVICE_ID \
  64. (BTA_LAST_JV_SERVICE_ID - BTA_FIRST_JV_SERVICE_ID + 1)
  65. /* Discoverable modes */
  66. enum { BTA_JV_DISC_NONE, BTA_JV_DISC_LIMITED, BTA_JV_DISC_GENERAL };
  67. typedef uint16_t tBTA_JV_DISC;
  68. #define BTA_JV_ROLE_SLAVE BTM_ROLE_SLAVE
  69. #define BTA_JV_ROLE_MASTER BTM_ROLE_MASTER
  70. typedef uint32_t tBTA_JV_ROLE;
  71. #define BTA_JV_SERVICE_LMTD_DISCOVER \
  72. BTM_COD_SERVICE_LMTD_DISCOVER /* 0x0020 \
  73. */
  74. #define BTA_JV_SERVICE_POSITIONING BTM_COD_SERVICE_POSITIONING /* 0x0100 */
  75. #define BTA_JV_SERVICE_NETWORKING BTM_COD_SERVICE_NETWORKING /* 0x0200 */
  76. #define BTA_JV_SERVICE_RENDERING BTM_COD_SERVICE_RENDERING /* 0x0400 */
  77. #define BTA_JV_SERVICE_CAPTURING BTM_COD_SERVICE_CAPTURING /* 0x0800 */
  78. #define BTA_JV_SERVICE_OBJ_TRANSFER BTM_COD_SERVICE_OBJ_TRANSFER /* 0x1000 */
  79. #define BTA_JV_SERVICE_AUDIO BTM_COD_SERVICE_AUDIO /* 0x2000 */
  80. #define BTA_JV_SERVICE_TELEPHONY BTM_COD_SERVICE_TELEPHONY /* 0x4000 */
  81. #define BTA_JV_SERVICE_INFORMATION BTM_COD_SERVICE_INFORMATION /* 0x8000 */
  82. /* JV ID type */
  83. #define BTA_JV_PM_ID_1 1 /* PM example profile 1 */
  84. #define BTA_JV_PM_ID_2 2 /* PM example profile 2 */
  85. #define BTA_JV_PM_ID_CLEAR 0 /* Special JV ID used to clear PM profile */
  86. #define BTA_JV_PM_ALL 0xFF /* Generic match all id, see bta_dm_cfg.c */
  87. typedef uint8_t tBTA_JV_PM_ID;
  88. #define BTA_JV_PM_HANDLE_CLEAR \
  89. 0xFF /* Special JV ID used to clear PM profile */
  90. /* define maximum number of registered PM entities. should be in sync with bta
  91. * pm! */
  92. #ifndef BTA_JV_PM_MAX_NUM
  93. #define BTA_JV_PM_MAX_NUM 5
  94. #endif
  95. /* JV pm connection states */
  96. enum {
  97. BTA_JV_CONN_OPEN = 0, /* Connection opened state */
  98. BTA_JV_CONN_CLOSE, /* Connection closed state */
  99. BTA_JV_APP_OPEN, /* JV Application opened state */
  100. BTA_JV_APP_CLOSE, /* JV Application closed state */
  101. BTA_JV_SCO_OPEN, /* SCO connection opened state */
  102. BTA_JV_SCO_CLOSE, /* SCO connection opened state */
  103. BTA_JV_CONN_IDLE, /* Connection idle state */
  104. BTA_JV_CONN_BUSY, /* Connection busy state */
  105. BTA_JV_MAX_CONN_STATE /* Max number of connection state */
  106. };
  107. typedef uint8_t tBTA_JV_CONN_STATE;
  108. /* JV Connection types */
  109. #define BTA_JV_CONN_TYPE_RFCOMM 0
  110. #define BTA_JV_CONN_TYPE_L2CAP 1
  111. #define BTA_JV_CONN_TYPE_L2CAP_LE 2
  112. /* Java I/F callback events */
  113. /* events received by tBTA_JV_DM_CBACK */
  114. #define BTA_JV_ENABLE_EVT 0 /* JV enabled */
  115. #define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */
  116. #define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */
  117. #define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */
  118. #define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */
  119. /* events received by tBTA_JV_L2CAP_CBACK */
  120. #define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */
  121. #define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */
  122. #define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */
  123. #define BTA_JV_L2CAP_CL_INIT_EVT 19 /* L2CAP client initiated a connection */
  124. #define BTA_JV_L2CAP_DATA_IND_EVT 20 /* L2CAP connection received data */
  125. #define BTA_JV_L2CAP_CONG_EVT \
  126. 21 /* L2CAP connection congestion status changed */
  127. #define BTA_JV_L2CAP_READ_EVT 22 /* the result for BTA_JvL2capRead */
  128. #define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/
  129. #define BTA_JV_L2CAP_WRITE_FIXED_EVT \
  130. 25 /* the result for BTA_JvL2capWriteFixed */
  131. /* events received by tBTA_JV_RFCOMM_CBACK */
  132. #define BTA_JV_RFCOMM_OPEN_EVT \
  133. 26 /* open status of RFCOMM Client connection \
  134. */
  135. #define BTA_JV_RFCOMM_CLOSE_EVT 27 /* RFCOMM connection closed */
  136. #define BTA_JV_RFCOMM_START_EVT 28 /* RFCOMM server started */
  137. #define BTA_JV_RFCOMM_CL_INIT_EVT \
  138. 29 /* RFCOMM client initiated a connection \
  139. */
  140. #define BTA_JV_RFCOMM_DATA_IND_EVT 30 /* RFCOMM connection received data */
  141. #define BTA_JV_RFCOMM_CONG_EVT \
  142. 31 /* RFCOMM connection congestion status changed */
  143. #define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/
  144. #define BTA_JV_RFCOMM_SRV_OPEN_EVT \
  145. 34 /* open status of Server RFCOMM connection */
  146. #define BTA_JV_MAX_EVT 35 /* max number of JV events */
  147. typedef uint16_t tBTA_JV_EVT;
  148. /* data associated with BTA_JV_SET_DISCOVER_EVT */
  149. typedef struct {
  150. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  151. tBTA_JV_DISC disc_mode; /* The current discoverable mode */
  152. } tBTA_JV_SET_DISCOVER;
  153. /* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */
  154. typedef struct {
  155. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  156. int scn; /* channel # */
  157. } tBTA_JV_DISCOVERY_COMP;
  158. /* data associated with BTA_JV_CREATE_RECORD_EVT */
  159. typedef struct {
  160. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  161. } tBTA_JV_CREATE_RECORD;
  162. /* data associated with BTA_JV_L2CAP_OPEN_EVT */
  163. typedef struct {
  164. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  165. uint32_t handle; /* The connection handle */
  166. RawAddress rem_bda; /* The peer address */
  167. int32_t tx_mtu; /* The transmit MTU */
  168. } tBTA_JV_L2CAP_OPEN;
  169. /* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
  170. typedef struct {
  171. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  172. uint32_t handle; /* The connection handle */
  173. RawAddress rem_bda; /* The peer address */
  174. int32_t tx_mtu; /* The transmit MTU */
  175. void** p_p_cback; /* set them for new socket */
  176. void** p_user_data; /* set them for new socket */
  177. } tBTA_JV_L2CAP_LE_OPEN;
  178. /* data associated with BTA_JV_L2CAP_CLOSE_EVT */
  179. typedef struct {
  180. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  181. uint32_t handle; /* The connection handle */
  182. bool async; /* false, if local initiates disconnect */
  183. } tBTA_JV_L2CAP_CLOSE;
  184. /* data associated with BTA_JV_L2CAP_START_EVT */
  185. typedef struct {
  186. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  187. uint32_t handle; /* The connection handle */
  188. uint8_t sec_id; /* security ID used by this server */
  189. } tBTA_JV_L2CAP_START;
  190. /* data associated with BTA_JV_L2CAP_CL_INIT_EVT */
  191. typedef struct {
  192. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  193. uint32_t handle; /* The connection handle */
  194. uint8_t sec_id; /* security ID used by this client */
  195. } tBTA_JV_L2CAP_CL_INIT;
  196. /* data associated with BTA_JV_L2CAP_CONG_EVT */
  197. typedef struct {
  198. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  199. uint32_t handle; /* The connection handle */
  200. bool cong; /* true, congested. false, uncongested */
  201. } tBTA_JV_L2CAP_CONG;
  202. /* data associated with BTA_JV_L2CAP_READ_EVT */
  203. typedef struct {
  204. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  205. uint32_t handle; /* The connection handle */
  206. uint32_t req_id; /* The req_id in the associated BTA_JvL2capRead() */
  207. uint8_t* p_data; /* This points the same location as the p_data
  208. * parameter in BTA_JvL2capRead () */
  209. uint16_t len; /* The length of the data read. */
  210. } tBTA_JV_L2CAP_READ;
  211. /* data associated with BTA_JV_L2CAP_WRITE_EVT */
  212. typedef struct {
  213. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  214. uint32_t handle; /* The connection handle */
  215. uint32_t req_id; /* The req_id in the associated BTA_JvL2capWrite() */
  216. uint16_t len; /* The length of the data written. */
  217. bool cong; /* congestion status */
  218. } tBTA_JV_L2CAP_WRITE;
  219. /* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
  220. typedef struct {
  221. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  222. uint16_t channel; /* The connection channel */
  223. RawAddress addr; /* The peer address */
  224. uint32_t req_id; /* The req_id in the associated BTA_JvL2capWrite() */
  225. uint16_t len; /* The length of the data written. */
  226. bool cong; /* congestion status */
  227. } tBTA_JV_L2CAP_WRITE_FIXED;
  228. /* data associated with BTA_JV_RFCOMM_OPEN_EVT */
  229. typedef struct {
  230. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  231. uint32_t handle; /* The connection handle */
  232. RawAddress rem_bda; /* The peer address */
  233. } tBTA_JV_RFCOMM_OPEN;
  234. /* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
  235. typedef struct {
  236. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  237. uint32_t handle; /* The connection handle */
  238. uint32_t new_listen_handle; /* The new listen handle */
  239. RawAddress rem_bda; /* The peer address */
  240. } tBTA_JV_RFCOMM_SRV_OPEN;
  241. /* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
  242. typedef struct {
  243. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  244. uint32_t port_status; /* PORT status */
  245. uint32_t handle; /* The connection handle */
  246. bool async; /* false, if local initiates disconnect */
  247. } tBTA_JV_RFCOMM_CLOSE;
  248. /* data associated with BTA_JV_RFCOMM_START_EVT */
  249. typedef struct {
  250. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  251. uint32_t handle; /* The connection handle */
  252. uint8_t sec_id; /* security ID used by this server */
  253. bool use_co; /* true to use co_rfc_data */
  254. } tBTA_JV_RFCOMM_START;
  255. /* data associated with BTA_JV_RFCOMM_CL_INIT_EVT */
  256. typedef struct {
  257. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  258. uint32_t handle; /* The connection handle */
  259. uint8_t sec_id; /* security ID used by this client */
  260. bool use_co; /* true to use co_rfc_data */
  261. } tBTA_JV_RFCOMM_CL_INIT;
  262. /*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
  263. typedef struct {
  264. uint32_t handle; /* The connection handle */
  265. } tBTA_JV_DATA_IND;
  266. /*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
  267. typedef struct {
  268. uint32_t handle; /* The connection handle */
  269. BT_HDR* p_buf; /* The incoming data */
  270. } tBTA_JV_LE_DATA_IND;
  271. /* data associated with BTA_JV_RFCOMM_CONG_EVT */
  272. typedef struct {
  273. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  274. uint32_t handle; /* The connection handle */
  275. bool cong; /* true, congested. false, uncongested */
  276. } tBTA_JV_RFCOMM_CONG;
  277. /* data associated with BTA_JV_RFCOMM_WRITE_EVT */
  278. typedef struct {
  279. tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  280. uint32_t handle; /* The connection handle */
  281. uint32_t req_id; /* The req_id in the associated BTA_JvRfcommWrite() */
  282. int len; /* The length of the data written. */
  283. bool cong; /* congestion status */
  284. } tBTA_JV_RFCOMM_WRITE;
  285. /* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */
  286. typedef struct {
  287. tBTA_JV_STATUS status; /* Status of the operation */
  288. uint32_t handle; /* Connection handle */
  289. tBTA_JV_PM_ID app_id; /* JV app ID */
  290. } tBTA_JV_SET_PM_PROFILE;
  291. /* data associated with BTA_JV_API_NOTIFY_PM_STATE_CHANGE_EVT */
  292. typedef struct {
  293. uint32_t handle; /* Connection handle */
  294. tBTA_JV_CONN_STATE state; /* JV connection stata */
  295. } tBTA_JV_NOTIFY_PM_STATE_CHANGE;
  296. /* union of data associated with JV callback */
  297. typedef union {
  298. tBTA_JV_STATUS status; /* BTA_JV_ENABLE_EVT */
  299. tBTA_JV_DISCOVERY_COMP disc_comp; /* BTA_JV_DISCOVERY_COMP_EVT */
  300. tBTA_JV_SET_DISCOVER set_discover; /* BTA_JV_SET_DISCOVER_EVT */
  301. uint8_t scn; /* BTA_JV_GET_SCN_EVT */
  302. uint16_t psm; /* BTA_JV_GET_PSM_EVT */
  303. tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */
  304. tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */
  305. tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */
  306. tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */
  307. tBTA_JV_L2CAP_CL_INIT l2c_cl_init; /* BTA_JV_L2CAP_CL_INIT_EVT */
  308. tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */
  309. tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */
  310. tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */
  311. tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */
  312. tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
  313. tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */
  314. tBTA_JV_RFCOMM_START rfc_start; /* BTA_JV_RFCOMM_START_EVT */
  315. tBTA_JV_RFCOMM_CL_INIT rfc_cl_init; /* BTA_JV_RFCOMM_CL_INIT_EVT */
  316. tBTA_JV_RFCOMM_CONG rfc_cong; /* BTA_JV_RFCOMM_CONG_EVT */
  317. tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */
  318. tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT
  319. BTA_JV_RFCOMM_DATA_IND_EVT */
  320. tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
  321. tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */
  322. tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
  323. } tBTA_JV;
  324. /* JAVA DM Interface callback */
  325. typedef void(tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id);
  326. /* JAVA RFCOMM interface callback */
  327. typedef uint32_t(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV* p_data,
  328. uint32_t rfcomm_slot_id);
  329. /* JAVA L2CAP interface callback */
  330. typedef void(tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV* p_data,
  331. uint32_t l2cap_socket_id);
  332. /* JV configuration structure */
  333. typedef struct {
  334. uint16_t sdp_raw_size; /* The size of p_sdp_raw_data */
  335. uint16_t sdp_db_size; /* The size of p_sdp_db */
  336. uint8_t* p_sdp_raw_data; /* The data buffer to keep raw data */
  337. tSDP_DISCOVERY_DB* p_sdp_db; /* The data buffer to keep SDP database */
  338. } tBTA_JV_CFG;
  339. /*******************************************************************************
  340. *
  341. * Function BTA_JvEnable
  342. *
  343. * Description Enable the Java I/F service. When the enable
  344. * operation is complete the callback function will be
  345. * called with a BTA_JV_ENABLE_EVT. This function must
  346. * be called before other functions in the JV API are
  347. * called.
  348. *
  349. * Returns BTA_JV_SUCCESS if successful.
  350. * BTA_JV_FAIL if internal failure.
  351. *
  352. ******************************************************************************/
  353. tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK* p_cback);
  354. /*******************************************************************************
  355. *
  356. * Function BTA_JvDisable
  357. *
  358. * Description Disable the Java I/F
  359. *
  360. * Returns void
  361. *
  362. ******************************************************************************/
  363. void BTA_JvDisable(void);
  364. /*******************************************************************************
  365. *
  366. * Function BTA_JvIsEncrypted
  367. *
  368. * Description This function checks if the link to peer device is encrypted
  369. *
  370. * Returns true if encrypted.
  371. * false if not.
  372. *
  373. ******************************************************************************/
  374. bool BTA_JvIsEncrypted(const RawAddress& bd_addr);
  375. /*******************************************************************************
  376. *
  377. * Function BTA_JvGetChannelId
  378. *
  379. * Description This function reserves a SCN/PSM for applications running
  380. * over RFCOMM or L2CAP. It is primarily called by
  381. * server profiles/applications to register their SCN/PSM into
  382. * the SDP database. The SCN is reported by the
  383. * tBTA_JV_DM_CBACK callback with a BTA_JV_GET_SCN_EVT.
  384. * If the SCN/PSM reported is 0, that means all SCN resources
  385. * are exhausted.
  386. * The channel parameter can be used to request a specific
  387. * channel. If the request on the specific channel fails, the
  388. * SCN/PSM returned in the EVT will be 0 - no attempt to
  389. * request a new channel will be made. set channel to <= 0 to
  390. * automatically assign an channel ID.
  391. *
  392. * Returns void
  393. *
  394. ******************************************************************************/
  395. void BTA_JvGetChannelId(int conn_type, uint32_t id, int32_t channel);
  396. /*******************************************************************************
  397. *
  398. * Function BTA_JvFreeChannel
  399. *
  400. * Description This function frees a SCN/PSM that was used
  401. * by an application running over RFCOMM or L2CAP.
  402. *
  403. * Returns BTA_JV_SUCCESS, if the request is being processed.
  404. * BTA_JV_FAILURE, otherwise.
  405. *
  406. ******************************************************************************/
  407. tBTA_JV_STATUS BTA_JvFreeChannel(uint16_t channel, int conn_type);
  408. /*******************************************************************************
  409. *
  410. * Function BTA_JvStartDiscovery
  411. *
  412. * Description This function performs service discovery for the services
  413. * provided by the given peer device. When the operation is
  414. * complete the tBTA_JV_DM_CBACK callback function will be
  415. * called with a BTA_JV_DISCOVERY_COMP_EVT.
  416. *
  417. * Returns BTA_JV_SUCCESS, if the request is being processed.
  418. * BTA_JV_FAILURE, otherwise.
  419. *
  420. ******************************************************************************/
  421. tBTA_JV_STATUS BTA_JvStartDiscovery(const RawAddress& bd_addr,
  422. uint16_t num_uuid,
  423. const bluetooth::Uuid* p_uuid_list,
  424. uint32_t rfcomm_slot_id);
  425. /*******************************************************************************
  426. *
  427. * Function BTA_JvCreateRecordByUser
  428. *
  429. * Description Create a service record in the local SDP database by user in
  430. * tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT.
  431. *
  432. * Returns BTA_JV_SUCCESS, if the request is being processed.
  433. * BTA_JV_FAILURE, otherwise.
  434. *
  435. ******************************************************************************/
  436. tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id);
  437. /*******************************************************************************
  438. *
  439. * Function BTA_JvDeleteRecord
  440. *
  441. * Description Delete a service record in the local SDP database.
  442. *
  443. * Returns BTA_JV_SUCCESS, if the request is being processed.
  444. * BTA_JV_FAILURE, otherwise.
  445. *
  446. ******************************************************************************/
  447. tBTA_JV_STATUS BTA_JvDeleteRecord(uint32_t handle);
  448. /*******************************************************************************
  449. *
  450. * Function BTA_JvL2capConnectLE
  451. *
  452. * Description Initiate a connection as an LE L2CAP client to the given BD
  453. * Address.
  454. * When the connection is initiated or failed to initiate,
  455. * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
  456. * When the connection is established or failed,
  457. * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
  458. *
  459. ******************************************************************************/
  460. void BTA_JvL2capConnectLE(uint16_t remote_chan, const RawAddress& peer_bd_addr,
  461. tBTA_JV_L2CAP_CBACK* p_cback,
  462. uint32_t l2cap_socket_id);
  463. /*******************************************************************************
  464. *
  465. * Function BTA_JvL2capConnect
  466. *
  467. * Description Initiate a connection as a L2CAP client to the given BD
  468. * Address.
  469. * When the connection is initiated or failed to initiate,
  470. * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
  471. * When the connection is established or failed,
  472. * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
  473. *
  474. ******************************************************************************/
  475. void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
  476. std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info,
  477. uint16_t remote_psm, uint16_t rx_mtu,
  478. std::unique_ptr<tL2CAP_CFG_INFO> cfg,
  479. const RawAddress& peer_bd_addr,
  480. tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id);
  481. /*******************************************************************************
  482. *
  483. * Function BTA_JvL2capClose
  484. *
  485. * Description This function closes an L2CAP client connection
  486. *
  487. * Returns BTA_JV_SUCCESS, if the request is being processed.
  488. * BTA_JV_FAILURE, otherwise.
  489. *
  490. ******************************************************************************/
  491. tBTA_JV_STATUS BTA_JvL2capClose(uint32_t handle);
  492. /*******************************************************************************
  493. *
  494. * Function BTA_JvL2capCloseLE
  495. *
  496. * Description This function closes an L2CAP client connection for Fixed
  497. * Channels Function is idempotent and no callbacks are called!
  498. *
  499. * Returns BTA_JV_SUCCESS, if the request is being processed.
  500. * BTA_JV_FAILURE, otherwise.
  501. *
  502. ******************************************************************************/
  503. tBTA_JV_STATUS BTA_JvL2capCloseLE(uint32_t handle);
  504. /*******************************************************************************
  505. *
  506. * Function BTA_JvL2capStartServer
  507. *
  508. * Description This function starts an L2CAP server and listens for an
  509. * L2CAP connection from a remote Bluetooth device. When the
  510. * server is started successfully, tBTA_JV_L2CAP_CBACK is
  511. * called with BTA_JV_L2CAP_START_EVT. When the connection is
  512. * established, tBTA_JV_L2CAP_CBACK is called with
  513. * BTA_JV_L2CAP_OPEN_EVT.
  514. *
  515. * Returns void
  516. *
  517. ******************************************************************************/
  518. void BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
  519. std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info,
  520. uint16_t local_psm, uint16_t rx_mtu,
  521. std::unique_ptr<tL2CAP_CFG_INFO> cfg,
  522. tBTA_JV_L2CAP_CBACK* p_cback,
  523. uint32_t l2cap_socket_id);
  524. /*******************************************************************************
  525. *
  526. * Function BTA_JvL2capStartServerLE
  527. *
  528. * Description This function starts an LE L2CAP server and listens for an
  529. * L2CAP connection from a remote Bluetooth device on a fixed
  530. * channel over an LE link. When the server
  531. * is started successfully, tBTA_JV_L2CAP_CBACK is called with
  532. * BTA_JV_L2CAP_START_EVT. When the connection is established,
  533. * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
  534. *
  535. * Returns void
  536. *
  537. ******************************************************************************/
  538. void BTA_JvL2capStartServerLE(uint16_t local_chan, tBTA_JV_L2CAP_CBACK* p_cback,
  539. uint32_t l2cap_socket_id);
  540. /*******************************************************************************
  541. *
  542. * Function BTA_JvL2capStopServerLE
  543. *
  544. * Description This function stops the LE L2CAP server. If the server has
  545. * an active connection, it would be closed.
  546. *
  547. * Returns BTA_JV_SUCCESS, if the request is being processed.
  548. * BTA_JV_FAILURE, otherwise.
  549. *
  550. ******************************************************************************/
  551. tBTA_JV_STATUS BTA_JvL2capStopServerLE(uint16_t local_chan,
  552. uint32_t l2cap_socket_id);
  553. /*******************************************************************************
  554. *
  555. * Function BTA_JvL2capStopServer
  556. *
  557. * Description This function stops the L2CAP server. If the server has
  558. * an active connection, it would be closed.
  559. *
  560. * Returns BTA_JV_SUCCESS, if the request is being processed.
  561. * BTA_JV_FAILURE, otherwise.
  562. *
  563. ******************************************************************************/
  564. tBTA_JV_STATUS BTA_JvL2capStopServer(uint16_t local_psm,
  565. uint32_t l2cap_socket_id);
  566. /*******************************************************************************
  567. *
  568. * Function BTA_JvL2capRead
  569. *
  570. * Description This function reads data from an L2CAP connection
  571. * When the operation is complete, tBTA_JV_L2CAP_CBACK is
  572. * called with BTA_JV_L2CAP_READ_EVT.
  573. *
  574. * Returns BTA_JV_SUCCESS, if the request is being processed.
  575. * BTA_JV_FAILURE, otherwise.
  576. *
  577. ******************************************************************************/
  578. tBTA_JV_STATUS BTA_JvL2capRead(uint32_t handle, uint32_t req_id,
  579. uint8_t* p_data, uint16_t len);
  580. /*******************************************************************************
  581. *
  582. * Function BTA_JvL2capReady
  583. *
  584. * Description This function determined if there is data to read from
  585. * an L2CAP connection
  586. *
  587. * Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size.
  588. * BTA_JV_FAILURE, if error.
  589. *
  590. ******************************************************************************/
  591. tBTA_JV_STATUS BTA_JvL2capReady(uint32_t handle, uint32_t* p_data_size);
  592. /*******************************************************************************
  593. *
  594. * Function BTA_JvL2capWrite
  595. *
  596. * Description This function writes data to an L2CAP connection
  597. * When the operation is complete, tBTA_JV_L2CAP_CBACK is
  598. * called with BTA_JV_L2CAP_WRITE_EVT. Works for
  599. * PSM-based connections
  600. *
  601. * Returns BTA_JV_SUCCESS, if the request is being processed.
  602. * BTA_JV_FAILURE, otherwise.
  603. *
  604. ******************************************************************************/
  605. tBTA_JV_STATUS BTA_JvL2capWrite(uint32_t handle, uint32_t req_id, BT_HDR* msg,
  606. uint32_t user_id);
  607. /*******************************************************************************
  608. *
  609. * Function BTA_JvL2capWriteFixed
  610. *
  611. * Description This function writes data to an L2CAP connection
  612. * When the operation is complete, tBTA_JV_L2CAP_CBACK is
  613. * called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for
  614. * fixed-channel connections
  615. *
  616. ******************************************************************************/
  617. void BTA_JvL2capWriteFixed(uint16_t channel, const RawAddress& addr,
  618. uint32_t req_id, tBTA_JV_L2CAP_CBACK* p_cback,
  619. BT_HDR* msg, uint32_t user_id);
  620. /*******************************************************************************
  621. *
  622. * Function BTA_JvRfcommConnect
  623. *
  624. * Description This function makes an RFCOMM conection to a remote BD
  625. * Address.
  626. * When the connection is initiated or failed to initiate,
  627. * tBTA_JV_RFCOMM_CBACK is called with
  628. * BTA_JV_RFCOMM_CL_INIT_EVT
  629. * When the connection is established or failed,
  630. * tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT
  631. *
  632. * Returns BTA_JV_SUCCESS, if the request is being processed.
  633. * BTA_JV_FAILURE, otherwise.
  634. *
  635. ******************************************************************************/
  636. tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
  637. uint8_t remote_scn,
  638. const RawAddress& peer_bd_addr,
  639. tBTA_JV_RFCOMM_CBACK* p_cback,
  640. uint32_t rfcomm_slot_id);
  641. /*******************************************************************************
  642. *
  643. * Function BTA_JvRfcommClose
  644. *
  645. * Description This function closes an RFCOMM connection
  646. *
  647. * Returns BTA_JV_SUCCESS, if the request is being processed.
  648. * BTA_JV_FAILURE, otherwise.
  649. *
  650. ******************************************************************************/
  651. tBTA_JV_STATUS BTA_JvRfcommClose(uint32_t handle, uint32_t rfcomm_slot_id);
  652. /*******************************************************************************
  653. *
  654. * Function BTA_JvRfcommStartServer
  655. *
  656. * Description This function starts listening for an RFCOMM connection
  657. * request from a remote Bluetooth device. When the server is
  658. * started successfully, tBTA_JV_RFCOMM_CBACK is called
  659. * with BTA_JV_RFCOMM_START_EVT.
  660. * When the connection is established, tBTA_JV_RFCOMM_CBACK
  661. * is called with BTA_JV_RFCOMM_OPEN_EVT.
  662. *
  663. * Returns BTA_JV_SUCCESS, if the request is being processed.
  664. * BTA_JV_FAILURE, otherwise.
  665. *
  666. ******************************************************************************/
  667. tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
  668. uint8_t local_scn, uint8_t max_session,
  669. tBTA_JV_RFCOMM_CBACK* p_cback,
  670. uint32_t rfcomm_slot_id);
  671. /*******************************************************************************
  672. *
  673. * Function BTA_JvRfcommStopServer
  674. *
  675. * Description This function stops the RFCOMM server. If the server has an
  676. * active connection, it would be closed.
  677. *
  678. * Returns BTA_JV_SUCCESS, if the request is being processed.
  679. * BTA_JV_FAILURE, otherwise.
  680. *
  681. ******************************************************************************/
  682. tBTA_JV_STATUS BTA_JvRfcommStopServer(uint32_t handle, uint32_t rfcomm_slot_id);
  683. /*******************************************************************************
  684. *
  685. * Function BTA_JvRfcommWrite
  686. *
  687. * Description This function writes data to an RFCOMM connection
  688. * When the operation is complete, tBTA_JV_RFCOMM_CBACK is
  689. * called with BTA_JV_RFCOMM_WRITE_EVT.
  690. *
  691. * Returns BTA_JV_SUCCESS, if the request is being processed.
  692. * BTA_JV_FAILURE, otherwise.
  693. *
  694. ******************************************************************************/
  695. tBTA_JV_STATUS BTA_JvRfcommWrite(uint32_t handle, uint32_t req_id);
  696. /*******************************************************************************
  697. *
  698. * Function BTA_JVSetPmProfile
  699. *
  700. * Description This function set or free power mode profile for different JV
  701. * application
  702. *
  703. * Parameters: handle, JV handle from RFCOMM or L2CAP
  704. * app_id: app specific pm ID, can be BTA_JV_PM_ALL, see
  705. * bta_dm_cfg.c for details
  706. * BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st
  707. * is ignored and BTA_JV_CONN_CLOSE is called
  708. * implicitly
  709. * init_st: state after calling this API. typically it should be
  710. * BTA_JV_CONN_OPEN
  711. *
  712. * Returns BTA_JV_SUCCESS, if the request is being processed.
  713. * BTA_JV_FAILURE, otherwise.
  714. *
  715. * NOTE: BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm
  716. * calls automatically
  717. * BTA_JV_CONN_CLOSE to remove in case of connection close!
  718. *
  719. ******************************************************************************/
  720. tBTA_JV_STATUS BTA_JvSetPmProfile(uint32_t handle, tBTA_JV_PM_ID app_id,
  721. tBTA_JV_CONN_STATE init_st);
  722. /*******************************************************************************
  723. *
  724. * Function BTA_JvRfcommGetPortHdl
  725. *
  726. * Description This function fetches the rfcomm port handle
  727. *
  728. * Returns BTA_JV_SUCCESS, if the request is being processed.
  729. * BTA_JV_FAILURE, otherwise.
  730. *
  731. ******************************************************************************/
  732. uint16_t BTA_JvRfcommGetPortHdl(uint32_t handle);
  733. #endif /* BTA_JV_API_H */