btm_api.h 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071
  1. /******************************************************************************
  2. *
  3. * Copyright 1999-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * This file contains the Bluetooth Manager (BTM) API function external
  21. * definitions.
  22. *
  23. ******************************************************************************/
  24. #ifndef BTM_API_H
  25. #define BTM_API_H
  26. #include "bt_target.h"
  27. #include "device/include/esco_parameters.h"
  28. #include "hcidefs.h"
  29. #include "sdp_api.h"
  30. #include "smp_api.h"
  31. #include "btm_api_types.h"
  32. /*****************************************************************************
  33. * DEVICE CONTROL and COMMON
  34. ****************************************************************************/
  35. /*****************************************************************************
  36. * EXTERNAL FUNCTION DECLARATIONS
  37. ****************************************************************************/
  38. /*****************************************************************************
  39. * DEVICE CONTROL and COMMON FUNCTIONS
  40. ****************************************************************************/
  41. /*******************************************************************************
  42. *
  43. * Function BTM_DeviceReset
  44. *
  45. * Description This function is called to reset the controller. The
  46. * Callback function if provided is called when startup of the
  47. * device has completed.
  48. *
  49. * Returns void
  50. *
  51. ******************************************************************************/
  52. extern void BTM_DeviceReset(tBTM_CMPL_CB* p_cb);
  53. /*******************************************************************************
  54. *
  55. * Function BTM_IsDeviceUp
  56. *
  57. * Description This function is called to check if the device is up.
  58. *
  59. * Returns true if device is up, else false
  60. *
  61. ******************************************************************************/
  62. extern bool BTM_IsDeviceUp(void);
  63. /*******************************************************************************
  64. *
  65. * Function BTM_SetLocalDeviceName
  66. *
  67. * Description This function is called to set the local device name.
  68. *
  69. * Returns BTM_CMD_STARTED if successful, otherwise an error
  70. *
  71. ******************************************************************************/
  72. extern tBTM_STATUS BTM_SetLocalDeviceName(char* p_name);
  73. /*******************************************************************************
  74. *
  75. * Function BTM_SetDeviceClass
  76. *
  77. * Description This function is called to set the local device class
  78. *
  79. * Returns BTM_SUCCESS if successful, otherwise an error
  80. *
  81. ******************************************************************************/
  82. extern tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class);
  83. /*******************************************************************************
  84. *
  85. * Function BTM_ReadLocalDeviceName
  86. *
  87. * Description This function is called to read the local device name.
  88. *
  89. * Returns status of the operation
  90. * If success, BTM_SUCCESS is returned and p_name points stored
  91. * local device name
  92. * If BTM doesn't store local device name, BTM_NO_RESOURCES is
  93. * is returned and p_name is set to NULL
  94. *
  95. ******************************************************************************/
  96. extern tBTM_STATUS BTM_ReadLocalDeviceName(char** p_name);
  97. /*******************************************************************************
  98. *
  99. * Function BTM_ReadLocalDeviceNameFromController
  100. *
  101. * Description Get local device name from controller. Do not use cached
  102. * name (used to get chip-id prior to btm reset complete).
  103. *
  104. * Returns BTM_CMD_STARTED if successful, otherwise an error
  105. *
  106. ******************************************************************************/
  107. extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController(
  108. tBTM_CMPL_CB* p_rln_cmpl_cback);
  109. /*******************************************************************************
  110. *
  111. * Function BTM_ReadDeviceClass
  112. *
  113. * Description This function is called to read the local device class
  114. *
  115. * Returns pointer to the device class
  116. *
  117. ******************************************************************************/
  118. extern uint8_t* BTM_ReadDeviceClass(void);
  119. /*******************************************************************************
  120. *
  121. * Function BTM_ReadLocalFeatures
  122. *
  123. * Description This function is called to read the local features
  124. *
  125. * Returns pointer to the local features string
  126. *
  127. ******************************************************************************/
  128. extern uint8_t* BTM_ReadLocalFeatures(void);
  129. /*******************************************************************************
  130. *
  131. * Function BTM_RegisterForDeviceStatusNotif
  132. *
  133. * Description This function is called to register for device status
  134. * change notifications.
  135. *
  136. * Returns pointer to previous caller's callback function or NULL if
  137. * first registration.
  138. *
  139. ******************************************************************************/
  140. extern tBTM_DEV_STATUS_CB* BTM_RegisterForDeviceStatusNotif(
  141. tBTM_DEV_STATUS_CB* p_cb);
  142. /*******************************************************************************
  143. *
  144. * Function BTM_RegisterForVSEvents
  145. *
  146. * Description This function is called to register/deregister for vendor
  147. * specific HCI events.
  148. *
  149. * If is_register=true, then the function will be registered;
  150. * otherwise the function will be deregistered.
  151. *
  152. * Returns BTM_SUCCESS if successful,
  153. * BTM_BUSY if maximum number of callbacks have already been
  154. * registered.
  155. *
  156. ******************************************************************************/
  157. extern tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb,
  158. bool is_register);
  159. /*******************************************************************************
  160. *
  161. * Function BTM_VendorSpecificCommand
  162. *
  163. * Description Send a vendor specific HCI command to the controller.
  164. *
  165. ******************************************************************************/
  166. extern void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len,
  167. uint8_t* p_param_buf,
  168. tBTM_VSC_CMPL_CB* p_cb);
  169. /*******************************************************************************
  170. *
  171. * Function BTM_AllocateSCN
  172. *
  173. * Description Look through the Server Channel Numbers for a free one to be
  174. * used with an RFCOMM connection.
  175. *
  176. * Returns Allocated SCN number or 0 if none.
  177. *
  178. ******************************************************************************/
  179. extern uint8_t BTM_AllocateSCN(void);
  180. /*******************************************************************************
  181. *
  182. * Function BTM_TryAllocateSCN
  183. *
  184. * Description Try to allocate a fixed server channel
  185. *
  186. * Returns Returns true if server channel was available
  187. *
  188. ******************************************************************************/
  189. extern bool BTM_TryAllocateSCN(uint8_t scn);
  190. /*******************************************************************************
  191. *
  192. * Function BTM_FreeSCN
  193. *
  194. * Description Free the specified SCN.
  195. *
  196. * Returns true if successful, false if SCN is not in use or invalid
  197. *
  198. ******************************************************************************/
  199. extern bool BTM_FreeSCN(uint8_t scn);
  200. /*******************************************************************************
  201. *
  202. * Function BTM_SetTraceLevel
  203. *
  204. * Description This function sets the trace level for BTM. If called with
  205. * a value of 0xFF, it simply returns the current trace level.
  206. *
  207. * Returns The new or current trace level
  208. *
  209. ******************************************************************************/
  210. extern uint8_t BTM_SetTraceLevel(uint8_t new_level);
  211. /*******************************************************************************
  212. *
  213. * Function BTM_WritePageTimeout
  214. *
  215. * Description Send HCI Wite Page Timeout.
  216. *
  217. ******************************************************************************/
  218. extern void BTM_WritePageTimeout(uint16_t timeout);
  219. /*******************************************************************************
  220. *
  221. * Function BTM_WriteVoiceSettings
  222. *
  223. * Description Send HCI Write Voice Settings command.
  224. * See hcidefs.h for settings bitmask values.
  225. *
  226. ******************************************************************************/
  227. extern void BTM_WriteVoiceSettings(uint16_t settings);
  228. /*******************************************************************************
  229. *
  230. * Function BTM_EnableTestMode
  231. *
  232. * Description Send HCI the enable device under test command.
  233. *
  234. * Note: Controller can only be taken out of this mode by
  235. * resetting the controller.
  236. *
  237. * Returns
  238. * BTM_SUCCESS Command sent.
  239. * BTM_NO_RESOURCES If out of resources to send the command.
  240. *
  241. *
  242. ******************************************************************************/
  243. extern tBTM_STATUS BTM_EnableTestMode(void);
  244. /*******************************************************************************
  245. * DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
  246. ******************************************************************************/
  247. /*******************************************************************************
  248. *
  249. * Function BTM_SetDiscoverability
  250. *
  251. * Description This function is called to set the device into or out of
  252. * discoverable mode. Discoverable mode means inquiry
  253. * scans are enabled. If a value of '0' is entered for window
  254. * or interval, the default values are used.
  255. *
  256. * Returns BTM_SUCCESS if successful
  257. * BTM_BUSY if a setting of the filter is already in progress
  258. * BTM_NO_RESOURCES if couldn't get a memory pool buffer
  259. * BTM_ILLEGAL_VALUE if a bad parameter was detected
  260. * BTM_WRONG_MODE if the device is not up.
  261. *
  262. ******************************************************************************/
  263. extern tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode, uint16_t window,
  264. uint16_t interval);
  265. /*******************************************************************************
  266. *
  267. * Function BTM_ReadDiscoverability
  268. *
  269. * Description This function is called to read the current discoverability
  270. * mode of the device.
  271. *
  272. * Output Params: p_window - current inquiry scan duration
  273. * p_interval - current inquiry scan interval
  274. *
  275. * Returns BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
  276. * BTM_GENERAL_DISCOVERABLE
  277. *
  278. ******************************************************************************/
  279. extern uint16_t BTM_ReadDiscoverability(uint16_t* p_window,
  280. uint16_t* p_interval);
  281. /*******************************************************************************
  282. *
  283. * Function BTM_SetPeriodicInquiryMode
  284. *
  285. * Description This function is called to set the device periodic inquiry
  286. * mode. If the duration is zero, the periodic inquiry mode is
  287. * cancelled.
  288. *
  289. * Parameters: p_inqparms - pointer to the inquiry information
  290. * mode - GENERAL or LIMITED inquiry
  291. * duration - length in 1.28 sec intervals (If '0', the
  292. * inquiry is CANCELLED)
  293. * max_resps - maximum amount of devices to search for
  294. * before ending the inquiry
  295. * filter_cond_type - BTM_CLR_INQUIRY_FILTER,
  296. * BTM_FILTER_COND_DEVICE_CLASS, or
  297. * BTM_FILTER_COND_BD_ADDR
  298. * filter_cond - value for the filter (based on
  299. * filter_cond_type)
  300. *
  301. * max_delay - maximum amount of time between successive
  302. * inquiries
  303. * min_delay - minimum amount of time between successive
  304. * inquiries
  305. * p_results_cb - callback returning pointer to results
  306. * (tBTM_INQ_RESULTS)
  307. *
  308. * Returns BTM_CMD_STARTED if successfully started
  309. * BTM_ILLEGAL_VALUE if a bad parameter is detected
  310. * BTM_NO_RESOURCES if could not allocate a message buffer
  311. * BTM_SUCCESS - if cancelling the periodic inquiry
  312. * BTM_BUSY - if an inquiry is already active
  313. * BTM_WRONG_MODE if the device is not up.
  314. *
  315. ******************************************************************************/
  316. extern tBTM_STATUS BTM_SetPeriodicInquiryMode(
  317. tBTM_INQ_PARMS* p_inqparms, uint16_t max_delay, uint16_t min_delay,
  318. tBTM_INQ_RESULTS_CB* p_results_cb);
  319. /*******************************************************************************
  320. *
  321. * Function BTM_StartInquiry
  322. *
  323. * Description This function is called to start an inquiry.
  324. *
  325. * Parameters: p_inqparms - pointer to the inquiry information
  326. * mode - GENERAL or LIMITED inquiry
  327. * duration - length in 1.28 sec intervals (If '0', the
  328. * inquiry is CANCELLED)
  329. * max_resps - maximum amount of devices to search for
  330. * before ending the inquiry
  331. * filter_cond_type - BTM_CLR_INQUIRY_FILTER,
  332. * BTM_FILTER_COND_DEVICE_CLASS, or
  333. * BTM_FILTER_COND_BD_ADDR
  334. * filter_cond - value for the filter (based on
  335. * filter_cond_type)
  336. *
  337. * p_results_cb - Pointer to the callback routine which gets
  338. * called upon receipt of an inquiry result. If
  339. * this field is NULL, the application is not
  340. * notified.
  341. *
  342. * p_cmpl_cb - Pointer to the callback routine which gets
  343. * called upon completion. If this field is
  344. * NULL, the application is not notified when
  345. * completed.
  346. * Returns tBTM_STATUS
  347. * BTM_CMD_STARTED if successfully initiated
  348. * BTM_BUSY if already in progress
  349. * BTM_ILLEGAL_VALUE if parameter(s) are out of range
  350. * BTM_NO_RESOURCES if could not allocate resources to start
  351. * the command
  352. * BTM_WRONG_MODE if the device is not up.
  353. *
  354. ******************************************************************************/
  355. extern tBTM_STATUS BTM_StartInquiry(tBTM_INQ_PARMS* p_inqparms,
  356. tBTM_INQ_RESULTS_CB* p_results_cb,
  357. tBTM_CMPL_CB* p_cmpl_cb);
  358. /*******************************************************************************
  359. *
  360. * Function BTM_IsInquiryActive
  361. *
  362. * Description Return a bit mask of the current inquiry state
  363. *
  364. * Returns BTM_INQUIRY_INACTIVE if inactive (0)
  365. * BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
  366. * BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
  367. * BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
  368. *
  369. ******************************************************************************/
  370. extern uint16_t BTM_IsInquiryActive(void);
  371. /*******************************************************************************
  372. *
  373. * Function BTM_CancelInquiry
  374. *
  375. * Description This function cancels an inquiry if active
  376. *
  377. * Returns BTM_SUCCESS if successful
  378. * BTM_NO_RESOURCES if could not allocate a message buffer
  379. * BTM_WRONG_MODE if the device is not up.
  380. *
  381. ******************************************************************************/
  382. extern tBTM_STATUS BTM_CancelInquiry(void);
  383. /*******************************************************************************
  384. *
  385. * Function BTM_CancelPeriodicInquiry
  386. *
  387. * Description This function cancels a periodic inquiry
  388. *
  389. * Returns
  390. * BTM_NO_RESOURCES if could not allocate a message buffer
  391. * BTM_SUCCESS - if cancelling the periodic inquiry
  392. * BTM_WRONG_MODE if the device is not up.
  393. *
  394. ******************************************************************************/
  395. extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
  396. /*******************************************************************************
  397. *
  398. * Function BTM_SetConnectability
  399. *
  400. * Description This function is called to set the device into or out of
  401. * connectable mode. Discoverable mode means page scans are
  402. * enabled.
  403. *
  404. * Returns BTM_SUCCESS if successful
  405. * BTM_ILLEGAL_VALUE if a bad parameter is detected
  406. * BTM_NO_RESOURCES if could not allocate a message buffer
  407. * BTM_WRONG_MODE if the device is not up.
  408. *
  409. ******************************************************************************/
  410. extern tBTM_STATUS BTM_SetConnectability(uint16_t page_mode, uint16_t window,
  411. uint16_t interval);
  412. /*******************************************************************************
  413. *
  414. * Function BTM_ReadConnectability
  415. *
  416. * Description This function is called to read the current discoverability
  417. * mode of the device.
  418. * Output Params p_window - current page scan duration
  419. * p_interval - current time between page scans
  420. *
  421. * Returns BTM_NON_CONNECTABLE or BTM_CONNECTABLE
  422. *
  423. ******************************************************************************/
  424. extern uint16_t BTM_ReadConnectability(uint16_t* p_window,
  425. uint16_t* p_interval);
  426. /*******************************************************************************
  427. *
  428. * Function BTM_SetInquiryMode
  429. *
  430. * Description This function is called to set standard, with RSSI
  431. * mode or extended of the inquiry for local device.
  432. *
  433. * Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
  434. * BTM_INQ_RESULT_EXTENDED
  435. *
  436. * Returns BTM_SUCCESS if successful
  437. * BTM_NO_RESOURCES if couldn't get a memory pool buffer
  438. * BTM_ILLEGAL_VALUE if a bad parameter was detected
  439. * BTM_WRONG_MODE if the device is not up.
  440. *
  441. ******************************************************************************/
  442. extern tBTM_STATUS BTM_SetInquiryMode(uint8_t mode);
  443. /*******************************************************************************
  444. *
  445. * Function BTM_SetInquiryScanType
  446. *
  447. * Description This function is called to set the iquiry scan-type to
  448. * standard or interlaced.
  449. *
  450. * Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
  451. *
  452. * Returns BTM_SUCCESS if successful
  453. * BTM_MODE_UNSUPPORTED if not a 1.2 device
  454. * BTM_WRONG_MODE if the device is not up.
  455. *
  456. ******************************************************************************/
  457. extern tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type);
  458. /*******************************************************************************
  459. *
  460. * Function BTM_SetPageScanType
  461. *
  462. * Description This function is called to set the page scan-type to
  463. * standard or interlaced.
  464. *
  465. * Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
  466. *
  467. * Returns BTM_SUCCESS if successful
  468. * BTM_MODE_UNSUPPORTED if not a 1.2 device
  469. * BTM_WRONG_MODE if the device is not up.
  470. *
  471. ******************************************************************************/
  472. extern tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type);
  473. /*******************************************************************************
  474. *
  475. * Function BTM_ReadRemoteDeviceName
  476. *
  477. * Description This function initiates a remote device HCI command to the
  478. * controller and calls the callback when the process has
  479. * completed.
  480. *
  481. * Input Params: remote_bda - device address of name to retrieve
  482. * p_cb - callback function called when
  483. * BTM_CMD_STARTED is returned.
  484. * A pointer to tBTM_REMOTE_DEV_NAME is
  485. * passed to the callback.
  486. *
  487. * Returns
  488. * BTM_CMD_STARTED is returned if the request was successfully
  489. * sent to HCI.
  490. * BTM_BUSY if already in progress
  491. * BTM_UNKNOWN_ADDR if device address is bad
  492. * BTM_NO_RESOURCES if resources could not be allocated to
  493. * start the command
  494. * BTM_WRONG_MODE if the device is not up.
  495. *
  496. ******************************************************************************/
  497. extern tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda,
  498. tBTM_CMPL_CB* p_cb,
  499. tBT_TRANSPORT transport);
  500. /*******************************************************************************
  501. *
  502. * Function BTM_CancelRemoteDeviceName
  503. *
  504. * Description This function initiates the cancel request for the specified
  505. * remote device.
  506. *
  507. * Input Params: None
  508. *
  509. * Returns
  510. * BTM_CMD_STARTED is returned if the request was successfully
  511. * sent to HCI.
  512. * BTM_NO_RESOURCES if resources could not be allocated to
  513. * start the command
  514. * BTM_WRONG_MODE if there is no active remote name request.
  515. *
  516. ******************************************************************************/
  517. extern tBTM_STATUS BTM_CancelRemoteDeviceName(void);
  518. /*******************************************************************************
  519. *
  520. * Function BTM_ReadRemoteVersion
  521. *
  522. * Description This function is called to read a remote device's version
  523. *
  524. * Returns BTM_SUCCESS if successful, otherwise an error
  525. *
  526. ******************************************************************************/
  527. extern tBTM_STATUS BTM_ReadRemoteVersion(const RawAddress& addr,
  528. uint8_t* lmp_version,
  529. uint16_t* manufacturer,
  530. uint16_t* lmp_sub_version);
  531. /*******************************************************************************
  532. *
  533. * Function BTM_ReadRemoteFeatures
  534. *
  535. * Description This function is called to read a remote device's
  536. * supported features mask (features mask located at page 0)
  537. *
  538. * Note: The size of device features mask page is
  539. * BTM_FEATURE_BYTES_PER_PAGE bytes.
  540. *
  541. * Returns pointer to the remote supported features mask
  542. *
  543. ******************************************************************************/
  544. extern uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr);
  545. /*******************************************************************************
  546. *
  547. * Function BTM_ReadRemoteExtendedFeatures
  548. *
  549. * Description This function is called to read a specific extended features
  550. * page of the remote device
  551. *
  552. * Note1: The size of device features mask page is
  553. * BTM_FEATURE_BYTES_PER_PAGE bytes.
  554. * Note2: The valid device features mask page number depends on
  555. * the remote device capabilities. It is expected to be in the
  556. * range [0 - BTM_EXT_FEATURES_PAGE_MAX].
  557. * Returns pointer to the remote extended features mask
  558. * or NULL if page_number is not valid
  559. *
  560. ******************************************************************************/
  561. extern uint8_t* BTM_ReadRemoteExtendedFeatures(const RawAddress& addr,
  562. uint8_t page_number);
  563. /*******************************************************************************
  564. *
  565. * Function BTM_ReadNumberRemoteFeaturesPages
  566. *
  567. * Description This function is called to retrieve the number of feature
  568. * pages read from the remote device
  569. *
  570. * Returns number of features pages read from the remote device
  571. *
  572. ******************************************************************************/
  573. extern uint8_t BTM_ReadNumberRemoteFeaturesPages(const RawAddress& addr);
  574. /*******************************************************************************
  575. *
  576. * Function BTM_ReadAllRemoteFeatures
  577. *
  578. * Description Read all the features of the remote device
  579. *
  580. * Returns pointer to the byte[0] of the page[0] of the remote device
  581. * feature mask.
  582. *
  583. * Note: the function returns the pointer to the array of the size
  584. * BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1)
  585. *
  586. ******************************************************************************/
  587. extern uint8_t* BTM_ReadAllRemoteFeatures(const RawAddress& addr);
  588. /*******************************************************************************
  589. *
  590. * Function BTM_InqDbRead
  591. *
  592. * Description This function looks through the inquiry database for a match
  593. * based on Bluetooth Device Address. This is the application's
  594. * interface to get the inquiry details of a specific BD
  595. * address.
  596. *
  597. * Returns pointer to entry, or NULL if not found
  598. *
  599. ******************************************************************************/
  600. extern tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda);
  601. /*******************************************************************************
  602. *
  603. * Function BTM_InqDbFirst
  604. *
  605. * Description This function looks through the inquiry database for the
  606. * first used entry, and returns that. This is used in
  607. * conjunction with BTM_InqDbNext by applications as a way to
  608. * walk through the inquiry database.
  609. *
  610. * Returns pointer to first in-use entry, or NULL if DB is empty
  611. *
  612. ******************************************************************************/
  613. extern tBTM_INQ_INFO* BTM_InqDbFirst(void);
  614. /*******************************************************************************
  615. *
  616. * Function BTM_InqDbNext
  617. *
  618. * Description This function looks through the inquiry database for the
  619. * next used entry, and returns that. If the input parameter
  620. * is NULL, the first entry is returned.
  621. *
  622. * Returns pointer to next in-use entry, or NULL if no more found.
  623. *
  624. ******************************************************************************/
  625. extern tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur);
  626. /*******************************************************************************
  627. *
  628. * Function BTM_ClearInqDb
  629. *
  630. * Description This function is called to clear out a device or all devices
  631. * from the inquiry database.
  632. *
  633. * Parameter p_bda - (input) BD_ADDR -> Address of device to clear
  634. * (NULL clears all entries)
  635. *
  636. * Returns BTM_BUSY if an inquiry, get remote name, or event filter
  637. * is active, otherwise BTM_SUCCESS
  638. *
  639. ******************************************************************************/
  640. extern tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda);
  641. /*******************************************************************************
  642. *
  643. * Function BTM_ReadInquiryRspTxPower
  644. *
  645. * Description This command will read the inquiry Transmit Power level used
  646. * to transmit the FHS and EIR data packets.
  647. * This can be used directly in the Tx Power Level EIR data
  648. * type.
  649. *
  650. * Returns BTM_SUCCESS if successful
  651. *
  652. ******************************************************************************/
  653. extern tBTM_STATUS BTM_ReadInquiryRspTxPower(tBTM_CMPL_CB* p_cb);
  654. /*****************************************************************************
  655. * ACL CHANNEL MANAGEMENT FUNCTIONS
  656. ****************************************************************************/
  657. /*******************************************************************************
  658. *
  659. * Function BTM_SetLinkPolicy
  660. *
  661. * Description Create and send HCI "Write Policy Set" command
  662. *
  663. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  664. *
  665. ******************************************************************************/
  666. extern tBTM_STATUS BTM_SetLinkPolicy(const RawAddress& remote_bda,
  667. uint16_t* settings);
  668. /*******************************************************************************
  669. *
  670. * Function BTM_SetDefaultLinkPolicy
  671. *
  672. * Description Set the default value for HCI "Write Policy Set" command
  673. * to use when an ACL link is created.
  674. *
  675. * Returns void
  676. *
  677. ******************************************************************************/
  678. extern void BTM_SetDefaultLinkPolicy(uint16_t settings);
  679. /*******************************************************************************
  680. *
  681. * Function BTM_SetDefaultLinkSuperTout
  682. *
  683. * Description Set the default value for HCI "Write Link Supervision
  684. * Timeout" command to use when an ACL link is created.
  685. *
  686. * Returns void
  687. *
  688. ******************************************************************************/
  689. extern void BTM_SetDefaultLinkSuperTout(uint16_t timeout);
  690. /*******************************************************************************
  691. *
  692. * Function BTM_SetLinkSuperTout
  693. *
  694. * Description Create and send HCI "Write Link Supervision Timeout" command
  695. *
  696. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  697. *
  698. ******************************************************************************/
  699. extern tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,
  700. uint16_t timeout);
  701. /*******************************************************************************
  702. *
  703. * Function BTM_GetLinkSuperTout
  704. *
  705. * Description Read the link supervision timeout value of the connection
  706. *
  707. * Returns status of the operation
  708. *
  709. ******************************************************************************/
  710. extern tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda,
  711. uint16_t* p_timeout);
  712. /*******************************************************************************
  713. *
  714. * Function BTM_IsAclConnectionUp
  715. *
  716. * Description This function is called to check if an ACL connection exists
  717. * to a specific remote BD Address.
  718. *
  719. * Returns true if connection is up, else false.
  720. *
  721. ******************************************************************************/
  722. extern bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,
  723. tBT_TRANSPORT transport);
  724. /*******************************************************************************
  725. *
  726. * Function BTM_GetRole
  727. *
  728. * Description This function is called to get the role of the local device
  729. * for the ACL connection with the specified remote device
  730. *
  731. * Returns BTM_SUCCESS if connection exists.
  732. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  733. *
  734. ******************************************************************************/
  735. extern tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr,
  736. uint8_t* p_role);
  737. /*******************************************************************************
  738. *
  739. * Function BTM_SwitchRole
  740. *
  741. * Description This function is called to switch role between master and
  742. * slave. If role is already set it will do nothing. If the
  743. * command was initiated, the callback function is called upon
  744. * completion.
  745. *
  746. * Returns BTM_SUCCESS if already in specified role.
  747. * BTM_CMD_STARTED if command issued to controller.
  748. * BTM_NO_RESOURCES if memory couldn't be allocated to issue
  749. * the command
  750. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  751. * BTM_MODE_UNSUPPORTED if the local device does not support
  752. * role switching
  753. *
  754. ******************************************************************************/
  755. extern tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr,
  756. uint8_t new_role, tBTM_CMPL_CB* p_cb);
  757. /*******************************************************************************
  758. *
  759. * Function BTM_ReadRSSI
  760. *
  761. * Description This function is called to read the link policy settings.
  762. * The address of link policy results are returned in the
  763. * callback. (tBTM_RSSI_RESULT)
  764. *
  765. * Returns BTM_CMD_STARTED if command issued to controller.
  766. * BTM_NO_RESOURCES if memory couldn't be allocated to issue
  767. * the command
  768. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  769. * BTM_BUSY if command is already in progress
  770. *
  771. ******************************************************************************/
  772. extern tBTM_STATUS BTM_ReadRSSI(const RawAddress& remote_bda,
  773. tBTM_CMPL_CB* p_cb);
  774. /*******************************************************************************
  775. *
  776. * Function BTM_ReadFailedContactCounter
  777. *
  778. * Description This function is called to read the failed contact counter.
  779. * The result is returned in the callback.
  780. * (tBTM_FAILED_CONTACT_COUNTER_RESULT)
  781. *
  782. * Returns BTM_CMD_STARTED if command issued to controller.
  783. * BTM_NO_RESOURCES if memory couldn't be allocated to issue
  784. * the command
  785. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  786. * BTM_BUSY if command is already in progress
  787. *
  788. ******************************************************************************/
  789. extern tBTM_STATUS BTM_ReadFailedContactCounter(const RawAddress& remote_bda,
  790. tBTM_CMPL_CB* p_cb);
  791. /*******************************************************************************
  792. *
  793. * Function BTM_ReadAutomaticFlushTimeout
  794. *
  795. * Description This function is called to read the automatic flush timeout.
  796. * The result is returned in the callback.
  797. * (tBTM_AUTOMATIC_FLUSH_TIMEOUT_RESULT)
  798. *
  799. * Returns BTM_CMD_STARTED if command issued to controller.
  800. * BTM_NO_RESOURCES if memory couldn't be allocated to issue
  801. * the command
  802. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  803. * BTM_BUSY if command is already in progress
  804. *
  805. ******************************************************************************/
  806. extern tBTM_STATUS BTM_ReadAutomaticFlushTimeout(const RawAddress& remote_bda,
  807. tBTM_CMPL_CB* p_cb);
  808. /*******************************************************************************
  809. *
  810. * Function BTM_ReadTxPower
  811. *
  812. * Description This function is called to read the current connection
  813. * TX power of the connection. The TX power level results
  814. * are returned in the callback.
  815. * (tBTM_RSSI_RESULT)
  816. *
  817. * Returns BTM_CMD_STARTED if command issued to controller.
  818. * BTM_NO_RESOURCES if memory couldn't be allocated to issue
  819. * the command
  820. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  821. * BTM_BUSY if command is already in progress
  822. *
  823. ******************************************************************************/
  824. extern tBTM_STATUS BTM_ReadTxPower(const RawAddress& remote_bda,
  825. tBT_TRANSPORT transport, tBTM_CMPL_CB* p_cb);
  826. /*******************************************************************************
  827. *
  828. * Function BTM_ReadLinkQuality
  829. *
  830. * Description This function is called to read the link quality.
  831. * The value of the link quality is returned in the callback.
  832. * (tBTM_LINK_QUALITY_RESULT)
  833. *
  834. * Returns BTM_CMD_STARTED if command issued to controller.
  835. * BTM_NO_RESOURCES if memory couldn't be allocated to issue
  836. * the command
  837. * BTM_UNKNOWN_ADDR if no active link with bd addr specified
  838. * BTM_BUSY if command is already in progress
  839. *
  840. ******************************************************************************/
  841. extern tBTM_STATUS BTM_ReadLinkQuality(const RawAddress& remote_bda,
  842. tBTM_CMPL_CB* p_cb);
  843. /*******************************************************************************
  844. *
  845. * Function BTM_RegBusyLevelNotif
  846. *
  847. * Description This function is called to register a callback to receive
  848. * busy level change events.
  849. *
  850. * Returns BTM_SUCCESS if successfully registered, otherwise error
  851. *
  852. ******************************************************************************/
  853. extern tBTM_STATUS BTM_RegBusyLevelNotif(tBTM_BL_CHANGE_CB* p_cb,
  854. uint8_t* p_level,
  855. tBTM_BL_EVENT_MASK evt_mask);
  856. /*******************************************************************************
  857. *
  858. * Function BTM_AclRegisterForChanges
  859. *
  860. * Description This function is called to register a callback to receive
  861. * ACL database change events, i.e. new connection or removed.
  862. *
  863. * Returns BTM_SUCCESS if successfully initiated, otherwise error
  864. *
  865. ******************************************************************************/
  866. extern tBTM_STATUS BTM_AclRegisterForChanges(tBTM_ACL_DB_CHANGE_CB* p_cb);
  867. /*******************************************************************************
  868. *
  869. * Function BTM_GetNumAclLinks
  870. *
  871. * Description This function is called to count the number of
  872. * ACL links that are active.
  873. *
  874. * Returns uint16_t Number of active ACL links
  875. *
  876. ******************************************************************************/
  877. extern uint16_t BTM_GetNumAclLinks(void);
  878. /*******************************************************************************
  879. *
  880. * Function BTM_SetQoS
  881. *
  882. * Description This function is called to setup QoS
  883. *
  884. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  885. *
  886. ******************************************************************************/
  887. extern tBTM_STATUS BTM_SetQoS(const RawAddress& bd, FLOW_SPEC* p_flow,
  888. tBTM_CMPL_CB* p_cb);
  889. /*****************************************************************************
  890. * (e)SCO CHANNEL MANAGEMENT FUNCTIONS
  891. ****************************************************************************/
  892. /*******************************************************************************
  893. *
  894. * Function BTM_CreateSco
  895. *
  896. * Description This function is called to create an SCO connection. If the
  897. * "is_orig" flag is true, the connection will be originated,
  898. * otherwise BTM will wait for the other side to connect.
  899. *
  900. * Returns BTM_UNKNOWN_ADDR if the ACL connection is not up
  901. * BTM_BUSY if another SCO being set up to
  902. * the same BD address
  903. * BTM_NO_RESOURCES if the max SCO limit has been reached
  904. * BTM_CMD_STARTED if the connection establishment is started.
  905. * In this case, "*p_sco_inx" is filled in
  906. * with the sco index used for the connection.
  907. *
  908. ******************************************************************************/
  909. extern tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
  910. uint16_t pkt_types, uint16_t* p_sco_inx,
  911. tBTM_SCO_CB* p_conn_cb,
  912. tBTM_SCO_CB* p_disc_cb);
  913. /*******************************************************************************
  914. *
  915. * Function BTM_RemoveSco
  916. *
  917. * Description This function is called to remove a specific SCO connection.
  918. *
  919. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  920. *
  921. ******************************************************************************/
  922. extern tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx);
  923. /*******************************************************************************
  924. *
  925. * Function BTM_SetScoPacketTypes
  926. *
  927. * Description This function is called to set the packet types used for
  928. * a specific SCO connection,
  929. *
  930. * Parameters pkt_types - One or more of the following
  931. * BTM_SCO_PKT_TYPES_MASK_HV1
  932. * BTM_SCO_PKT_TYPES_MASK_HV2
  933. * BTM_SCO_PKT_TYPES_MASK_HV3
  934. * BTM_SCO_PKT_TYPES_MASK_EV3
  935. * BTM_SCO_PKT_TYPES_MASK_EV4
  936. * BTM_SCO_PKT_TYPES_MASK_EV5
  937. *
  938. * BTM_SCO_LINK_ALL_MASK - enables all supported types
  939. *
  940. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  941. *
  942. ******************************************************************************/
  943. extern tBTM_STATUS BTM_SetScoPacketTypes(uint16_t sco_inx, uint16_t pkt_types);
  944. /*******************************************************************************
  945. *
  946. * Function BTM_ReadScoPacketTypes
  947. *
  948. * Description This function is read the packet types used for a specific
  949. * SCO connection.
  950. *
  951. * Returns One or more of the following (bitmask)
  952. * BTM_SCO_PKT_TYPES_MASK_HV1
  953. * BTM_SCO_PKT_TYPES_MASK_HV2
  954. * BTM_SCO_PKT_TYPES_MASK_HV3
  955. * BTM_SCO_PKT_TYPES_MASK_EV3
  956. * BTM_SCO_PKT_TYPES_MASK_EV4
  957. * BTM_SCO_PKT_TYPES_MASK_EV5
  958. *
  959. * Returns packet types supported for the connection
  960. *
  961. ******************************************************************************/
  962. extern uint16_t BTM_ReadScoPacketTypes(uint16_t sco_inx);
  963. /*******************************************************************************
  964. *
  965. * Function BTM_ReadDeviceScoPacketTypes
  966. *
  967. * Description This function is read the SCO packet types that
  968. * the device supports.
  969. *
  970. * Returns packet types supported by the device.
  971. *
  972. ******************************************************************************/
  973. extern uint16_t BTM_ReadDeviceScoPacketTypes(void);
  974. /*******************************************************************************
  975. *
  976. * Function BTM_ReadScoHandle
  977. *
  978. * Description Reead the HCI handle used for a specific SCO connection,
  979. *
  980. * Returns handle for the connection, or 0xFFFF if invalid SCO index.
  981. *
  982. ******************************************************************************/
  983. extern uint16_t BTM_ReadScoHandle(uint16_t sco_inx);
  984. /*******************************************************************************
  985. *
  986. * Function BTM_ReadScoBdAddr
  987. *
  988. * Description This function is read the remote BD Address for a specific
  989. * SCO connection,
  990. *
  991. * Returns pointer to BD address or NULL if not known
  992. *
  993. ******************************************************************************/
  994. extern const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx);
  995. /*******************************************************************************
  996. *
  997. * Function BTM_ReadScoDiscReason
  998. *
  999. * Description This function is returns the reason why an (e)SCO connection
  1000. * has been removed. It contains the value until read, or until
  1001. * another (e)SCO connection has disconnected.
  1002. *
  1003. * Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
  1004. *
  1005. ******************************************************************************/
  1006. extern uint16_t BTM_ReadScoDiscReason(void);
  1007. /*******************************************************************************
  1008. *
  1009. * Function BTM_SetEScoMode
  1010. *
  1011. * Description This function sets up the negotiated parameters for SCO or
  1012. * eSCO, and sets as the default mode used for calls to
  1013. * BTM_CreateSco. It can be called only when there are no
  1014. * active (e)SCO links.
  1015. *
  1016. * Returns BTM_SUCCESS if the successful.
  1017. * BTM_BUSY if there are one or more active (e)SCO links.
  1018. *
  1019. ******************************************************************************/
  1020. extern tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms);
  1021. /*******************************************************************************
  1022. *
  1023. * Function BTM_SetWBSCodec
  1024. *
  1025. * Description This function sends command to the controller to setup
  1026. * WBS codec for the upcoming eSCO connection.
  1027. *
  1028. * Returns BTM_SUCCESS.
  1029. *
  1030. *
  1031. ******************************************************************************/
  1032. extern tBTM_STATUS BTM_SetWBSCodec(tBTM_SCO_CODEC_TYPE codec_type);
  1033. /*******************************************************************************
  1034. *
  1035. * Function BTM_RegForEScoEvts
  1036. *
  1037. * Description This function registers a SCO event callback with the
  1038. * specified instance. It should be used to received
  1039. * connection indication events and change of link parameter
  1040. * events.
  1041. *
  1042. * Returns BTM_SUCCESS if the successful.
  1043. * BTM_ILLEGAL_VALUE if there is an illegal sco_inx
  1044. *
  1045. ******************************************************************************/
  1046. extern tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx,
  1047. tBTM_ESCO_CBACK* p_esco_cback);
  1048. /*******************************************************************************
  1049. *
  1050. * Function BTM_ReadEScoLinkParms
  1051. *
  1052. * Description This function returns the current eSCO link parameters for
  1053. * the specified handle. This can be called anytime a
  1054. * connection is active, but is typically called after
  1055. * receiving the SCO opened callback.
  1056. *
  1057. * Note: If called over a 1.1 controller, only the packet types
  1058. * field has meaning.
  1059. * Note: If the upper layer doesn't know the current sco index,
  1060. * BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first
  1061. * parameter to find the first active SCO index
  1062. *
  1063. * Returns BTM_SUCCESS if returned data is valid connection.
  1064. * BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
  1065. * BTM_MODE_UNSUPPORTED if local controller does not support
  1066. * 1.2 specification.
  1067. *
  1068. ******************************************************************************/
  1069. extern tBTM_STATUS BTM_ReadEScoLinkParms(uint16_t sco_inx,
  1070. tBTM_ESCO_DATA* p_parms);
  1071. /*******************************************************************************
  1072. *
  1073. * Function BTM_ChangeEScoLinkParms
  1074. *
  1075. * Description This function requests renegotiation of the parameters on
  1076. * the current eSCO Link. If any of the changes are accepted
  1077. * by the controllers, the BTM_ESCO_CHG_EVT event is sent in
  1078. * the tBTM_ESCO_CBACK function with the current settings of
  1079. * the link. The callback is registered through the call to
  1080. * BTM_SetEScoMode.
  1081. *
  1082. *
  1083. * Returns BTM_CMD_STARTED if command is successfully initiated.
  1084. * BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
  1085. * BTM_NO_RESOURCES - not enough resources to initiate command.
  1086. * BTM_MODE_UNSUPPORTED if local controller does not support
  1087. * 1.2 specification.
  1088. *
  1089. ******************************************************************************/
  1090. extern tBTM_STATUS BTM_ChangeEScoLinkParms(uint16_t sco_inx,
  1091. tBTM_CHG_ESCO_PARAMS* p_parms);
  1092. /*******************************************************************************
  1093. *
  1094. * Function BTM_EScoConnRsp
  1095. *
  1096. * Description This function is called upon receipt of an (e)SCO connection
  1097. * request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
  1098. * the request. Parameters used to negotiate eSCO links.
  1099. * If p_parms is NULL, then values set through BTM_SetEScoMode
  1100. * are used.
  1101. * If the link type of the incoming request is SCO, then only
  1102. * the tx_bw, max_latency, content format, and packet_types are
  1103. * valid. The hci_status parameter should be
  1104. * ([0x0] to accept, [0x0d..0x0f] to reject)
  1105. *
  1106. *
  1107. * Returns void
  1108. *
  1109. ******************************************************************************/
  1110. extern void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status,
  1111. enh_esco_params_t* p_parms);
  1112. /*******************************************************************************
  1113. *
  1114. * Function BTM_GetNumScoLinks
  1115. *
  1116. * Description This function returns the number of active SCO links.
  1117. *
  1118. * Returns uint8_t
  1119. *
  1120. ******************************************************************************/
  1121. extern uint8_t BTM_GetNumScoLinks(void);
  1122. /*****************************************************************************
  1123. * SECURITY MANAGEMENT FUNCTIONS
  1124. ****************************************************************************/
  1125. /*******************************************************************************
  1126. *
  1127. * Function BTM_SecRegister
  1128. *
  1129. * Description Application manager calls this function to register for
  1130. * security services. There can be one and only one
  1131. * application saving link keys. BTM allows only first
  1132. * registration.
  1133. *
  1134. * Returns true if registered OK, else false
  1135. *
  1136. ******************************************************************************/
  1137. extern bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info);
  1138. /*******************************************************************************
  1139. *
  1140. * Function BTM_SecRegisterLinkKeyNotificationCallback
  1141. *
  1142. * Description Profiles can register to be notified when a new Link Key
  1143. * is generated per connection.
  1144. *
  1145. * Returns true if registered OK, else false
  1146. *
  1147. ******************************************************************************/
  1148. extern bool BTM_SecRegisterLinkKeyNotificationCallback(
  1149. tBTM_LINK_KEY_CALLBACK* p_callback);
  1150. /*******************************************************************************
  1151. *
  1152. * Function BTM_SecAddRmtNameNotifyCallback
  1153. *
  1154. * Description Profiles can register to be notified when name of the
  1155. * remote device is resolved (up to
  1156. * BTM_SEC_MAX_RMT_NAME_CALLBACKS).
  1157. *
  1158. * Returns true if registered OK, else false
  1159. *
  1160. ******************************************************************************/
  1161. extern bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
  1162. /*******************************************************************************
  1163. *
  1164. * Function BTM_SecDeleteRmtNameNotifyCallback
  1165. *
  1166. * Description A profile can deregister notification when a new Link Key
  1167. * is generated per connection.
  1168. *
  1169. * Returns true if OK, else false
  1170. *
  1171. ******************************************************************************/
  1172. extern bool BTM_SecDeleteRmtNameNotifyCallback(
  1173. tBTM_RMT_NAME_CALLBACK* p_callback);
  1174. /*******************************************************************************
  1175. *
  1176. * Function BTM_GetSecurityFlags
  1177. *
  1178. * Description Get security flags for the device
  1179. *
  1180. * Returns bool true or false is device found
  1181. *
  1182. ******************************************************************************/
  1183. extern bool BTM_GetSecurityFlags(const RawAddress& bd_addr,
  1184. uint8_t* p_sec_flags);
  1185. /*******************************************************************************
  1186. *
  1187. * Function BTM_GetSecurityFlagsByTransport
  1188. *
  1189. * Description Get security flags for the device on a particular transport
  1190. *
  1191. * Parameters bd_addr: BD address of remote device
  1192. * p_sec_flags : Out parameter to be filled with security
  1193. * flags for the connection
  1194. * transport : Physical transport of the connection
  1195. * (BR/EDR or LE)
  1196. *
  1197. * Returns bool true or false is device found
  1198. *
  1199. ******************************************************************************/
  1200. extern bool BTM_GetSecurityFlagsByTransport(const RawAddress& bd_addr,
  1201. uint8_t* p_sec_flags,
  1202. tBT_TRANSPORT transport);
  1203. /*******************************************************************************
  1204. *
  1205. * Function BTM_ReadTrustedMask
  1206. *
  1207. * Description Get trusted mask for the device
  1208. *
  1209. * Returns NULL, if the device record is not found.
  1210. * otherwise, the trusted mask
  1211. *
  1212. ******************************************************************************/
  1213. extern uint32_t* BTM_ReadTrustedMask(const RawAddress& bd_addr);
  1214. /*******************************************************************************
  1215. *
  1216. * Function BTM_SetPinType
  1217. *
  1218. * Description Set PIN type for the device.
  1219. *
  1220. * Returns void
  1221. *
  1222. ******************************************************************************/
  1223. extern void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code,
  1224. uint8_t pin_code_len);
  1225. /*******************************************************************************
  1226. *
  1227. * Function BTM_SetPairableMode
  1228. *
  1229. * Description Enable or disable pairing
  1230. *
  1231. * Parameters allow_pairing - (true or false) whether or not the device
  1232. * allows pairing.
  1233. * connect_only_paired - (true or false) whether or not to
  1234. * only allow paired devices to connect.
  1235. *
  1236. * Returns void
  1237. *
  1238. ******************************************************************************/
  1239. extern void BTM_SetPairableMode(bool allow_pairing, bool connect_only_paired);
  1240. /*******************************************************************************
  1241. *
  1242. * Function BTM_SetSecureConnectionsOnly
  1243. *
  1244. * Description Enable or disable default treatment for Mode 4 Level 0
  1245. * services
  1246. *
  1247. * Parameter secure_connections_only_mode - (true or false)
  1248. * true means that the device should treat Mode 4 Level 0
  1249. * services as services of other levels.
  1250. * false means that the device should provide default
  1251. * treatment for Mode 4 Level 0 services.
  1252. *
  1253. * Returns void
  1254. *
  1255. ******************************************************************************/
  1256. extern void BTM_SetSecureConnectionsOnly(bool secure_connections_only_mode);
  1257. /*******************************************************************************
  1258. *
  1259. * Function BTM_SetSecurityLevel
  1260. *
  1261. * Description Register service security level with Security Manager. Each
  1262. * service must register its requirements regardless of the
  1263. * security level that is used. This API is called once for
  1264. * originators and again for acceptors of connections.
  1265. *
  1266. * Returns true if registered OK, else false
  1267. *
  1268. ******************************************************************************/
  1269. extern bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
  1270. uint8_t service_id, uint16_t sec_level,
  1271. uint16_t psm, uint32_t mx_proto_id,
  1272. uint32_t mx_chan_id);
  1273. /*******************************************************************************
  1274. *
  1275. * Function BTM_SetOutService
  1276. *
  1277. * Description This function is called to set the service for
  1278. * outgoing connection.
  1279. *
  1280. * Returns void
  1281. *
  1282. ******************************************************************************/
  1283. extern void BTM_SetOutService(const RawAddress& bd_addr, uint8_t service_id,
  1284. uint32_t mx_chan_id);
  1285. /*******************************************************************************
  1286. *
  1287. * Function BTM_SecClrService
  1288. *
  1289. * Description Removes specified service record(s) from the security
  1290. * database. All service records with the specified name are
  1291. * removed. Typically used only by devices with limited RAM
  1292. * so that it can reuse an old security service record.
  1293. *
  1294. * Returns Number of records that were freed.
  1295. *
  1296. ******************************************************************************/
  1297. extern uint8_t BTM_SecClrService(uint8_t service_id);
  1298. /*******************************************************************************
  1299. *
  1300. * Function BTM_SecAddDevice
  1301. *
  1302. * Description Add/modify device. This function will be normally called
  1303. * during host startup to restore all required information
  1304. * stored in the NVRAM.
  1305. * dev_class, bd_name, link_key, and features are NULL if
  1306. * unknown
  1307. *
  1308. * Returns true if added OK, else false
  1309. *
  1310. ******************************************************************************/
  1311. extern bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
  1312. BD_NAME bd_name, uint8_t* features,
  1313. uint32_t trusted_mask[], LinkKey* link_key,
  1314. uint8_t key_type, tBTM_IO_CAP io_cap,
  1315. uint8_t pin_length);
  1316. /** Free resources associated with the device associated with |bd_addr| address.
  1317. *
  1318. * *** WARNING ***
  1319. * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function
  1320. * is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is
  1321. * no longer valid!
  1322. * *** WARNING ***
  1323. *
  1324. * Returns true if removed OK, false if not found or ACL link is active.
  1325. */
  1326. extern bool BTM_SecDeleteDevice(const RawAddress& bd_addr);
  1327. /*******************************************************************************
  1328. *
  1329. * Function BTM_SecClearSecurityFlags
  1330. *
  1331. * Description Reset the security flags (mark as not-paired) for a given
  1332. * remove device.
  1333. *
  1334. ******************************************************************************/
  1335. extern void BTM_SecClearSecurityFlags(const RawAddress& bd_addr);
  1336. /*******************************************************************************
  1337. *
  1338. * Function BTM_SecGetDeviceLinkKey
  1339. *
  1340. * Description This function is called to obtain link key for the device
  1341. * it returns BTM_SUCCESS if link key is available, or
  1342. * BTM_UNKNOWN_ADDR if Security Manager does not know about
  1343. * the device or device record does not contain link key info
  1344. *
  1345. * Returns BTM_SUCCESS if successful, otherwise error code
  1346. *
  1347. ******************************************************************************/
  1348. extern tBTM_STATUS BTM_SecGetDeviceLinkKey(const RawAddress& bd_addr,
  1349. LinkKey* link_key);
  1350. /*******************************************************************************
  1351. *
  1352. * Function BTM_SecGetDeviceLinkKeyType
  1353. *
  1354. * Description This function is called to obtain link key type for the
  1355. * device.
  1356. * it returns BTM_SUCCESS if link key is available, or
  1357. * BTM_UNKNOWN_ADDR if Security Manager does not know about
  1358. * the device or device record does not contain link key info
  1359. *
  1360. * Returns BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
  1361. * otherwise.
  1362. *
  1363. ******************************************************************************/
  1364. extern tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(
  1365. const RawAddress& bd_addr);
  1366. /*******************************************************************************
  1367. *
  1368. * Function BTM_PINCodeReply
  1369. *
  1370. * Description This function is called after Security Manager submitted
  1371. * PIN code request to the UI.
  1372. *
  1373. * Parameters: bd_addr - Address of the device for which PIN was
  1374. * requested
  1375. * res - result of the operation BTM_SUCCESS if
  1376. * success
  1377. * pin_len - length in bytes of the PIN Code
  1378. * p_pin - pointer to array with the PIN Code
  1379. * trusted_mask - bitwise OR of trusted services
  1380. * (array of uint32_t)
  1381. *
  1382. * Returns void
  1383. *
  1384. ******************************************************************************/
  1385. extern void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res,
  1386. uint8_t pin_len, uint8_t* p_pin,
  1387. uint32_t trusted_mask[]);
  1388. /*******************************************************************************
  1389. *
  1390. * Function BTM_SecBond
  1391. *
  1392. * Description This function is called to perform bonding with peer device.
  1393. *
  1394. * Parameters: bd_addr - Address of the device to bond
  1395. * pin_len - length in bytes of the PIN Code
  1396. * p_pin - pointer to array with the PIN Code
  1397. * trusted_mask - bitwise OR of trusted services
  1398. * (array of uint32_t)
  1399. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  1400. *
  1401. ******************************************************************************/
  1402. extern tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
  1403. uint8_t* p_pin, uint32_t trusted_mask[]);
  1404. /*******************************************************************************
  1405. *
  1406. * Function BTM_SecBondByTransport
  1407. *
  1408. * Description Perform bonding by designated transport
  1409. *
  1410. * Parameters: bd_addr - Address of the device to bond
  1411. * pin_len - length in bytes of the PIN Code
  1412. * p_pin - pointer to array with the PIN Code
  1413. * trusted_mask - bitwise OR of trusted services
  1414. * (array of uint32_t)
  1415. * transport : Physical transport to use for bonding
  1416. * (BR/EDR or LE)
  1417. *
  1418. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  1419. *
  1420. ******************************************************************************/
  1421. extern tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
  1422. tBT_TRANSPORT transport,
  1423. uint8_t pin_len, uint8_t* p_pin,
  1424. uint32_t trusted_mask[]);
  1425. /*******************************************************************************
  1426. *
  1427. * Function BTM_SecBondCancel
  1428. *
  1429. * Description This function is called to cancel ongoing bonding process
  1430. * with peer device.
  1431. *
  1432. * Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  1433. *
  1434. ******************************************************************************/
  1435. extern tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr);
  1436. /*******************************************************************************
  1437. *
  1438. * Function BTM_SetEncryption
  1439. *
  1440. * Description This function is called to ensure that connection is
  1441. * encrypted. Should be called only on an open connection.
  1442. * Typically only needed for connections that first want to
  1443. * bring up unencrypted links, then later encrypt them.
  1444. *
  1445. * Parameters: bd_addr - Address of the peer device
  1446. * transport - Link transport
  1447. * p_callback - Pointer to callback function called if
  1448. * this function returns PENDING after required
  1449. * procedures are completed. Can be set to
  1450. * NULL if status is not desired.
  1451. * p_ref_data - pointer to any data the caller wishes to
  1452. * receive in the callback function upon
  1453. * completion.
  1454. * can be set to NULL if not used.
  1455. * sec_act - LE security action, unused for BR/EDR
  1456. *
  1457. * Returns BTM_SUCCESS - already encrypted
  1458. * BTM_PENDING - command will be returned in the callback
  1459. * BTM_WRONG_MODE- connection not up.
  1460. * BTM_BUSY - security procedures are currently active
  1461. * BTM_MODE_UNSUPPORTED - if security manager not linked in.
  1462. *
  1463. ******************************************************************************/
  1464. extern tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
  1465. tBT_TRANSPORT transport,
  1466. tBTM_SEC_CBACK* p_callback,
  1467. void* p_ref_data,
  1468. tBTM_BLE_SEC_ACT sec_act);
  1469. /*******************************************************************************
  1470. *
  1471. * Function BTM_ConfirmReqReply
  1472. *
  1473. * Description This function is called to confirm the numeric value for
  1474. * Simple Pairing in response to BTM_SP_CFM_REQ_EVT
  1475. *
  1476. * Parameters: res - result of the operation BTM_SUCCESS if
  1477. * success
  1478. * bd_addr - Address of the peer device
  1479. *
  1480. ******************************************************************************/
  1481. extern void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr);
  1482. /*******************************************************************************
  1483. *
  1484. * Function BTM_PasskeyReqReply
  1485. *
  1486. * Description This function is called to provide the passkey for
  1487. * Simple Pairing in response to BTM_SP_KEY_REQ_EVT
  1488. *
  1489. * Parameters: res - result of the operation BTM_SUCCESS if
  1490. * success
  1491. * bd_addr - Address of the peer device
  1492. * passkey - numeric value in the range of
  1493. * 0 - 999999(0xF423F).
  1494. *
  1495. ******************************************************************************/
  1496. extern void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr,
  1497. uint32_t passkey);
  1498. /*******************************************************************************
  1499. *
  1500. * Function BTM_SendKeypressNotif
  1501. *
  1502. * Description This function is used during the passkey entry model
  1503. * by a device with KeyboardOnly IO capabilities
  1504. * (very likely to be a HID Device).
  1505. * It is called by a HID Device to inform the remote device
  1506. * when a key has been entered or erased.
  1507. *
  1508. * Parameters: bd_addr - Address of the peer device
  1509. * type - notification type
  1510. *
  1511. ******************************************************************************/
  1512. extern void BTM_SendKeypressNotif(const RawAddress& bd_addr,
  1513. tBTM_SP_KEY_TYPE type);
  1514. /*******************************************************************************
  1515. *
  1516. * Function BTM_IoCapRsp
  1517. *
  1518. * Description This function is called in response to BTM_SP_IO_REQ_EVT
  1519. * When the event data io_req.oob_data is set to
  1520. * BTM_OOB_UNKNOWN by the tBTM_SP_CALLBACK implementation, this
  1521. * function is called to provide the actual response
  1522. *
  1523. * Parameters: bd_addr - Address of the peer device
  1524. * io_cap - The IO capability of local device.
  1525. * oob - BTM_OOB_NONE or BTM_OOB_PRESENT.
  1526. * auth_req- MITM protection required or not.
  1527. *
  1528. ******************************************************************************/
  1529. extern void BTM_IoCapRsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap,
  1530. tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
  1531. /*******************************************************************************
  1532. *
  1533. * Function BTM_ReadLocalOobData
  1534. *
  1535. * Description This function is called to read the local OOB data from
  1536. * LM
  1537. *
  1538. ******************************************************************************/
  1539. extern void BTM_ReadLocalOobData(void);
  1540. /*******************************************************************************
  1541. *
  1542. * Function BTM_RemoteOobDataReply
  1543. *
  1544. * Description This function is called to provide the remote OOB data for
  1545. * Simple Pairing in response to BTM_SP_RMT_OOB_EVT
  1546. *
  1547. * Parameters: bd_addr - Address of the peer device
  1548. * c - simple pairing Hash C.
  1549. * r - simple pairing Randomizer C.
  1550. *
  1551. ******************************************************************************/
  1552. extern void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr,
  1553. const Octet16& c, const Octet16& r);
  1554. /*******************************************************************************
  1555. *
  1556. * Function BTM_BuildOobData
  1557. *
  1558. * Description This function is called to build the OOB data payload to
  1559. * be sent over OOB (non-Bluetooth) link
  1560. *
  1561. * Parameters: p_data - the location for OOB data
  1562. * max_len - p_data size.
  1563. * c - simple pairing Hash C.
  1564. * r - simple pairing Randomizer C.
  1565. * name_len- 0, local device name would not be included.
  1566. * otherwise, the local device name is included for
  1567. * up to this specified length
  1568. *
  1569. * Returns Number of bytes in p_data.
  1570. *
  1571. ******************************************************************************/
  1572. extern uint16_t BTM_BuildOobData(uint8_t* p_data, uint16_t max_len,
  1573. const Octet16& c, const Octet16& r,
  1574. uint8_t name_len);
  1575. /*******************************************************************************
  1576. *
  1577. * Function BTM_BothEndsSupportSecureConnections
  1578. *
  1579. * Description This function is called to check if both the local device
  1580. * and the peer device specified by bd_addr support BR/EDR
  1581. * Secure Connections.
  1582. *
  1583. * Parameters: bd_addr - address of the peer
  1584. *
  1585. * Returns true if BR/EDR Secure Connections are supported by both
  1586. * local and the remote device.
  1587. * else false.
  1588. *
  1589. ******************************************************************************/
  1590. extern bool BTM_BothEndsSupportSecureConnections(const RawAddress& bd_addr);
  1591. /*******************************************************************************
  1592. *
  1593. * Function BTM_PeerSupportsSecureConnections
  1594. *
  1595. * Description This function is called to check if the peer supports
  1596. * BR/EDR Secure Connections.
  1597. *
  1598. * Parameters: bd_addr - address of the peer
  1599. *
  1600. * Returns true if BR/EDR Secure Connections are supported by the peer,
  1601. * else false.
  1602. *
  1603. ******************************************************************************/
  1604. extern bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr);
  1605. /*******************************************************************************
  1606. *
  1607. * Function BTM_ReadOobData
  1608. *
  1609. * Description This function is called to parse the OOB data payload
  1610. * received over OOB (non-Bluetooth) link
  1611. *
  1612. * Parameters: p_data - the location for OOB data
  1613. * eir_tag - The associated EIR tag to read the data.
  1614. * *p_len(output) - the length of the data with the given tag.
  1615. *
  1616. * Returns the beginning of the data with the given tag.
  1617. * NULL, if the tag is not found.
  1618. *
  1619. ******************************************************************************/
  1620. extern uint8_t* BTM_ReadOobData(uint8_t* p_data, uint8_t eir_tag,
  1621. uint8_t* p_len);
  1622. /*******************************************************************************
  1623. *
  1624. * Function BTM_SecReadDevName
  1625. *
  1626. * Description Looks for the device name in the security database for the
  1627. * specified BD address.
  1628. *
  1629. * Returns Pointer to the name or NULL
  1630. *
  1631. ******************************************************************************/
  1632. extern char* BTM_SecReadDevName(const RawAddress& bd_addr);
  1633. /*****************************************************************************
  1634. * POWER MANAGEMENT FUNCTIONS
  1635. ****************************************************************************/
  1636. /*******************************************************************************
  1637. *
  1638. * Function BTM_PmRegister
  1639. *
  1640. * Description register or deregister with power manager
  1641. *
  1642. * Returns BTM_SUCCESS if successful,
  1643. * BTM_NO_RESOURCES if no room to hold registration
  1644. * BTM_ILLEGAL_VALUE
  1645. *
  1646. ******************************************************************************/
  1647. extern tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id,
  1648. tBTM_PM_STATUS_CBACK* p_cb);
  1649. /*******************************************************************************
  1650. *
  1651. * Function BTM_SetPowerMode
  1652. *
  1653. * Description store the mode in control block or
  1654. * alter ACL connection behavior.
  1655. *
  1656. * Returns BTM_SUCCESS if successful,
  1657. * BTM_UNKNOWN_ADDR if bd addr is not active or bad
  1658. *
  1659. ******************************************************************************/
  1660. extern tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
  1661. const tBTM_PM_PWR_MD* p_mode);
  1662. /*******************************************************************************
  1663. *
  1664. * Function BTM_ReadPowerMode
  1665. *
  1666. * Description This returns the current mode for a specific
  1667. * ACL connection.
  1668. *
  1669. * Input Param remote_bda - device address of desired ACL connection
  1670. *
  1671. * Output Param p_mode - address where the current mode is copied into.
  1672. * BTM_ACL_MODE_NORMAL
  1673. * BTM_ACL_MODE_HOLD
  1674. * BTM_ACL_MODE_SNIFF
  1675. * BTM_ACL_MODE_PARK
  1676. * (valid only if return code is BTM_SUCCESS)
  1677. *
  1678. * Returns BTM_SUCCESS if successful,
  1679. * BTM_UNKNOWN_ADDR if bd addr is not active or bad
  1680. *
  1681. ******************************************************************************/
  1682. extern tBTM_STATUS BTM_ReadPowerMode(const RawAddress& remote_bda,
  1683. tBTM_PM_MODE* p_mode);
  1684. /*******************************************************************************
  1685. *
  1686. * Function BTM_SetSsrParams
  1687. *
  1688. * Description This sends the given SSR parameters for the given ACL
  1689. * connection if it is in ACTIVE mode.
  1690. *
  1691. * Input Param remote_bda - device address of desired ACL connection
  1692. * max_lat - maximum latency (in 0.625ms)(0-0xFFFE)
  1693. * min_rmt_to - minimum remote timeout
  1694. * min_loc_to - minimum local timeout
  1695. *
  1696. *
  1697. * Returns BTM_SUCCESS if the HCI command is issued successful,
  1698. * BTM_UNKNOWN_ADDR if bd addr is not active or bad
  1699. * BTM_CMD_STORED if the command is stored
  1700. *
  1701. ******************************************************************************/
  1702. extern tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda,
  1703. uint16_t max_lat, uint16_t min_rmt_to,
  1704. uint16_t min_loc_to);
  1705. /*******************************************************************************
  1706. *
  1707. * Function BTM_GetHCIConnHandle
  1708. *
  1709. * Description This function is called to get the handle for an ACL
  1710. * connection to a specific remote BD Address.
  1711. *
  1712. * Returns the handle of the connection, or 0xFFFF if none.
  1713. *
  1714. ******************************************************************************/
  1715. extern uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda,
  1716. tBT_TRANSPORT transport);
  1717. /*******************************************************************************
  1718. *
  1719. * Function BTM_DeleteStoredLinkKey
  1720. *
  1721. * Description This function is called to delete link key for the specified
  1722. * device addresses from the NVRAM storage attached to the
  1723. * Bluetooth controller.
  1724. *
  1725. * Parameters: bd_addr - Addresses of the devices
  1726. * p_cb - Call back function to be called to return
  1727. * the results
  1728. *
  1729. ******************************************************************************/
  1730. extern tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr,
  1731. tBTM_CMPL_CB* p_cb);
  1732. /*******************************************************************************
  1733. *
  1734. * Function BTM_WriteEIR
  1735. *
  1736. * Description This function is called to write EIR data to controller.
  1737. *
  1738. * Parameters p_buff - allocated HCI command buffer including extended
  1739. * inquriry response
  1740. *
  1741. * Returns BTM_SUCCESS - if successful
  1742. * BTM_MODE_UNSUPPORTED - if local device cannot support it
  1743. *
  1744. ******************************************************************************/
  1745. extern tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff);
  1746. /*******************************************************************************
  1747. *
  1748. * Function BTM_HasEirService
  1749. *
  1750. * Description This function is called to know if UUID in bit map of UUID.
  1751. *
  1752. * Parameters p_eir_uuid - bit map of UUID list
  1753. * uuid16 - UUID 16-bit
  1754. *
  1755. * Returns true - if found
  1756. * false - if not found
  1757. *
  1758. ******************************************************************************/
  1759. extern bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16);
  1760. /*******************************************************************************
  1761. *
  1762. * Function BTM_HasInquiryEirService
  1763. *
  1764. * Description Return if a UUID is in the bit map of a UUID list.
  1765. *
  1766. * Parameters p_results - inquiry results
  1767. * uuid16 - UUID 16-bit
  1768. *
  1769. * Returns BTM_EIR_FOUND - if found
  1770. * BTM_EIR_NOT_FOUND - if not found and it is a complete list
  1771. * BTM_EIR_UNKNOWN - if not found and it is not complete list
  1772. *
  1773. ******************************************************************************/
  1774. extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(
  1775. tBTM_INQ_RESULTS* p_results, uint16_t uuid16);
  1776. /*******************************************************************************
  1777. *
  1778. * Function BTM_AddEirService
  1779. *
  1780. * Description This function is called to add a service in the bit map UUID
  1781. * list.
  1782. *
  1783. * Parameters p_eir_uuid - bit mask of UUID list for EIR
  1784. * uuid16 - UUID 16-bit
  1785. *
  1786. * Returns None
  1787. *
  1788. ******************************************************************************/
  1789. extern void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
  1790. /*******************************************************************************
  1791. *
  1792. * Function BTM_RemoveEirService
  1793. *
  1794. * Description This function is called to remove a service from the bit map
  1795. * UUID list.
  1796. *
  1797. * Parameters p_eir_uuid - bit mask of UUID list for EIR
  1798. * uuid16 - UUID 16-bit
  1799. *
  1800. * Returns None
  1801. *
  1802. ******************************************************************************/
  1803. extern void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
  1804. /*******************************************************************************
  1805. *
  1806. * Function BTM_GetEirSupportedServices
  1807. *
  1808. * Description This function is called to get UUID list from bit map UUID
  1809. * list.
  1810. *
  1811. * Parameters p_eir_uuid - bit mask of UUID list for EIR
  1812. * p - reference of current pointer of EIR
  1813. * max_num_uuid16 - max number of UUID can be written in EIR
  1814. * num_uuid16 - number of UUID have been written in EIR
  1815. *
  1816. * Returns BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
  1817. * BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
  1818. *
  1819. ******************************************************************************/
  1820. extern uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p,
  1821. uint8_t max_num_uuid16,
  1822. uint8_t* p_num_uuid16);
  1823. /*******************************************************************************
  1824. *
  1825. * Function BTM_GetEirUuidList
  1826. *
  1827. * Description This function parses EIR and returns UUID list.
  1828. *
  1829. * Parameters p_eir - EIR
  1830. * eirl_len - EIR len
  1831. * uuid_size - Uuid::kNumBytes16, Uuid::kNumBytes32,
  1832. * Uuid::kNumBytes128
  1833. * p_num_uuid - return number of UUID in found list
  1834. * p_uuid_list - return UUID 16-bit list
  1835. * max_num_uuid - maximum number of UUID to be returned
  1836. *
  1837. * Returns 0 - if not found
  1838. * BTM_EIR_COMPLETE_16BITS_UUID_TYPE
  1839. * BTM_EIR_MORE_16BITS_UUID_TYPE
  1840. * BTM_EIR_COMPLETE_32BITS_UUID_TYPE
  1841. * BTM_EIR_MORE_32BITS_UUID_TYPE
  1842. * BTM_EIR_COMPLETE_128BITS_UUID_TYPE
  1843. * BTM_EIR_MORE_128BITS_UUID_TYPE
  1844. *
  1845. ******************************************************************************/
  1846. extern uint8_t BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len,
  1847. uint8_t uuid_size, uint8_t* p_num_uuid,
  1848. uint8_t* p_uuid_list, uint8_t max_num_uuid);
  1849. /*****************************************************************************
  1850. * SCO OVER HCI
  1851. ****************************************************************************/
  1852. /*******************************************************************************
  1853. *
  1854. * Function BTM_ConfigScoPath
  1855. *
  1856. * Description This function enable/disable SCO over HCI and registers SCO
  1857. * data callback if SCO over HCI is enabled.
  1858. *
  1859. * Parameter path: SCO or HCI
  1860. * p_sco_data_cb: callback function or SCO data if path is set
  1861. * to transport.
  1862. * p_pcm_param: pointer to the PCM interface parameter. If a
  1863. * NULL pointer is used, the PCM parameter
  1864. * maintained in the control block will be used;
  1865. * otherwise update the control block value.
  1866. * err_data_rpt: Lisbon feature to enable the erronous data
  1867. * report or not.
  1868. *
  1869. * Returns BTM_SUCCESS if the successful.
  1870. * BTM_NO_RESOURCES: no rsource to start the command.
  1871. * BTM_ILLEGAL_VALUE: invalid callback function pointer.
  1872. * BTM_CMD_STARTED : Command sent. Waiting for command
  1873. * complete event.
  1874. *
  1875. *
  1876. ******************************************************************************/
  1877. extern tBTM_STATUS BTM_ConfigScoPath(esco_data_path_t path,
  1878. tBTM_SCO_DATA_CB* p_sco_data_cb,
  1879. tBTM_SCO_PCM_PARAM* p_pcm_param,
  1880. bool err_data_rpt);
  1881. /*******************************************************************************
  1882. *
  1883. * Function BTM_WriteScoData
  1884. *
  1885. * Description This function write SCO data to a specified instance. The
  1886. * data to be written p_buf needs to carry an offset of
  1887. * HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
  1888. * exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is
  1889. * set to 60 and is configurable. Data longer than the maximum
  1890. * bytes will be truncated.
  1891. *
  1892. * Returns BTM_SUCCESS: data write is successful
  1893. * BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
  1894. * BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO
  1895. * packet size.
  1896. * BTM_NO_RESOURCES: no resources.
  1897. * BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is
  1898. * not routed via HCI.
  1899. *
  1900. *
  1901. ******************************************************************************/
  1902. extern tBTM_STATUS BTM_WriteScoData(uint16_t sco_inx, BT_HDR* p_buf);
  1903. /*******************************************************************************
  1904. *
  1905. * Function BTM_SetARCMode
  1906. *
  1907. * Description Send Audio Routing Control command.
  1908. *
  1909. * Returns void
  1910. *
  1911. ******************************************************************************/
  1912. extern void BTM_SetARCMode(uint8_t iface, uint8_t arc_mode,
  1913. tBTM_VSC_CMPL_CB* p_arc_cb);
  1914. /*******************************************************************************
  1915. *
  1916. * Function BTM_PCM2Setup_Write
  1917. *
  1918. * Description Send PCM2_Setup write command.
  1919. *
  1920. * Returns void
  1921. *
  1922. ******************************************************************************/
  1923. extern void BTM_PCM2Setup_Write(bool clk_master, tBTM_VSC_CMPL_CB* p_arc_cb);
  1924. /*******************************************************************************
  1925. *
  1926. * Function BTM_PM_ReadControllerState
  1927. *
  1928. * Description This function is called to obtain the controller state
  1929. *
  1930. * Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and
  1931. * BTM_CONTRL_IDLE)
  1932. *
  1933. ******************************************************************************/
  1934. extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
  1935. #endif /* BTM_API_H */