bta_api.h 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  1. /******************************************************************************
  2. *
  3. * Copyright 2003-2014 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 for BTA, Broadcom's Bluetooth
  21. * application layer for mobile phones.
  22. *
  23. ******************************************************************************/
  24. #ifndef BTA_API_H
  25. #define BTA_API_H
  26. #include <hardware/bt_common_types.h>
  27. #include <memory>
  28. #include "bt_target.h"
  29. #include "bt_types.h"
  30. #include "btm_api.h"
  31. #include "btm_ble_api.h"
  32. /*****************************************************************************
  33. * Constants and data types
  34. ****************************************************************************/
  35. /* Status Return Value */
  36. #define BTA_SUCCESS 0 /* Successful operation. */
  37. #define BTA_FAILURE 1 /* Generic failure. */
  38. #define BTA_PENDING 2 /* API cannot be completed right now */
  39. #define BTA_BUSY 3
  40. #define BTA_NO_RESOURCES 4
  41. #define BTA_WRONG_MODE 5
  42. typedef uint8_t tBTA_STATUS;
  43. /*
  44. * Service ID
  45. *
  46. * NOTES: When you add a new Service ID for BTA AND require to change the value
  47. * of BTA_MAX_SERVICE_ID, make sure that the correct security ID of the new
  48. * service from Security service definitions (btm_api.h) should be added to
  49. * bta_service_id_to_btm_srv_id_lkup_tbl table in bta_dm_act.cc
  50. */
  51. #define BTA_RES_SERVICE_ID 0 /* Reserved */
  52. #define BTA_SPP_SERVICE_ID 1 /* Serial port profile. */
  53. #define BTA_DUN_SERVICE_ID 2 /* Dial-up networking profile. */
  54. #define BTA_A2DP_SOURCE_SERVICE_ID 3 /* A2DP Source profile. */
  55. #define BTA_LAP_SERVICE_ID 4 /* LAN access profile. */
  56. #define BTA_HSP_SERVICE_ID 5 /* Headset profile. */
  57. #define BTA_HFP_SERVICE_ID 6 /* Hands-free profile. */
  58. #define BTA_OPP_SERVICE_ID 7 /* Object push */
  59. #define BTA_FTP_SERVICE_ID 8 /* File transfer */
  60. #define BTA_CTP_SERVICE_ID 9 /* Cordless Terminal */
  61. #define BTA_ICP_SERVICE_ID 10 /* Intercom Terminal */
  62. #define BTA_SYNC_SERVICE_ID 11 /* Synchronization */
  63. #define BTA_BPP_SERVICE_ID 12 /* Basic printing profile */
  64. #define BTA_BIP_SERVICE_ID 13 /* Basic Imaging profile */
  65. #define BTA_PANU_SERVICE_ID 14 /* PAN User */
  66. #define BTA_NAP_SERVICE_ID 15 /* PAN Network access point */
  67. #define BTA_GN_SERVICE_ID 16 /* PAN Group Ad-hoc networks */
  68. #define BTA_SAP_SERVICE_ID 17 /* SIM Access profile */
  69. #define BTA_A2DP_SINK_SERVICE_ID 18 /* A2DP Sink */
  70. #define BTA_AVRCP_SERVICE_ID 19 /* A/V remote control */
  71. #define BTA_HID_SERVICE_ID 20 /* HID */
  72. #define BTA_VDP_SERVICE_ID 21 /* Video distribution */
  73. #define BTA_PBAP_SERVICE_ID 22 /* PhoneBook Access Server*/
  74. #define BTA_HSP_HS_SERVICE_ID 23 /* HFP HS role */
  75. #define BTA_HFP_HS_SERVICE_ID 24 /* HSP HS role */
  76. #define BTA_MAP_SERVICE_ID 25 /* Message Access Profile */
  77. #define BTA_MN_SERVICE_ID 26 /* Message Notification Service */
  78. #define BTA_HDP_SERVICE_ID 27 /* Health Device Profile */
  79. #define BTA_PCE_SERVICE_ID 28 /* PhoneBook Access Client */
  80. #define BTA_SDP_SERVICE_ID 29 /* SDP Search */
  81. #define BTA_HIDD_SERVICE_ID 30 /* HID Device */
  82. /* BLE profile service ID */
  83. #define BTA_BLE_SERVICE_ID 31 /* GATT profile */
  84. #define BTA_USER_SERVICE_ID 32 /* User requested UUID */
  85. #define BTA_MAX_SERVICE_ID 33
  86. /* service IDs (BTM_SEC_SERVICE_FIRST_EMPTY + 1) to (BTM_SEC_MAX_SERVICES - 1)
  87. * are used by BTA JV */
  88. #define BTA_FIRST_JV_SERVICE_ID (BTM_SEC_SERVICE_FIRST_EMPTY + 1)
  89. #define BTA_LAST_JV_SERVICE_ID (BTM_SEC_MAX_SERVICES - 1)
  90. typedef uint8_t tBTA_SERVICE_ID;
  91. /* Service ID Mask */
  92. #define BTA_RES_SERVICE_MASK 0x00000001 /* Reserved */
  93. #define BTA_SPP_SERVICE_MASK 0x00000002 /* Serial port profile. */
  94. #define BTA_DUN_SERVICE_MASK 0x00000004 /* Dial-up networking profile. */
  95. #define BTA_FAX_SERVICE_MASK 0x00000008 /* Fax profile. */
  96. #define BTA_LAP_SERVICE_MASK 0x00000010 /* LAN access profile. */
  97. #define BTA_HSP_SERVICE_MASK 0x00000020 /* HSP AG role. */
  98. #define BTA_HFP_SERVICE_MASK 0x00000040 /* HFP AG role */
  99. #define BTA_OPP_SERVICE_MASK 0x00000080 /* Object push */
  100. #define BTA_FTP_SERVICE_MASK 0x00000100 /* File transfer */
  101. #define BTA_CTP_SERVICE_MASK 0x00000200 /* Cordless Terminal */
  102. #define BTA_ICP_SERVICE_MASK 0x00000400 /* Intercom Terminal */
  103. #define BTA_SYNC_SERVICE_MASK 0x00000800 /* Synchronization */
  104. #define BTA_BPP_SERVICE_MASK 0x00001000 /* Print server */
  105. #define BTA_BIP_SERVICE_MASK 0x00002000 /* Basic Imaging */
  106. #define BTA_PANU_SERVICE_MASK 0x00004000 /* PAN User */
  107. #define BTA_NAP_SERVICE_MASK 0x00008000 /* PAN Network access point */
  108. #define BTA_GN_SERVICE_MASK 0x00010000 /* PAN Group Ad-hoc networks */
  109. #define BTA_SAP_SERVICE_MASK 0x00020000 /* PAN Group Ad-hoc networks */
  110. #define BTA_A2DP_SERVICE_MASK 0x00040000 /* Advanced audio distribution */
  111. #define BTA_AVRCP_SERVICE_MASK 0x00080000 /* A/V remote control */
  112. #define BTA_HID_SERVICE_MASK 0x00100000 /* HID */
  113. #define BTA_VDP_SERVICE_MASK 0x00200000 /* Video distribution */
  114. #define BTA_PBAP_SERVICE_MASK 0x00400000 /* Phone Book Server */
  115. #define BTA_HSP_HS_SERVICE_MASK 0x00800000 /* HFP HS role */
  116. #define BTA_HFP_HS_SERVICE_MASK 0x01000000 /* HSP HS role */
  117. #define BTA_MAS_SERVICE_MASK 0x02000000 /* Message Access Profile */
  118. #define BTA_MN_SERVICE_MASK 0x04000000 /* Message Notification Profile */
  119. #define BTA_HL_SERVICE_MASK 0x08000000 /* Health Device Profile */
  120. #define BTA_PCE_SERVICE_MASK 0x10000000 /* Phone Book Client */
  121. #define BTA_HIDD_SERVICE_MASK 0x20000000 /* HID Device */
  122. #define BTA_BLE_SERVICE_MASK 0x40000000 /* GATT based service */
  123. #define BTA_ALL_SERVICE_MASK 0x7FFFFFFF /* All services supported by BTA. */
  124. #define BTA_USER_SERVICE_MASK 0x80000000 /* Message Notification Profile */
  125. typedef uint32_t tBTA_SERVICE_MASK;
  126. /* extended service mask, including mask with one or more GATT UUID */
  127. typedef struct {
  128. tBTA_SERVICE_MASK srvc_mask;
  129. uint8_t num_uuid;
  130. bluetooth::Uuid* p_uuid;
  131. } tBTA_SERVICE_MASK_EXT;
  132. /* Security Setting Mask */
  133. #define BTA_SEC_NONE BTM_SEC_NONE /* No security. */
  134. #define BTA_SEC_AUTHORIZE \
  135. (BTM_SEC_IN_AUTHORIZE) /* Authorization required (only needed for out \
  136. going connection )*/
  137. #define BTA_SEC_AUTHENTICATE \
  138. (BTM_SEC_IN_AUTHENTICATE | \
  139. BTM_SEC_OUT_AUTHENTICATE) /* Authentication required. */
  140. #define BTA_SEC_ENCRYPT \
  141. (BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT) /* Encryption required. */
  142. #define BTA_SEC_MODE4_LEVEL4 \
  143. (BTM_SEC_MODE4_LEVEL4) /* Mode 4 level 4 service, i.e. incoming/outgoing \
  144. MITM and P-256 encryption */
  145. #define BTA_SEC_MITM \
  146. (BTM_SEC_IN_MITM | BTM_SEC_OUT_MITM) /* Man-In-The_Middle protection */
  147. #define BTA_SEC_IN_16_DIGITS \
  148. (BTM_SEC_IN_MIN_16_DIGIT_PIN) /* Min 16 digit for pin code */
  149. typedef uint16_t tBTA_SEC;
  150. /* Ignore for Discoverable, Connectable, Pairable and Connectable Paired only
  151. * device modes */
  152. #define BTA_DM_IGNORE 0x00FF
  153. /* Ignore for Discoverable, Connectable only for LE modes */
  154. #define BTA_DM_LE_IGNORE 0xFF00
  155. #define BTA_APP_ID_PAN_MULTI 0xFE /* app id for pan multiple connection */
  156. #define BTA_ALL_APP_ID 0xFF
  157. /* Discoverable Modes */
  158. #define BTA_DM_NON_DISC BTM_NON_DISCOVERABLE /* Device is not discoverable. */
  159. #define BTA_DM_GENERAL_DISC \
  160. BTM_GENERAL_DISCOVERABLE /* General discoverable. \
  161. */
  162. #define BTA_DM_BLE_NON_DISCOVERABLE \
  163. BTM_BLE_NON_DISCOVERABLE /* Device is not LE discoverable */
  164. #define BTA_DM_BLE_GENERAL_DISCOVERABLE \
  165. BTM_BLE_GENERAL_DISCOVERABLE /* Device is LE General discoverable */
  166. #define BTA_DM_BLE_LIMITED_DISCOVERABLE \
  167. BTM_BLE_LIMITED_DISCOVERABLE /* Device is LE Limited discoverable */
  168. typedef uint16_t
  169. tBTA_DM_DISC; /* this discoverability mode is a bit mask among BR mode and
  170. LE mode */
  171. /* Connectable Modes */
  172. #define BTA_DM_NON_CONN BTM_NON_CONNECTABLE /* Device is not connectable. */
  173. #define BTA_DM_CONN BTM_CONNECTABLE /* Device is connectable. */
  174. #define BTA_DM_BLE_NON_CONNECTABLE \
  175. BTM_BLE_NON_CONNECTABLE /* Device is LE non-connectable. */
  176. #define BTA_DM_BLE_CONNECTABLE \
  177. BTM_BLE_CONNECTABLE /* Device is LE connectable. */
  178. typedef uint16_t tBTA_DM_CONN;
  179. #define BTA_TRANSPORT_UNKNOWN 0
  180. #define BTA_TRANSPORT_BR_EDR BT_TRANSPORT_BR_EDR
  181. #define BTA_TRANSPORT_LE BT_TRANSPORT_LE
  182. typedef tBT_TRANSPORT tBTA_TRANSPORT;
  183. /* Pairable Modes */
  184. #define BTA_DM_PAIRABLE 1
  185. #define BTA_DM_NON_PAIRABLE 0
  186. /* Connectable Paired Only Mode */
  187. #define BTA_DM_CONN_ALL 0
  188. #define BTA_DM_CONN_PAIRED 1
  189. /* Inquiry Modes */
  190. #define BTA_DM_INQUIRY_NONE BTM_INQUIRY_NONE /*No BR inquiry. */
  191. #define BTA_DM_GENERAL_INQUIRY \
  192. BTM_GENERAL_INQUIRY /* Perform general inquiry. */
  193. #define BTA_DM_LIMITED_INQUIRY \
  194. BTM_LIMITED_INQUIRY /* Perform limited inquiry. */
  195. #define BTA_BLE_INQUIRY_NONE BTM_BLE_INQUIRY_NONE
  196. #define BTA_BLE_GENERAL_INQUIRY \
  197. BTM_BLE_GENERAL_INQUIRY /* Perform LE general inquiry. */
  198. #define BTA_BLE_LIMITED_INQUIRY \
  199. BTM_BLE_LIMITED_INQUIRY /* Perform LE limited inquiry. */
  200. typedef uint8_t tBTA_DM_INQ_MODE;
  201. /* Inquiry Filter Type */
  202. #define BTA_DM_INQ_CLR BTM_CLR_INQUIRY_FILTER /* Clear inquiry filter. */
  203. #define BTA_DM_INQ_DEV_CLASS \
  204. BTM_FILTER_COND_DEVICE_CLASS /* Filter on device class. */
  205. #define BTA_DM_INQ_BD_ADDR \
  206. BTM_FILTER_COND_BD_ADDR /* Filter on a specific BD address. */
  207. typedef uint8_t tBTA_DM_INQ_FILT;
  208. /* Authorize Response */
  209. #define BTA_DM_AUTH_PERM \
  210. 0 /* Authorized for future connections to the service */
  211. #define BTA_DM_AUTH_TEMP 1 /* Authorized for current connection only */
  212. #define BTA_DM_NOT_AUTH 2 /* Not authorized for the service */
  213. typedef uint8_t tBTA_AUTH_RESP;
  214. /* M/S preferred roles */
  215. #define BTA_ANY_ROLE 0x00
  216. #define BTA_MASTER_ROLE_PREF 0x01
  217. #define BTA_MASTER_ROLE_ONLY 0x02
  218. #define BTA_SLAVE_ROLE_ONLY \
  219. 0x03 /* Used for PANU only, skip role switch to master */
  220. typedef uint8_t tBTA_PREF_ROLES;
  221. enum {
  222. BTA_DM_NO_SCATTERNET, /* Device doesn't support scatternet, it might
  223. support "role switch during connection" for
  224. an incoming connection, when it already has
  225. another connection in master role */
  226. BTA_DM_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
  227. simulateous connection in Master and Slave roles
  228. for short period of time */
  229. BTA_DM_FULL_SCATTERNET /* Device can have simultaneous connection in master
  230. and slave roles */
  231. };
  232. /* Inquiry filter device class condition */
  233. typedef struct {
  234. DEV_CLASS dev_class; /* device class of interest */
  235. DEV_CLASS dev_class_mask; /* mask to determine the bits of device class of
  236. interest */
  237. } tBTA_DM_COD_COND;
  238. /* Inquiry Filter Condition */
  239. typedef union {
  240. RawAddress bd_addr; /* BD address of device to filter. */
  241. tBTA_DM_COD_COND dev_class_cond; /* Device class filter condition */
  242. } tBTA_DM_INQ_COND;
  243. /* Inquiry Parameters */
  244. typedef struct {
  245. tBTA_DM_INQ_MODE mode; /* Inquiry mode, limited or general. */
  246. uint8_t duration; /* Inquiry duration in 1.28 sec units. */
  247. uint8_t max_resps; /* Maximum inquiry responses. Set to zero for unlimited
  248. responses. */
  249. bool report_dup; /* report duplicated inquiry response with higher RSSI value
  250. */
  251. tBTA_DM_INQ_FILT filter_type; /* Filter condition type. */
  252. tBTA_DM_INQ_COND filter_cond; /* Filter condition data. */
  253. } tBTA_DM_INQ;
  254. typedef struct {
  255. uint8_t bta_dm_eir_min_name_len; /* minimum length of local name when it is
  256. shortened */
  257. #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
  258. uint8_t bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
  259. uint8_t* bta_dm_eir_uuid16; /* 16-bit UUIDs */
  260. #else
  261. uint32_t uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
  262. #endif
  263. int8_t* bta_dm_eir_inq_tx_power; /* Inquiry TX power */
  264. uint8_t bta_dm_eir_flag_len; /* length of flags in bytes */
  265. uint8_t* bta_dm_eir_flags; /* flags for EIR */
  266. uint8_t bta_dm_eir_manufac_spec_len; /* length of manufacturer specific in
  267. bytes */
  268. uint8_t* bta_dm_eir_manufac_spec; /* manufacturer specific */
  269. uint8_t bta_dm_eir_additional_len; /* length of additional data in bytes */
  270. uint8_t* bta_dm_eir_additional; /* additional data */
  271. } tBTA_DM_EIR_CONF;
  272. /* advertising filter policy */
  273. typedef tBTM_BLE_AFP tBTA_BLE_AFP;
  274. enum {
  275. BTA_BLE_BATCH_SCAN_MODE_PASS = 1,
  276. BTA_BLE_BATCH_SCAN_MODE_ACTI = 2,
  277. BTA_BLE_BATCH_SCAN_MODE_PASS_ACTI = 3
  278. };
  279. typedef uint8_t tBTA_BLE_BATCH_SCAN_MODE;
  280. enum { BTA_BLE_DISCARD_OLD_ITEMS = 0, BTA_BLE_DISCARD_LOWER_RSSI_ITEMS = 1 };
  281. typedef uint8_t tBTA_BLE_DISCARD_RULE;
  282. enum { BTA_BLE_ADV_SEEN_FIRST_TIME = 0, BTA_BLE_ADV_TRACKING_TIMEOUT = 1 };
  283. typedef uint8_t tBTA_BLE_ADV_CHANGE_REASON;
  284. /* BLE customer specific feature function type definitions */
  285. /* data type used on customer specific feature for RSSI monitoring */
  286. #define BTA_BLE_RSSI_ALERT_HI 0
  287. #define BTA_BLE_RSSI_ALERT_RANGE 1
  288. #define BTA_BLE_RSSI_ALERT_LO 2
  289. typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_TYPE;
  290. #define BTA_BLE_RSSI_ALERT_NONE BTM_BLE_RSSI_ALERT_NONE /* (0) */
  291. #define BTA_BLE_RSSI_ALERT_HI_BIT BTM_BLE_RSSI_ALERT_HI_BIT /* (1) */
  292. #define BTA_BLE_RSSI_ALERT_RANGE_BIT \
  293. BTM_BLE_RSSI_ALERT_RANGE_BIT /* (1 << 1) */
  294. #define BTA_BLE_RSSI_ALERT_LO_BIT BTM_BLE_RSSI_ALERT_LO_BIT /* (1 << 2) */
  295. typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_MASK;
  296. typedef void(tBTA_DM_BLE_RSSI_CBACK)(const RawAddress& bd_addr,
  297. tBTA_DM_BLE_RSSI_ALERT_TYPE alert_type,
  298. int8_t rssi);
  299. typedef int8_t tBTA_DM_RSSI_VALUE;
  300. typedef uint8_t tBTA_DM_LINK_QUALITY_VALUE;
  301. typedef uint8_t tBTA_SIG_STRENGTH_MASK;
  302. /* Security Callback Events */
  303. #define BTA_DM_ENABLE_EVT 0 /* Enable Event */
  304. #define BTA_DM_DISABLE_EVT 1 /* Disable Event */
  305. #define BTA_DM_PIN_REQ_EVT 2 /* PIN request. */
  306. #define BTA_DM_AUTH_CMPL_EVT 3 /* Authentication complete indication. */
  307. #define BTA_DM_AUTHORIZE_EVT 4 /* Authorization request. */
  308. #define BTA_DM_LINK_UP_EVT 5 /* Connection UP event */
  309. #define BTA_DM_LINK_DOWN_EVT 6 /* Connection DOWN event */
  310. #define BTA_DM_SIG_STRENGTH_EVT \
  311. 7 /* Signal strength for bluetooth connection \
  312. */
  313. #define BTA_DM_BUSY_LEVEL_EVT 8 /* System busy level */
  314. #define BTA_DM_BOND_CANCEL_CMPL_EVT 9 /* Bond cancel complete indication */
  315. #define BTA_DM_SP_CFM_REQ_EVT \
  316. 10 /* Simple Pairing User Confirmation request. \
  317. */
  318. #define BTA_DM_SP_KEY_NOTIF_EVT 11 /* Simple Pairing Passkey Notification */
  319. #define BTA_DM_SP_RMT_OOB_EVT 12 /* Simple Pairing Remote OOB Data request. */
  320. #define BTA_DM_SP_KEYPRESS_EVT 13 /* Key press notification event. */
  321. #define BTA_DM_ROLE_CHG_EVT 14 /* Role Change event. */
  322. #define BTA_DM_BLE_KEY_EVT 15 /* BLE SMP key event for peer device keys */
  323. #define BTA_DM_BLE_SEC_REQ_EVT 16 /* BLE SMP security request */
  324. #define BTA_DM_BLE_PASSKEY_NOTIF_EVT 17 /* SMP passkey notification event */
  325. #define BTA_DM_BLE_PASSKEY_REQ_EVT 18 /* SMP passkey request event */
  326. #define BTA_DM_BLE_OOB_REQ_EVT 19 /* SMP OOB request event */
  327. #define BTA_DM_BLE_LOCAL_IR_EVT 20 /* BLE local IR event */
  328. #define BTA_DM_BLE_LOCAL_ER_EVT 21 /* BLE local ER event */
  329. #define BTA_DM_BLE_NC_REQ_EVT 22 /* SMP Numeric Comparison request event */
  330. #define BTA_DM_SP_RMT_OOB_EXT_EVT \
  331. 23 /* Simple Pairing Remote OOB Extended Data request. */
  332. #define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */
  333. #define BTA_DM_DEV_UNPAIRED_EVT 25
  334. #define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
  335. #define BTA_DM_LE_FEATURES_READ \
  336. 27 /* Cotroller specific LE features are read \
  337. */
  338. #define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
  339. #define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
  340. typedef uint8_t tBTA_DM_SEC_EVT;
  341. /* Structure associated with BTA_DM_ENABLE_EVT */
  342. typedef struct { tBTA_STATUS status; } tBTA_DM_ENABLE;
  343. /* Structure associated with BTA_DM_PIN_REQ_EVT */
  344. typedef struct {
  345. /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
  346. * order */
  347. RawAddress bd_addr; /* BD address peer device. */
  348. DEV_CLASS dev_class; /* Class of Device */
  349. BD_NAME bd_name; /* Name of peer device. */
  350. bool min_16_digit; /* true if the pin returned must be at least 16 digits */
  351. } tBTA_DM_PIN_REQ;
  352. /* BLE related definition */
  353. #define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10)
  354. /* Converts SMP error codes defined in smp_api.h to SMP auth fail reasons below.
  355. */
  356. #define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x))
  357. #define BTA_DM_AUTH_SMP_PASSKEY_FAIL \
  358. (BTA_DM_AUTH_FAIL_BASE + SMP_PASSKEY_ENTRY_FAIL)
  359. #define BTA_DM_AUTH_SMP_OOB_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_OOB_FAIL)
  360. #define BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL \
  361. (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_AUTH_FAIL)
  362. #define BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL \
  363. (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_VALUE_ERR)
  364. #define BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT \
  365. (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_NOT_SUPPORT)
  366. #define BTA_DM_AUTH_SMP_ENC_KEY_SIZE (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_KEY_SIZE)
  367. #define BTA_DM_AUTH_SMP_INVALID_CMD (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_CMD)
  368. #define BTA_DM_AUTH_SMP_UNKNOWN_ERR \
  369. (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_FAIL_UNKNOWN)
  370. #define BTA_DM_AUTH_SMP_REPEATED_ATTEMPT \
  371. (BTA_DM_AUTH_FAIL_BASE + SMP_REPEATED_ATTEMPTS)
  372. #define BTA_DM_AUTH_SMP_INVALID_PARAMETERS \
  373. (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_PARAMETERS)
  374. #define BTA_DM_AUTH_SMP_INTERNAL_ERR \
  375. (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_INTERNAL_ERR)
  376. #define BTA_DM_AUTH_SMP_UNKNOWN_IO (BTA_DM_AUTH_FAIL_BASE + SMP_UNKNOWN_IO_CAP)
  377. #define BTA_DM_AUTH_SMP_INIT_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_INIT_FAIL)
  378. #define BTA_DM_AUTH_SMP_CONFIRM_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_FAIL)
  379. #define BTA_DM_AUTH_SMP_BUSY (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
  380. #define BTA_DM_AUTH_SMP_ENC_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
  381. #define BTA_DM_AUTH_SMP_RSP_TIMEOUT (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
  382. #define BTA_DM_AUTH_SMP_CONN_TOUT (BTA_DM_AUTH_FAIL_BASE + SMP_CONN_TOUT)
  383. /* connection parameter boundary value and dummy value */
  384. #define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN
  385. #define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX
  386. #define BTA_DM_BLE_SCAN_WIN_MIN BTM_BLE_SCAN_WIN_MIN
  387. #define BTA_DM_BLE_SCAN_WIN_MAX BTM_BLE_SCAN_WIN_MAX
  388. #define BTA_DM_BLE_CONN_INT_MIN BTM_BLE_CONN_INT_MIN
  389. #define BTA_DM_BLE_CONN_INT_MAX BTM_BLE_CONN_INT_MAX
  390. #define BTA_DM_BLE_CONN_LATENCY_MAX BTM_BLE_CONN_LATENCY_MAX
  391. #define BTA_DM_BLE_CONN_SUP_TOUT_MIN BTM_BLE_CONN_SUP_TOUT_MIN
  392. #define BTA_DM_BLE_CONN_SUP_TOUT_MAX BTM_BLE_CONN_SUP_TOUT_MAX
  393. #define BTA_DM_BLE_CONN_PARAM_UNDEF \
  394. BTM_BLE_CONN_PARAM_UNDEF /* use this value when a specific value not to be \
  395. overwritten */
  396. #define BTA_LE_KEY_PENC \
  397. BTM_LE_KEY_PENC /* encryption information of peer device */
  398. #define BTA_LE_KEY_PID BTM_LE_KEY_PID /* identity key of the peer device */
  399. #define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */
  400. #define BTA_LE_KEY_LENC \
  401. BTM_LE_KEY_LENC /* master role security information:div */
  402. #define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */
  403. #define BTA_LE_KEY_LCSRK \
  404. BTM_LE_KEY_LCSRK /* local CSRK has been deliver to peer */
  405. typedef uint8_t tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
  406. typedef tBTM_LE_PENC_KEYS tBTA_LE_PENC_KEYS;
  407. typedef tBTM_LE_PCSRK_KEYS tBTA_LE_PCSRK_KEYS;
  408. typedef tBTM_LE_LENC_KEYS tBTA_LE_LENC_KEYS;
  409. typedef tBTM_LE_LCSRK_KEYS tBTA_LE_LCSRK_KEYS;
  410. typedef tBTM_LE_PID_KEYS tBTA_LE_PID_KEYS;
  411. typedef union {
  412. tBTA_LE_PENC_KEYS penc_key; /* received peer encryption key */
  413. tBTA_LE_PCSRK_KEYS psrk_key; /* received peer device SRK */
  414. tBTA_LE_PID_KEYS pid_key; /* peer device ID key */
  415. tBTA_LE_LENC_KEYS
  416. lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
  417. tBTA_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
  418. tBTA_LE_PID_KEYS lid_key; /* local device ID key for the particular remote */
  419. } tBTA_LE_KEY_VALUE;
  420. #define BTA_BLE_LOCAL_KEY_TYPE_ID 1
  421. #define BTA_BLE_LOCAL_KEY_TYPE_ER 2
  422. typedef uint8_t tBTA_DM_BLE_LOCAL_KEY_MASK;
  423. typedef struct {
  424. Octet16 ir;
  425. Octet16 irk;
  426. Octet16 dhk;
  427. } tBTA_BLE_LOCAL_ID_KEYS;
  428. #define BTA_DM_SEC_GRANTED BTA_SUCCESS
  429. #define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
  430. #define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
  431. typedef uint8_t tBTA_DM_BLE_SEC_GRANT;
  432. /* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
  433. typedef struct {
  434. RawAddress bd_addr; /* peer address */
  435. BD_NAME bd_name; /* peer device name */
  436. } tBTA_DM_BLE_SEC_REQ;
  437. typedef struct {
  438. RawAddress bd_addr; /* peer address */
  439. tBTM_LE_KEY_TYPE key_type;
  440. tBTM_LE_KEY_VALUE* p_key_value;
  441. } tBTA_DM_BLE_KEY;
  442. /* Structure associated with BTA_DM_AUTH_CMPL_EVT */
  443. typedef struct {
  444. RawAddress bd_addr; /* BD address peer device. */
  445. BD_NAME bd_name; /* Name of peer device. */
  446. bool key_present; /* Valid link key value in key element */
  447. LinkKey key; /* Link key associated with peer device. */
  448. uint8_t key_type; /* The type of Link Key */
  449. bool success; /* true of authentication succeeded, false if failed. */
  450. uint8_t fail_reason; /* The HCI reason/error code for when success=false */
  451. tBLE_ADDR_TYPE addr_type; /* Peer device address type */
  452. tBT_DEVICE_TYPE dev_type;
  453. } tBTA_DM_AUTH_CMPL;
  454. /* Structure associated with BTA_DM_AUTHORIZE_EVT */
  455. typedef struct {
  456. RawAddress bd_addr; /* BD address peer device. */
  457. BD_NAME bd_name; /* Name of peer device. */
  458. tBTA_SERVICE_ID service; /* Service ID to authorize. */
  459. DEV_CLASS dev_class;
  460. } tBTA_DM_AUTHORIZE;
  461. /* Structure associated with BTA_DM_LINK_UP_EVT */
  462. typedef struct {
  463. RawAddress bd_addr; /* BD address peer device. */
  464. tBTA_TRANSPORT link_type;
  465. } tBTA_DM_LINK_UP;
  466. /* Structure associated with BTA_DM_LINK_DOWN_EVT */
  467. typedef struct {
  468. RawAddress bd_addr; /* BD address peer device. */
  469. uint8_t status; /* connection open/closed */
  470. bool is_removed; /* true if device is removed when link is down */
  471. tBTA_TRANSPORT link_type;
  472. } tBTA_DM_LINK_DOWN;
  473. /* Structure associated with BTA_DM_ROLE_CHG_EVT */
  474. typedef struct {
  475. RawAddress bd_addr; /* BD address peer device. */
  476. uint8_t new_role; /* the new connection role */
  477. } tBTA_DM_ROLE_CHG;
  478. /* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
  479. typedef struct {
  480. uint8_t level; /* when paging or inquiring, level is 10.
  481. Otherwise, the number of ACL links */
  482. uint8_t level_flags; /* indicates individual flags */
  483. } tBTA_DM_BUSY_LEVEL;
  484. #define BTA_IO_CAP_OUT BTM_IO_CAP_OUT /* 0 DisplayOnly */
  485. #define BTA_IO_CAP_IO BTM_IO_CAP_IO /* 1 DisplayYesNo */
  486. #define BTA_IO_CAP_IN BTM_IO_CAP_IN /* 2 KeyboardOnly */
  487. #define BTA_IO_CAP_NONE BTM_IO_CAP_NONE /* 3 NoInputNoOutput */
  488. #define BTA_IO_CAP_KBDISP BTM_IO_CAP_KBDISP /* 4 Keyboard display */
  489. typedef tBTM_IO_CAP tBTA_IO_CAP;
  490. #define BTA_AUTH_SP_NO \
  491. BTM_AUTH_SP_NO /* 0 MITM Protection Not Required - Single \
  492. Profile/non-bonding \
  493. Numeric comparison with automatic accept allowed */
  494. #define BTA_AUTH_SP_YES \
  495. BTM_AUTH_SP_YES /* 1 MITM Protection Required - Single Profile/non-bonding \
  496. Use IO Capabilities to determine authentication procedure \
  497. */
  498. #define BTA_AUTH_AP_NO \
  499. BTM_AUTH_AP_NO /* 2 MITM Protection Not Required - All Profiles/dedicated \
  500. bonding \
  501. Numeric comparison with automatic accept allowed */
  502. #define BTA_AUTH_AP_YES \
  503. BTM_AUTH_AP_YES /* 3 MITM Protection Required - All Profiles/dedicated \
  504. bonding \
  505. Use IO Capabilities to determine authentication procedure \
  506. */
  507. #define BTA_AUTH_SPGB_NO \
  508. BTM_AUTH_SPGB_NO /* 4 MITM Protection Not Required - Single Profiles/general \
  509. bonding \
  510. Numeric comparison with automatic accept allowed */
  511. #define BTA_AUTH_SPGB_YES \
  512. BTM_AUTH_SPGB_YES /* 5 MITM Protection Required - Single Profiles/general \
  513. bonding \
  514. Use IO Capabilities to determine authentication \
  515. procedure */
  516. typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
  517. #define BTA_AUTH_DD_BOND \
  518. BTM_AUTH_DD_BOND /* 2 this bit is set for dedicated bonding */
  519. #define BTA_AUTH_GEN_BOND \
  520. BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */
  521. #define BTA_AUTH_BONDS \
  522. BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits */
  523. #define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/
  524. #define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND /* 1 << 0 */
  525. #define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM /* 1 << 2 */
  526. #define BTA_LE_AUTH_REQ_SC_ONLY BTM_LE_AUTH_REQ_SC_ONLY /* 1 << 3 */
  527. #define BTA_LE_AUTH_REQ_SC_BOND BTM_LE_AUTH_REQ_SC_BOND /* 1001 */
  528. #define BTA_LE_AUTH_REQ_SC_MITM BTM_LE_AUTH_REQ_SC_MITM /* 1100 */
  529. #define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */
  530. typedef tBTM_LE_AUTH_REQ
  531. tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */
  532. #define BTA_OOB_NONE BTM_OOB_NONE
  533. #define BTA_OOB_PRESENT BTM_OOB_PRESENT
  534. #define BTA_OOB_UNKNOWN BTM_OOB_UNKNOWN
  535. typedef tBTM_OOB_DATA tBTA_OOB_DATA;
  536. /* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
  537. typedef struct {
  538. /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
  539. * order */
  540. RawAddress bd_addr; /* peer address */
  541. DEV_CLASS dev_class; /* peer CoD */
  542. BD_NAME bd_name; /* peer device name */
  543. uint32_t num_val; /* the numeric value for comparison. If just_works, do not
  544. show this number to UI */
  545. bool just_works; /* true, if "Just Works" association model */
  546. tBTA_AUTH_REQ loc_auth_req; /* Authentication required for local device */
  547. tBTA_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */
  548. tBTA_IO_CAP loc_io_caps; /* IO Capabilities of local device */
  549. tBTA_AUTH_REQ rmt_io_caps; /* IO Capabilities of remote device */
  550. } tBTA_DM_SP_CFM_REQ;
  551. enum {
  552. BTA_SP_KEY_STARTED, /* passkey entry started */
  553. BTA_SP_KEY_ENTERED, /* passkey digit entered */
  554. BTA_SP_KEY_ERASED, /* passkey digit erased */
  555. BTA_SP_KEY_CLEARED, /* passkey cleared */
  556. BTA_SP_KEY_COMPLT /* passkey entry completed */
  557. };
  558. typedef uint8_t tBTA_SP_KEY_TYPE;
  559. /* Structure associated with BTA_DM_SP_KEYPRESS_EVT */
  560. typedef struct {
  561. RawAddress bd_addr; /* peer address */
  562. tBTA_SP_KEY_TYPE notif_type;
  563. } tBTA_DM_SP_KEY_PRESS;
  564. /* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
  565. typedef struct {
  566. /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
  567. * order */
  568. RawAddress bd_addr; /* peer address */
  569. DEV_CLASS dev_class; /* peer CoD */
  570. BD_NAME bd_name; /* peer device name */
  571. uint32_t passkey; /* the numeric value for comparison. If just_works, do not
  572. show this number to UI */
  573. } tBTA_DM_SP_KEY_NOTIF;
  574. /* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
  575. typedef struct {
  576. /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
  577. * order */
  578. RawAddress bd_addr; /* peer address */
  579. DEV_CLASS dev_class; /* peer CoD */
  580. BD_NAME bd_name; /* peer device name */
  581. } tBTA_DM_SP_RMT_OOB;
  582. /* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
  583. typedef struct {
  584. tBTA_STATUS result; /* true of bond cancel succeeded, false if failed. */
  585. } tBTA_DM_BOND_CANCEL_CMPL;
  586. /* Union of all security callback structures */
  587. typedef union {
  588. tBTA_DM_ENABLE enable; /* BTA enabled */
  589. tBTA_DM_PIN_REQ pin_req; /* PIN request. */
  590. tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */
  591. tBTA_DM_AUTHORIZE authorize; /* Authorization request. */
  592. tBTA_DM_LINK_UP link_up; /* ACL connection down event */
  593. tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */
  594. tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */
  595. tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */
  596. tBTA_DM_SP_KEY_NOTIF key_notif; /* passkey notification */
  597. tBTA_DM_SP_RMT_OOB rmt_oob; /* remote oob */
  598. tBTA_DM_BOND_CANCEL_CMPL
  599. bond_cancel_cmpl; /* Bond Cancel Complete indication */
  600. tBTA_DM_SP_KEY_PRESS key_press; /* key press notification event */
  601. tBTA_DM_ROLE_CHG role_chg; /* role change event */
  602. tBTA_DM_BLE_SEC_REQ ble_req; /* BLE SMP related request */
  603. tBTA_DM_BLE_KEY ble_key; /* BLE SMP keys used when pairing */
  604. tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
  605. Octet16 ble_er; /* ER event data */
  606. } tBTA_DM_SEC;
  607. /* Security callback */
  608. typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data);
  609. #define BTA_DM_BLE_PF_LIST_LOGIC_OR 1
  610. #define BTA_DM_BLE_PF_FILT_LOGIC_OR 0
  611. /* Search callback events */
  612. #define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */
  613. #define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
  614. #define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
  615. #define BTA_DM_DISC_BLE_RES_EVT \
  616. 3 /* Discovery result for BLE GATT based servoce on a peer device. */
  617. #define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */
  618. #define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */
  619. #define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
  620. typedef uint8_t tBTA_DM_SEARCH_EVT;
  621. #define BTA_DM_INQ_RES_IGNORE_RSSI \
  622. BTM_INQ_RES_IGNORE_RSSI /* 0x7f RSSI value not supplied (ignore it) */
  623. /* Structure associated with BTA_DM_INQ_RES_EVT */
  624. typedef struct {
  625. RawAddress bd_addr; /* BD address peer device. */
  626. DEV_CLASS dev_class; /* Device class of peer device. */
  627. bool remt_name_not_required; /* Application sets this flag if it already knows
  628. the name of the device */
  629. /* If the device name is known to application BTA skips the remote name
  630. * request */
  631. bool is_limited; /* true, if the limited inquiry bit is set in the CoD */
  632. int8_t rssi; /* The rssi value */
  633. uint8_t* p_eir; /* received EIR */
  634. uint16_t eir_len; /* received EIR length */
  635. uint8_t inq_result_type;
  636. uint8_t ble_addr_type;
  637. uint16_t ble_evt_type;
  638. uint8_t ble_primary_phy;
  639. uint8_t ble_secondary_phy;
  640. uint8_t ble_advertising_sid;
  641. int8_t ble_tx_power;
  642. uint16_t ble_periodic_adv_int;
  643. tBT_DEVICE_TYPE device_type;
  644. uint8_t flag;
  645. } tBTA_DM_INQ_RES;
  646. /* Structure associated with BTA_DM_INQ_CMPL_EVT */
  647. typedef struct {
  648. uint8_t num_resps; /* Number of inquiry responses. */
  649. } tBTA_DM_INQ_CMPL;
  650. /* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
  651. typedef struct {
  652. RawAddress bd_addr; /* BD address peer device. */
  653. uint8_t num_record; /* Number of DI record */
  654. tBTA_STATUS result;
  655. } tBTA_DM_DI_DISC_CMPL;
  656. /* Structure associated with BTA_DM_DISC_RES_EVT */
  657. typedef struct {
  658. RawAddress bd_addr; /* BD address peer device. */
  659. BD_NAME bd_name; /* Name of peer device. */
  660. tBTA_SERVICE_MASK services; /* Services found on peer device. */
  661. uint8_t* p_raw_data; /* Raw data for discovery DB */
  662. uint32_t raw_data_size; /* size of raw data */
  663. tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
  664. uint32_t num_uuids;
  665. bluetooth::Uuid* p_uuid_list;
  666. tBTA_STATUS result;
  667. } tBTA_DM_DISC_RES;
  668. /* Structure associated with tBTA_DM_DISC_BLE_RES */
  669. typedef struct {
  670. RawAddress bd_addr; /* BD address peer device. */
  671. BD_NAME bd_name; /* Name of peer device. */
  672. bluetooth::Uuid service; /* GATT based Services UUID found on peer device. */
  673. } tBTA_DM_DISC_BLE_RES;
  674. /* Union of all search callback structures */
  675. typedef union {
  676. tBTA_DM_INQ_RES inq_res; /* Inquiry result for a peer device. */
  677. tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
  678. tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
  679. tBTA_DM_DISC_BLE_RES
  680. disc_ble_res; /* discovery result for GATT based service */
  681. tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
  682. } tBTA_DM_SEARCH;
  683. /* Search callback */
  684. typedef void(tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event,
  685. tBTA_DM_SEARCH* p_data);
  686. /* Execute call back */
  687. typedef void(tBTA_DM_EXEC_CBACK)(void* p_param);
  688. /* Encryption callback*/
  689. typedef void(tBTA_DM_ENCRYPT_CBACK)(const RawAddress& bd_addr,
  690. tBTA_TRANSPORT transport,
  691. tBTA_STATUS result);
  692. #define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
  693. #define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT
  694. #define BTA_DM_BLE_SEC_NO_MITM BTM_BLE_SEC_ENCRYPT_NO_MITM
  695. #define BTA_DM_BLE_SEC_MITM BTM_BLE_SEC_ENCRYPT_MITM
  696. typedef tBTM_BLE_SEC_ACT tBTA_DM_BLE_SEC_ACT;
  697. typedef tBTM_BLE_TX_TIME_MS tBTA_DM_BLE_TX_TIME_MS;
  698. typedef tBTM_BLE_RX_TIME_MS tBTA_DM_BLE_RX_TIME_MS;
  699. typedef tBTM_BLE_IDLE_TIME_MS tBTA_DM_BLE_IDLE_TIME_MS;
  700. typedef tBTM_BLE_ENERGY_USED tBTA_DM_BLE_ENERGY_USED;
  701. #define BTA_DM_CONTRL_UNKNOWN 0 /* Unknown state */
  702. #define BTA_DM_CONTRL_ACTIVE 1 /* ACL link on, SCO link ongoing, sniff mode */
  703. #define BTA_DM_CONTRL_SCAN \
  704. 2 /* Scan state - paging/inquiry/trying to \
  705. connect*/
  706. #define BTA_DM_CONTRL_IDLE \
  707. 3 /* Idle state - page scan, LE advt, inquiry scan \
  708. */
  709. typedef uint8_t tBTA_DM_CONTRL_STATE;
  710. typedef uint8_t tBTA_DM_BLE_ADV_STATE;
  711. typedef uint8_t tBTA_DM_BLE_ADV_INFO_PRESENT;
  712. typedef uint8_t tBTA_DM_BLE_RSSI_VALUE;
  713. typedef uint16_t tBTA_DM_BLE_ADV_INFO_TIMESTAMP;
  714. typedef void(tBTA_BLE_ENERGY_INFO_CBACK)(tBTA_DM_BLE_TX_TIME_MS tx_time,
  715. tBTA_DM_BLE_RX_TIME_MS rx_time,
  716. tBTA_DM_BLE_IDLE_TIME_MS idle_time,
  717. tBTA_DM_BLE_ENERGY_USED energy_used,
  718. tBTA_DM_CONTRL_STATE ctrl_state,
  719. tBTA_STATUS status);
  720. /* Maximum service name length */
  721. #define BTA_SERVICE_NAME_LEN 35
  722. #define BTA_SERVICE_DESP_LEN BTA_SERVICE_NAME_LEN
  723. #define BTA_PROVIDER_NAME_LEN BTA_SERVICE_NAME_LEN
  724. /* link policy masks */
  725. #define BTA_DM_LP_SWITCH HCI_ENABLE_MASTER_SLAVE_SWITCH
  726. #define BTA_DM_LP_HOLD HCI_ENABLE_HOLD_MODE
  727. #define BTA_DM_LP_SNIFF HCI_ENABLE_SNIFF_MODE
  728. #define BTA_DM_LP_PARK HCI_ENABLE_PARK_MODE
  729. typedef uint16_t tBTA_DM_LP_MASK;
  730. /* power mode actions */
  731. #define BTA_DM_PM_NO_ACTION 0x00 /* no change to the current pm setting */
  732. #define BTA_DM_PM_PARK 0x10 /* prefers park mode */
  733. #define BTA_DM_PM_SNIFF 0x20 /* prefers sniff mode */
  734. #define BTA_DM_PM_SNIFF1 0x21 /* prefers sniff1 mode */
  735. #define BTA_DM_PM_SNIFF2 0x22 /* prefers sniff2 mode */
  736. #define BTA_DM_PM_SNIFF3 0x23 /* prefers sniff3 mode */
  737. #define BTA_DM_PM_SNIFF4 0x24 /* prefers sniff4 mode */
  738. #define BTA_DM_PM_SNIFF5 0x25 /* prefers sniff5 mode */
  739. #define BTA_DM_PM_SNIFF6 0x26 /* prefers sniff6 mode */
  740. #define BTA_DM_PM_SNIFF7 0x27 /* prefers sniff7 mode */
  741. #define BTA_DM_PM_SNIFF_USER0 \
  742. 0x28 /* prefers user-defined sniff0 mode (testtool only) */
  743. #define BTA_DM_PM_SNIFF_USER1 \
  744. 0x29 /* prefers user-defined sniff1 mode (testtool only) */
  745. #define BTA_DM_PM_ACTIVE 0x40 /* prefers active mode */
  746. #define BTA_DM_PM_RETRY 0x80 /* retry power mode based on current settings */
  747. #define BTA_DM_PM_SUSPEND 0x04 /* prefers suspend mode */
  748. #define BTA_DM_PM_NO_PREF \
  749. 0x01 /* service has no prefernce on power mode setting. eg. connection to \
  750. service got closed */
  751. typedef uint8_t tBTA_DM_PM_ACTION;
  752. /* index to bta_dm_ssr_spec */
  753. #define BTA_DM_PM_SSR0 0
  754. #define BTA_DM_PM_SSR1 \
  755. 1 /* BTA_DM_PM_SSR1 will be dedicated for \
  756. HH SSR setting entry, no other profile can use it */
  757. #define BTA_DM_PM_SSR2 2
  758. #define BTA_DM_PM_SSR3 3
  759. #define BTA_DM_PM_SSR4 4
  760. #define BTA_DM_PM_SSR5 5
  761. #define BTA_DM_PM_SSR6 6
  762. #define BTA_DM_PM_NUM_EVTS 9
  763. #ifndef BTA_DM_PM_PARK_IDX
  764. #define BTA_DM_PM_PARK_IDX \
  765. 6 /* the actual index to bta_dm_pm_md[] for PARK mode */
  766. #endif
  767. #ifndef BTA_DM_PM_SNIFF_A2DP_IDX
  768. #define BTA_DM_PM_SNIFF_A2DP_IDX BTA_DM_PM_SNIFF
  769. #endif
  770. #ifndef BTA_DM_PM_SNIFF_HD_IDLE_IDX
  771. #define BTA_DM_PM_SNIFF_HD_IDLE_IDX BTA_DM_PM_SNIFF2
  772. #endif
  773. #ifndef BTA_DM_PM_SNIFF_SCO_OPEN_IDX
  774. #define BTA_DM_PM_SNIFF_SCO_OPEN_IDX BTA_DM_PM_SNIFF3
  775. #endif
  776. #ifndef BTA_DM_PM_SNIFF_HD_ACTIVE_IDX
  777. #define BTA_DM_PM_SNIFF_HD_ACTIVE_IDX BTA_DM_PM_SNIFF4
  778. #endif
  779. #ifndef BTA_DM_PM_SNIFF_HH_OPEN_IDX
  780. #define BTA_DM_PM_SNIFF_HH_OPEN_IDX BTA_DM_PM_SNIFF2
  781. #endif
  782. #ifndef BTA_DM_PM_SNIFF_HH_ACTIVE_IDX
  783. #define BTA_DM_PM_SNIFF_HH_ACTIVE_IDX BTA_DM_PM_SNIFF2
  784. #endif
  785. #ifndef BTA_DM_PM_SNIFF_HH_IDLE_IDX
  786. #define BTA_DM_PM_SNIFF_HH_IDLE_IDX BTA_DM_PM_SNIFF2
  787. #endif
  788. #ifndef BTA_DM_PM_HH_OPEN_DELAY
  789. #define BTA_DM_PM_HH_OPEN_DELAY 30000
  790. #endif
  791. #ifndef BTA_DM_PM_HH_ACTIVE_DELAY
  792. #define BTA_DM_PM_HH_ACTIVE_DELAY 30000
  793. #endif
  794. #ifndef BTA_DM_PM_HH_IDLE_DELAY
  795. #define BTA_DM_PM_HH_IDLE_DELAY 30000
  796. #endif
  797. /* The Sniff Parameters defined below must be ordered from highest
  798. * latency (biggest interval) to lowest latency. If there is a conflict
  799. * among the connected services the setting with the lowest latency will
  800. * be selected. If a device should override a sniff parameter then it
  801. * must insure that order is maintained.
  802. */
  803. #ifndef BTA_DM_PM_SNIFF_MAX
  804. #define BTA_DM_PM_SNIFF_MAX 800
  805. #define BTA_DM_PM_SNIFF_MIN 400
  806. #define BTA_DM_PM_SNIFF_ATTEMPT 4
  807. #define BTA_DM_PM_SNIFF_TIMEOUT 1
  808. #endif
  809. #ifndef BTA_DM_PM_SNIFF1_MAX
  810. #define BTA_DM_PM_SNIFF1_MAX 400
  811. #define BTA_DM_PM_SNIFF1_MIN 200
  812. #define BTA_DM_PM_SNIFF1_ATTEMPT 4
  813. #define BTA_DM_PM_SNIFF1_TIMEOUT 1
  814. #endif
  815. #ifndef BTA_DM_PM_SNIFF2_MAX
  816. #define BTA_DM_PM_SNIFF2_MAX 54
  817. #define BTA_DM_PM_SNIFF2_MIN 30
  818. #define BTA_DM_PM_SNIFF2_ATTEMPT 4
  819. #define BTA_DM_PM_SNIFF2_TIMEOUT 1
  820. #endif
  821. #ifndef BTA_DM_PM_SNIFF3_MAX
  822. #define BTA_DM_PM_SNIFF3_MAX 150
  823. #define BTA_DM_PM_SNIFF3_MIN 50
  824. #define BTA_DM_PM_SNIFF3_ATTEMPT 4
  825. #define BTA_DM_PM_SNIFF3_TIMEOUT 1
  826. #endif
  827. #ifndef BTA_DM_PM_SNIFF4_MAX
  828. #define BTA_DM_PM_SNIFF4_MAX 18
  829. #define BTA_DM_PM_SNIFF4_MIN 10
  830. #define BTA_DM_PM_SNIFF4_ATTEMPT 4
  831. #define BTA_DM_PM_SNIFF4_TIMEOUT 1
  832. #endif
  833. #ifndef BTA_DM_PM_SNIFF5_MAX
  834. #define BTA_DM_PM_SNIFF5_MAX 36
  835. #define BTA_DM_PM_SNIFF5_MIN 30
  836. #define BTA_DM_PM_SNIFF5_ATTEMPT 2
  837. #define BTA_DM_PM_SNIFF5_TIMEOUT 0
  838. #endif
  839. #ifndef BTA_DM_PM_SNIFF6_MAX
  840. #define BTA_DM_PM_SNIFF6_MAX 18
  841. #define BTA_DM_PM_SNIFF6_MIN 14
  842. #define BTA_DM_PM_SNIFF6_ATTEMPT 1
  843. #define BTA_DM_PM_SNIFF6_TIMEOUT 0
  844. #endif
  845. #ifndef BTA_DM_PM_PARK_MAX
  846. #define BTA_DM_PM_PARK_MAX 800
  847. #define BTA_DM_PM_PARK_MIN 400
  848. #define BTA_DM_PM_PARK_ATTEMPT 0
  849. #define BTA_DM_PM_PARK_TIMEOUT 0
  850. #endif
  851. /* Switch callback events */
  852. #define BTA_DM_SWITCH_CMPL_EVT 0 /* Completion of the Switch API */
  853. typedef uint8_t tBTA_DM_SWITCH_EVT;
  854. typedef void(tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event,
  855. tBTA_STATUS status);
  856. /* Audio routing out configuration */
  857. #define BTA_DM_ROUTE_NONE 0x00 /* No Audio output */
  858. #define BTA_DM_ROUTE_DAC 0x01 /* routing over analog output */
  859. #define BTA_DM_ROUTE_I2S 0x02 /* routing over digital (I2S) output */
  860. #define BTA_DM_ROUTE_BT_MONO 0x04 /* routing over SCO */
  861. #define BTA_DM_ROUTE_BT_STEREO 0x08 /* routing over BT Stereo */
  862. #define BTA_DM_ROUTE_HOST 0x10 /* routing over Host */
  863. #define BTA_DM_ROUTE_FMTX 0x20 /* routing over FMTX */
  864. #define BTA_DM_ROUTE_FMRX 0x40 /* routing over FMRX */
  865. #define BTA_DM_ROUTE_BTSNK 0x80 /* routing over BT SNK */
  866. typedef uint8_t tBTA_DM_ROUTE_PATH;
  867. /* Device Identification (DI) data structure
  868. */
  869. /* Used to set the DI record */
  870. typedef tSDP_DI_RECORD tBTA_DI_RECORD;
  871. /* Used to get the DI record */
  872. typedef tSDP_DI_GET_RECORD tBTA_DI_GET_RECORD;
  873. /* SDP discovery database */
  874. typedef tSDP_DISCOVERY_DB tBTA_DISCOVERY_DB;
  875. #ifndef BTA_DI_NUM_MAX
  876. #define BTA_DI_NUM_MAX 3
  877. #endif
  878. /* Device features mask definitions */
  879. #define BTA_FEATURE_BYTES_PER_PAGE BTM_FEATURE_BYTES_PER_PAGE
  880. #define BTA_EXT_FEATURES_PAGE_MAX BTM_EXT_FEATURES_PAGE_MAX
  881. /* ACL type
  882. */
  883. #define BTA_DM_LINK_TYPE_BR_EDR 0x01
  884. #define BTA_DM_LINK_TYPE_LE 0x02
  885. #define BTA_DM_LINK_TYPE_ALL 0xFF
  886. typedef uint8_t tBTA_DM_LINK_TYPE;
  887. #define IMMEDIATE_DELY_MODE 0x00
  888. #define ONFOUND_DELY_MODE 0x01
  889. #define BATCH_DELY_MODE 0x02
  890. #define ALLOW_ALL_FILTER 0x00
  891. #define LOWEST_RSSI_VALUE 129
  892. /*****************************************************************************
  893. * External Function Declarations
  894. ****************************************************************************/
  895. /*******************************************************************************
  896. *
  897. * Function BTA_EnableBluetooth
  898. *
  899. * Description This function initializes BTA and prepares BTA and the
  900. * Bluetooth protocol stack for use. This function is
  901. * typically called at startup or when Bluetooth services
  902. * are required by the phone. This function must be called
  903. * before calling any other API function.
  904. *
  905. *
  906. * Returns BTA_SUCCESS if successful.
  907. * BTA_FAIL if internal failure.
  908. *
  909. ******************************************************************************/
  910. extern tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK* p_cback);
  911. /*******************************************************************************
  912. *
  913. * Function BTA_DisableBluetooth
  914. *
  915. * Description This function disables BTA and the Bluetooth protocol
  916. * stack. It is called when BTA is no longer being used
  917. * by any application in the system.
  918. *
  919. *
  920. * Returns void
  921. *
  922. ******************************************************************************/
  923. extern tBTA_STATUS BTA_DisableBluetooth(void);
  924. /*******************************************************************************
  925. *
  926. * Function BTA_EnableTestMode
  927. *
  928. * Description Enables bluetooth device under test mode
  929. *
  930. *
  931. * Returns tBTA_STATUS
  932. *
  933. ******************************************************************************/
  934. extern void BTA_EnableTestMode(void);
  935. /*******************************************************************************
  936. *
  937. * Function BTA_DisableTestMode
  938. *
  939. * Description Disable bluetooth device under test mode
  940. *
  941. *
  942. * Returns None
  943. *
  944. ******************************************************************************/
  945. extern void BTA_DisableTestMode(void);
  946. /*******************************************************************************
  947. *
  948. * Function BTA_DmSetDeviceName
  949. *
  950. * Description This function sets the Bluetooth name of the local device.
  951. *
  952. *
  953. * Returns void
  954. *
  955. ******************************************************************************/
  956. extern void BTA_DmSetDeviceName(char* p_name);
  957. /*******************************************************************************
  958. *
  959. * Function BTA_DmSetVisibility
  960. *
  961. * Description This function sets the Bluetooth connectable,discoverable,
  962. * pairable and conn paired only modesmodes of the local
  963. * device.
  964. * This controls whether other Bluetooth devices can find and
  965. * connect to the local device.
  966. *
  967. *
  968. * Returns void
  969. *
  970. ******************************************************************************/
  971. extern void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode,
  972. uint8_t pairable_mode, uint8_t conn_filter);
  973. /*******************************************************************************
  974. *
  975. * Function BTA_DmSearch
  976. *
  977. * Description This function searches for peer Bluetooth devices. It
  978. * first performs an inquiry; for each device found from the
  979. * inquiry it gets the remote name of the device. If
  980. * parameter services is nonzero, service discovery will be
  981. * performed on each device for the services specified.
  982. *
  983. *
  984. * Returns void
  985. *
  986. ******************************************************************************/
  987. extern void BTA_DmSearch(tBTA_DM_INQ* p_dm_inq, tBTA_SERVICE_MASK services,
  988. tBTA_DM_SEARCH_CBACK* p_cback);
  989. /*******************************************************************************
  990. *
  991. * Function BTA_DmSearchCancel
  992. *
  993. * Description This function cancels a search that has been initiated
  994. * by calling BTA_DmSearch().
  995. *
  996. *
  997. * Returns void
  998. *
  999. ******************************************************************************/
  1000. extern void BTA_DmSearchCancel(void);
  1001. /*******************************************************************************
  1002. *
  1003. * Function BTA_DmDiscover
  1004. *
  1005. * Description This function performs service discovery for the services
  1006. * of a particular peer device.
  1007. *
  1008. *
  1009. * Returns void
  1010. *
  1011. ******************************************************************************/
  1012. extern void BTA_DmDiscover(const RawAddress& bd_addr,
  1013. tBTA_SERVICE_MASK services,
  1014. tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search);
  1015. /*******************************************************************************
  1016. *
  1017. * Function BTA_DmDiscoverUUID
  1018. *
  1019. * Description This function performs service discovery for the services
  1020. * of a particular peer device.
  1021. *
  1022. *
  1023. * Returns void
  1024. *
  1025. ******************************************************************************/
  1026. extern void BTA_DmDiscoverUUID(const RawAddress& bd_addr,
  1027. const bluetooth::Uuid& uuid,
  1028. tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search);
  1029. /*******************************************************************************
  1030. *
  1031. * Function BTA_DmGetCachedRemoteName
  1032. *
  1033. * Description Retieve cached remote name if available
  1034. *
  1035. * Returns BTA_SUCCESS if cached name was retrieved
  1036. * BTA_FAILURE if cached name is not available
  1037. *
  1038. ******************************************************************************/
  1039. tBTA_STATUS BTA_DmGetCachedRemoteName(const RawAddress& remote_device,
  1040. uint8_t** pp_cached_name);
  1041. /*******************************************************************************
  1042. *
  1043. * Function BTA_DmBond
  1044. *
  1045. * Description This function initiates a bonding procedure with a peer
  1046. * device. The bonding procedure enables authentication
  1047. * and optionally encryption on the Bluetooth link.
  1048. *
  1049. *
  1050. * Returns void
  1051. *
  1052. ******************************************************************************/
  1053. extern void BTA_DmBond(const RawAddress& bd_addr);
  1054. /*******************************************************************************
  1055. *
  1056. * Function BTA_DmBondByTransport
  1057. *
  1058. * Description This function initiates a bonding procedure with a peer
  1059. * device by designated transport. The bonding procedure
  1060. * enables authentication and optionally encryption on the
  1061. * Bluetooth link.
  1062. *
  1063. *
  1064. * Returns void
  1065. *
  1066. ******************************************************************************/
  1067. extern void BTA_DmBondByTransport(const RawAddress& bd_addr,
  1068. tBTA_TRANSPORT transport);
  1069. /*******************************************************************************
  1070. *
  1071. * Function BTA_DmBondCancel
  1072. *
  1073. * Description This function cancels a bonding procedure with a peer
  1074. * device.
  1075. *
  1076. *
  1077. * Returns void
  1078. *
  1079. ******************************************************************************/
  1080. extern void BTA_DmBondCancel(const RawAddress& bd_addr);
  1081. /*******************************************************************************
  1082. *
  1083. * Function BTA_DmPinReply
  1084. *
  1085. * Description This function provides a PIN when one is requested by DM
  1086. * during a bonding procedure. The application should call
  1087. * this function after the security callback is called with
  1088. * a BTA_DM_PIN_REQ_EVT.
  1089. *
  1090. *
  1091. * Returns void
  1092. *
  1093. ******************************************************************************/
  1094. extern void BTA_DmPinReply(const RawAddress& bd_addr, bool accept,
  1095. uint8_t pin_len, uint8_t* p_pin);
  1096. /*******************************************************************************
  1097. *
  1098. * Function BTA_DmLocalOob
  1099. *
  1100. * Description This function retrieves the OOB data from local controller.
  1101. * The result is reported by bta_dm_co_loc_oob().
  1102. *
  1103. * Returns void
  1104. *
  1105. ******************************************************************************/
  1106. extern void BTA_DmLocalOob(void);
  1107. /*******************************************************************************
  1108. *
  1109. * Function BTA_DmConfirm
  1110. *
  1111. * Description This function accepts or rejects the numerical value of the
  1112. * Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
  1113. *
  1114. * Returns void
  1115. *
  1116. ******************************************************************************/
  1117. extern void BTA_DmConfirm(const RawAddress& bd_addr, bool accept);
  1118. /*******************************************************************************
  1119. *
  1120. * Function BTA_DmAddDevice
  1121. *
  1122. * Description This function adds a device to the security database list
  1123. * of peer devices. This function would typically be called
  1124. * at system startup to initialize the security database with
  1125. * known peer devices. This is a direct execution function
  1126. * that may lock task scheduling on some platforms.
  1127. *
  1128. * Returns void
  1129. *
  1130. ******************************************************************************/
  1131. extern void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
  1132. const LinkKey& link_key,
  1133. tBTA_SERVICE_MASK trusted_mask, bool is_trusted,
  1134. uint8_t key_type, tBTA_IO_CAP io_cap,
  1135. uint8_t pin_length);
  1136. /*******************************************************************************
  1137. *
  1138. * Function BTA_DmRemoveDevice
  1139. *
  1140. * Description This function removes a device from the security database.
  1141. * This is a direct execution function that may lock task
  1142. * scheduling on some platforms.
  1143. *
  1144. *
  1145. * Returns BTA_SUCCESS if successful.
  1146. * BTA_FAIL if operation failed.
  1147. *
  1148. ******************************************************************************/
  1149. extern tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr);
  1150. /*******************************************************************************
  1151. *
  1152. * Function BTA_GetEirService
  1153. *
  1154. * Description This function is called to get BTA service mask from EIR.
  1155. *
  1156. * Parameters p_eir - pointer of EIR significant part
  1157. * eir_len - EIR length
  1158. * p_services - return the BTA service mask
  1159. *
  1160. * Returns None
  1161. *
  1162. ******************************************************************************/
  1163. extern void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
  1164. tBTA_SERVICE_MASK* p_services);
  1165. /*******************************************************************************
  1166. *
  1167. * Function BTA_DmGetConnectionState
  1168. *
  1169. * Description Returns whether the remote device is currently connected.
  1170. *
  1171. * Returns 0 if the device is NOT connected.
  1172. *
  1173. ******************************************************************************/
  1174. extern uint16_t BTA_DmGetConnectionState(const RawAddress& bd_addr);
  1175. /*******************************************************************************
  1176. *
  1177. * Function BTA_DmSetLocalDiRecord
  1178. *
  1179. * Description This function adds a DI record to the local SDP database.
  1180. *
  1181. * Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
  1182. *
  1183. ******************************************************************************/
  1184. extern tBTA_STATUS BTA_DmSetLocalDiRecord(tBTA_DI_RECORD* p_device_info,
  1185. uint32_t* p_handle);
  1186. /*******************************************************************************
  1187. *
  1188. *
  1189. * Function BTA_DmCloseACL
  1190. *
  1191. * Description This function force to close an ACL connection and remove
  1192. the
  1193. * device from the security database list of known devices.
  1194. *
  1195. * Parameters: bd_addr - Address of the peer device
  1196. * remove_dev - remove device or not after link down
  1197. * transport - which transport to close
  1198. *
  1199. * Returns void.
  1200. *
  1201. ******************************************************************************/
  1202. extern void BTA_DmCloseACL(const RawAddress& bd_addr, bool remove_dev,
  1203. tBTA_TRANSPORT transport);
  1204. /* BLE related API functions */
  1205. /*******************************************************************************
  1206. *
  1207. * Function BTA_DmBleSecurityGrant
  1208. *
  1209. * Description Grant security request access.
  1210. *
  1211. * Parameters: bd_addr - BD address of the peer
  1212. * res - security grant status.
  1213. *
  1214. * Returns void
  1215. *
  1216. ******************************************************************************/
  1217. extern void BTA_DmBleSecurityGrant(const RawAddress& bd_addr,
  1218. tBTA_DM_BLE_SEC_GRANT res);
  1219. /*******************************************************************************
  1220. *
  1221. * Function BTA_DmBlePasskeyReply
  1222. *
  1223. * Description Send BLE SMP passkey reply.
  1224. *
  1225. * Parameters: bd_addr - BD address of the peer
  1226. * accept - passkey entry sucessful or declined.
  1227. * passkey - passkey value, must be a 6 digit number,
  1228. * can be lead by 0.
  1229. *
  1230. * Returns void
  1231. *
  1232. ******************************************************************************/
  1233. extern void BTA_DmBlePasskeyReply(const RawAddress& bd_addr, bool accept,
  1234. uint32_t passkey);
  1235. /*******************************************************************************
  1236. *
  1237. * Function BTA_DmBleConfirmReply
  1238. *
  1239. * Description Send BLE SMP SC user confirmation reply.
  1240. *
  1241. * Parameters: bd_addr - BD address of the peer
  1242. * accept - numbers to compare are the same or
  1243. * different.
  1244. *
  1245. * Returns void
  1246. *
  1247. ******************************************************************************/
  1248. extern void BTA_DmBleConfirmReply(const RawAddress& bd_addr, bool accept);
  1249. /*******************************************************************************
  1250. *
  1251. * Function BTA_DmAddBleDevice
  1252. *
  1253. * Description Add a BLE device. This function will be normally called
  1254. * during host startup to restore all required information
  1255. * for a LE device stored in the NVRAM.
  1256. *
  1257. * Parameters: bd_addr - BD address of the peer
  1258. * dev_type - Remote device's device type.
  1259. * addr_type - LE device address type.
  1260. *
  1261. * Returns void
  1262. *
  1263. ******************************************************************************/
  1264. extern void BTA_DmAddBleDevice(const RawAddress& bd_addr,
  1265. tBLE_ADDR_TYPE addr_type,
  1266. tBT_DEVICE_TYPE dev_type);
  1267. /*******************************************************************************
  1268. *
  1269. * Function BTA_DmAddBleKey
  1270. *
  1271. * Description Add/modify LE device information. This function will be
  1272. * normally called during host startup to restore all required
  1273. * information stored in the NVRAM.
  1274. *
  1275. * Parameters: bd_addr - BD address of the peer
  1276. * p_le_key - LE key values.
  1277. * key_type - LE SMP key type.
  1278. *
  1279. * Returns void
  1280. *
  1281. ******************************************************************************/
  1282. extern void BTA_DmAddBleKey(const RawAddress& bd_addr,
  1283. tBTA_LE_KEY_VALUE* p_le_key,
  1284. tBTA_LE_KEY_TYPE key_type);
  1285. /*******************************************************************************
  1286. *
  1287. * Function BTA_DmSetBlePrefConnParams
  1288. *
  1289. * Description This function is called to set the preferred connection
  1290. * parameters when default connection parameter is not desired.
  1291. *
  1292. * Parameters: bd_addr - BD address of the peripheral
  1293. * min_conn_int - minimum preferred connection interval
  1294. * max_conn_int - maximum preferred connection interval
  1295. * slave_latency - preferred slave latency
  1296. * supervision_tout - preferred supervision timeout
  1297. *
  1298. *
  1299. * Returns void
  1300. *
  1301. ******************************************************************************/
  1302. extern void BTA_DmSetBlePrefConnParams(const RawAddress& bd_addr,
  1303. uint16_t min_conn_int,
  1304. uint16_t max_conn_int,
  1305. uint16_t slave_latency,
  1306. uint16_t supervision_tout);
  1307. /*******************************************************************************
  1308. *
  1309. * Function BTA_DmSetBleConnScanParams
  1310. *
  1311. * Description This function is called to set scan parameters used in
  1312. * BLE connection request
  1313. *
  1314. * Parameters: scan_interval - scan interval
  1315. * scan_window - scan window
  1316. *
  1317. * Returns void
  1318. *
  1319. ******************************************************************************/
  1320. extern void BTA_DmSetBleConnScanParams(uint32_t scan_interval,
  1321. uint32_t scan_window);
  1322. /*******************************************************************************
  1323. *
  1324. * Function BTA_DmSearchExt
  1325. *
  1326. * Description This function searches for peer Bluetooth devices. It
  1327. * performs an inquiry and gets the remote name for devices.
  1328. * Service discovery is done if services is non zero
  1329. *
  1330. * Parameters p_dm_inq: inquiry conditions
  1331. * services: if service is not empty, service discovery will be
  1332. * done.
  1333. * for all GATT based service condition, put
  1334. * num_uuid, and p_uuid is the pointer to the list of
  1335. * UUID values.
  1336. * p_cback: callback functino when search is completed.
  1337. *
  1338. *
  1339. *
  1340. * Returns void
  1341. *
  1342. ******************************************************************************/
  1343. extern void BTA_DmSearchExt(tBTA_DM_INQ* p_dm_inq,
  1344. tBTA_SERVICE_MASK_EXT* p_services,
  1345. tBTA_DM_SEARCH_CBACK* p_cback);
  1346. /*******************************************************************************
  1347. *
  1348. * Function BTA_DmDiscoverExt
  1349. *
  1350. * Description This function does service discovery for services of a
  1351. * peer device. When services.num_uuid is 0, it indicates all
  1352. * GATT based services are to be searched; other wise a list of
  1353. * UUID of interested services should be provided through
  1354. * services.p_uuid.
  1355. *
  1356. *
  1357. *
  1358. * Returns void
  1359. *
  1360. ******************************************************************************/
  1361. extern void BTA_DmDiscoverExt(const RawAddress& bd_addr,
  1362. tBTA_SERVICE_MASK_EXT* p_services,
  1363. tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search);
  1364. /*******************************************************************************
  1365. *
  1366. * Function BTA_DmDiscoverByTransport
  1367. *
  1368. * Description This function does service discovery on particular transport
  1369. * for services of a
  1370. * peer device. When services.num_uuid is 0, it indicates all
  1371. * GATT based services are to be searched; other wise a list of
  1372. * UUID of interested services should be provided through
  1373. * p_services->p_uuid.
  1374. *
  1375. *
  1376. *
  1377. * Returns void
  1378. *
  1379. ******************************************************************************/
  1380. extern void BTA_DmDiscoverByTransport(const RawAddress& bd_addr,
  1381. tBTA_SERVICE_MASK_EXT* p_services,
  1382. tBTA_DM_SEARCH_CBACK* p_cback,
  1383. bool sdp_search,
  1384. tBTA_TRANSPORT transport);
  1385. /*******************************************************************************
  1386. *
  1387. * Function BTA_DmSetEncryption
  1388. *
  1389. * Description This function is called to ensure that connection is
  1390. * encrypted. Should be called only on an open connection.
  1391. * Typically only needed for connections that first want to
  1392. * bring up unencrypted links, then later encrypt them.
  1393. *
  1394. * Parameters: bd_addr - Address of the peer device
  1395. * transport - transport of the link to be encruypted
  1396. * p_callback - Pointer to callback function to indicat the
  1397. * link encryption status
  1398. * sec_act - This is the security action to indicate
  1399. * what kind of BLE security level is required
  1400. * for the BLE link if BLE is supported
  1401. * Note: This parameter is ignored for
  1402. * BR/EDR or if BLE is not supported.
  1403. *
  1404. * Returns void
  1405. *
  1406. *
  1407. ******************************************************************************/
  1408. extern void BTA_DmSetEncryption(const RawAddress& bd_addr,
  1409. tBTA_TRANSPORT transport,
  1410. tBTA_DM_ENCRYPT_CBACK* p_callback,
  1411. tBTA_DM_BLE_SEC_ACT sec_act);
  1412. /*******************************************************************************
  1413. *
  1414. * Function BTA_DmBleObserve
  1415. *
  1416. * Description This procedure keep the device listening for advertising
  1417. * events from a broadcast device.
  1418. *
  1419. * Parameters start: start or stop observe.
  1420. * duration : Duration of the scan. Continuous scan if 0 is
  1421. * passed
  1422. * p_results_cb: Callback to be called with scan results
  1423. *
  1424. * Returns void
  1425. *
  1426. ******************************************************************************/
  1427. extern void BTA_DmBleObserve(bool start, uint8_t duration,
  1428. tBTA_DM_SEARCH_CBACK* p_results_cb);
  1429. /*******************************************************************************
  1430. *
  1431. * Function BTA_DmBleConfigLocalPrivacy
  1432. *
  1433. * Description Enable/disable privacy on the local device
  1434. *
  1435. * Parameters: privacy_enable - enable/disabe privacy on remote device.
  1436. *
  1437. * Returns void
  1438. *
  1439. ******************************************************************************/
  1440. extern void BTA_DmBleConfigLocalPrivacy(bool privacy_enable);
  1441. /*******************************************************************************
  1442. *
  1443. * Function BTA_DmBleEnableRemotePrivacy
  1444. *
  1445. * Description Enable/disable privacy on a remote device
  1446. *
  1447. * Parameters: bd_addr - BD address of the peer
  1448. * privacy_enable - enable/disabe privacy on remote device.
  1449. *
  1450. * Returns void
  1451. *
  1452. ******************************************************************************/
  1453. extern void BTA_DmBleEnableRemotePrivacy(const RawAddress& bd_addr,
  1454. bool privacy_enable);
  1455. /*******************************************************************************
  1456. *
  1457. * Function BTA_DmBleUpdateConnectionParams
  1458. *
  1459. * Description Update connection parameters, can only be used when
  1460. * connection is up.
  1461. *
  1462. * Parameters: bd_addr - BD address of the peer
  1463. * min_int - minimum connection interval, [0x0004 ~ 0x4000]
  1464. * max_int - maximum connection interval, [0x0004 ~ 0x4000]
  1465. * latency - slave latency [0 ~ 500]
  1466. * timeout - supervision timeout [0x000a ~ 0xc80]
  1467. *
  1468. * Returns void
  1469. *
  1470. ******************************************************************************/
  1471. extern void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr,
  1472. uint16_t min_int, uint16_t max_int,
  1473. uint16_t latency, uint16_t timeout,
  1474. uint16_t min_ce_len,
  1475. uint16_t max_ce_len);
  1476. /*******************************************************************************
  1477. *
  1478. * Function BTA_DmBleSetDataLength
  1479. *
  1480. * Description This function is to set maximum LE data packet size
  1481. *
  1482. * Returns void
  1483. *
  1484. ******************************************************************************/
  1485. extern void BTA_DmBleSetDataLength(const RawAddress& remote_device,
  1486. uint16_t tx_data_length);
  1487. /*******************************************************************************
  1488. *
  1489. * Function BTA_DmBleGetEnergyInfo
  1490. *
  1491. * Description This function is called to obtain the energy info
  1492. *
  1493. * Parameters p_cmpl_cback - Command complete callback
  1494. *
  1495. * Returns void
  1496. *
  1497. ******************************************************************************/
  1498. extern void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback);
  1499. /*******************************************************************************
  1500. *
  1501. * Function BTA_BrcmInit
  1502. *
  1503. * Description This function initializes Broadcom specific VS handler in
  1504. * BTA
  1505. *
  1506. * Returns void
  1507. *
  1508. ******************************************************************************/
  1509. extern void BTA_VendorInit(void);
  1510. /*******************************************************************************
  1511. *
  1512. * Function BTA_BrcmCleanup
  1513. *
  1514. * Description This function frees up Broadcom specific VS specific dynamic
  1515. * memory
  1516. *
  1517. * Returns void
  1518. *
  1519. ******************************************************************************/
  1520. extern void BTA_VendorCleanup(void);
  1521. #endif /* BTA_API_H */