btm_api.h 161 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 1999-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  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_defs.h"
  27. #include "bt_target.h"
  28. #include "hcidefs.h"
  29. #if SDP_INCLUDED == TRUE
  30. #include "sdp_api.h"
  31. #endif
  32. #if SMP_INCLUDED == TRUE
  33. #include "smp_api.h"
  34. #endif
  35. /*****************************************************************************
  36. ** DEVICE CONTROL and COMMON
  37. *****************************************************************************/
  38. /*****************************
  39. ** Device Control Constants
  40. ******************************/
  41. /* Maximum number of bytes allowed for vendor specific command parameters */
  42. #define BTM_MAX_VENDOR_SPECIFIC_LEN HCI_COMMAND_SIZE
  43. /* BTM application return status codes */
  44. enum {
  45. BTM_SUCCESS = 0, /* 0 Command succeeded */
  46. BTM_CMD_STARTED, /* 1 Command started OK. */
  47. BTM_BUSY, /* 2 Device busy with another command */
  48. BTM_NO_RESOURCES, /* 3 No resources to issue command */
  49. BTM_MODE_UNSUPPORTED, /* 4 Request for 1 or more unsupported modes */
  50. BTM_ILLEGAL_VALUE, /* 5 Illegal parameter value */
  51. BTM_WRONG_MODE, /* 6 Device in wrong mode for request */
  52. BTM_UNKNOWN_ADDR, /* 7 Unknown remote BD address */
  53. BTM_DEVICE_TIMEOUT, /* 8 Device timeout */
  54. BTM_BAD_VALUE_RET, /* 9 A bad value was received from HCI */
  55. BTM_ERR_PROCESSING, /* 10 Generic error */
  56. BTM_NOT_AUTHORIZED, /* 11 Authorization failed */
  57. BTM_DEV_RESET, /* 12 Device has been reset */
  58. BTM_CMD_STORED, /* 13 request is stored in control block */
  59. BTM_ILLEGAL_ACTION, /* 14 state machine gets illegal command */
  60. BTM_DELAY_CHECK, /* 15 delay the check on encryption */
  61. BTM_SCO_BAD_LENGTH, /* 16 Bad SCO over HCI data length */
  62. BTM_SUCCESS_NO_SECURITY, /* 17 security passed, no security set */
  63. BTM_FAILED_ON_SECURITY, /* 18 security failed */
  64. BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */
  65. BTM_MODE4_LEVEL4_NOT_SUPPORTED /* 20 Secure Connections Only Mode can't be supported */
  66. };
  67. typedef uint8_t tBTM_STATUS;
  68. #if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
  69. typedef enum {
  70. BTM_BR_ONE, /*0 First state or BR/EDR scan 1*/
  71. BTM_BLE_ONE, /*1BLE scan 1*/
  72. BTM_BR_TWO, /*2 BR/EDR scan 2*/
  73. BTM_BLE_TWO, /*3 BLE scan 2*/
  74. BTM_FINISH, /*4 End of Interleave Scan, or normal scan*/
  75. BTM_NO_INTERLEAVING /*5 No Interleaving*/
  76. } btm_inq_state;
  77. #endif
  78. /*************************
  79. ** Device Control Types
  80. **************************/
  81. #define BTM_DEVICE_ROLE_BR 0x01
  82. #define BTM_DEVICE_ROLE_DUAL 0x02
  83. #define BTM_MAX_DEVICE_ROLE BTM_DEVICE_ROLE_DUAL
  84. typedef UINT8 tBTM_DEVICE_ROLE;
  85. /* Device name of peer (may be truncated to save space in BTM database) */
  86. typedef UINT8 tBTM_BD_NAME[BTM_MAX_REM_BD_NAME_LEN + 1];
  87. /* Structure returned with local version information */
  88. typedef struct {
  89. UINT8 hci_version;
  90. UINT16 hci_revision;
  91. UINT8 lmp_version;
  92. UINT16 manufacturer;
  93. UINT16 lmp_subversion;
  94. } tBTM_VERSION_INFO;
  95. /* Structure returned with Vendor Specific Command complete callback */
  96. typedef struct {
  97. UINT16 opcode;
  98. UINT16 param_len;
  99. UINT8 *p_param_buf;
  100. } tBTM_VSC_CMPL;
  101. #define BTM_VSC_CMPL_DATA_SIZE (BTM_MAX_VENDOR_SPECIFIC_LEN + sizeof(tBTM_VSC_CMPL))
  102. /**************************************************
  103. ** Device Control and General Callback Functions
  104. ***************************************************/
  105. /* Callback function for when device status changes. Appl must poll for
  106. ** what the new state is (BTM_IsDeviceUp). The event occurs whenever the stack
  107. ** has detected that the controller status has changed. This asynchronous event
  108. ** is enabled/disabled by calling BTM_RegisterForDeviceStatusNotif().
  109. */
  110. enum {
  111. BTM_DEV_STATUS_UP,
  112. BTM_DEV_STATUS_DOWN,
  113. BTM_DEV_STATUS_CMD_TOUT
  114. };
  115. typedef UINT8 tBTM_DEV_STATUS;
  116. typedef void (tBTM_DEV_STATUS_CB) (tBTM_DEV_STATUS status);
  117. /* Callback function for when a vendor specific event occurs. The length and
  118. ** array of returned parameter bytes are included. This asynchronous event
  119. ** is enabled/disabled by calling BTM_RegisterForVSEvents().
  120. */
  121. typedef void (tBTM_VS_EVT_CB) (UINT8 len, UINT8 *p);
  122. /* General callback function for notifying an application that a synchronous
  123. ** BTM function is complete. The pointer contains the address of any returned data.
  124. */
  125. typedef void (tBTM_CMPL_CB) (void *p1);
  126. /* VSC callback function for notifying an application that a synchronous
  127. ** BTM function is complete. The pointer contains the address of any returned data.
  128. */
  129. typedef void (tBTM_VSC_CMPL_CB) (tBTM_VSC_CMPL *p1);
  130. /* Callback for apps to check connection and inquiry filters.
  131. ** Parameters are the BD Address of remote and the Dev Class of remote.
  132. ** If the app returns none zero, the connection or inquiry result will be dropped.
  133. */
  134. typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc);
  135. /*****************************************************************************
  136. ** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
  137. *****************************************************************************/
  138. /*******************************
  139. ** Device Discovery Constants
  140. ********************************/
  141. /* Discoverable modes */
  142. #define BTM_NON_DISCOVERABLE 0
  143. #define BTM_LIMITED_DISCOVERABLE 1
  144. #define BTM_GENERAL_DISCOVERABLE 2
  145. #define BTM_DISCOVERABLE_MASK (BTM_LIMITED_DISCOVERABLE|BTM_GENERAL_DISCOVERABLE)
  146. #define BTM_MAX_DISCOVERABLE BTM_GENERAL_DISCOVERABLE
  147. /* high byte for BLE Discoverable modes */
  148. #define BTM_BLE_NON_DISCOVERABLE 0x0000
  149. #define BTM_BLE_LIMITED_DISCOVERABLE 0x0100
  150. #define BTM_BLE_GENERAL_DISCOVERABLE 0x0200
  151. #define BTM_BLE_MAX_DISCOVERABLE BTM_BLE_GENERAL_DISCOVERABLE
  152. #define BTM_BLE_DISCOVERABLE_MASK (BTM_BLE_NON_DISCOVERABLE|BTM_BLE_LIMITED_DISCOVERABLE|BTM_BLE_GENERAL_DISCOVERABLE)
  153. /* Connectable modes */
  154. #define BTM_NON_CONNECTABLE 0
  155. #define BTM_CONNECTABLE 1
  156. #define BTM_CONNECTABLE_MASK (BTM_NON_CONNECTABLE | BTM_CONNECTABLE)
  157. /* high byte for BLE Connectable modes */
  158. #define BTM_BLE_NON_CONNECTABLE 0x0000
  159. #define BTM_BLE_CONNECTABLE 0x0100
  160. #define BTM_BLE_MAX_CONNECTABLE BTM_BLE_CONNECTABLE
  161. #define BTM_BLE_CONNECTABLE_MASK (BTM_BLE_NON_CONNECTABLE | BTM_BLE_CONNECTABLE)
  162. /* Inquiry modes
  163. * Note: These modes are associated with the inquiry active values (BTM_*ACTIVE) */
  164. #define BTM_INQUIRY_NONE 0
  165. #define BTM_GENERAL_INQUIRY 0x01
  166. #define BTM_LIMITED_INQUIRY 0x02
  167. #define BTM_BR_INQUIRY_MASK (BTM_GENERAL_INQUIRY | BTM_LIMITED_INQUIRY)
  168. /* high byte of inquiry mode for BLE inquiry mode */
  169. #define BTM_BLE_INQUIRY_NONE 0x00
  170. #define BTM_BLE_GENERAL_INQUIRY 0x10
  171. #define BTM_BLE_LIMITED_INQUIRY 0x20
  172. #define BTM_BLE_INQUIRY_MASK (BTM_BLE_GENERAL_INQUIRY|BTM_BLE_LIMITED_INQUIRY)
  173. /* BTM_IsInquiryActive return values (Bit Mask)
  174. * Note: These bit masks are associated with the inquiry modes (BTM_*_INQUIRY) */
  175. #define BTM_INQUIRY_INACTIVE 0x0 /* no inquiry in progress */
  176. #define BTM_GENERAL_INQUIRY_ACTIVE BTM_GENERAL_INQUIRY /* a general inquiry is in progress */
  177. #define BTM_LIMITED_INQUIRY_ACTIVE BTM_LIMITED_INQUIRY /* a limited inquiry is in progress */
  178. #define BTM_PERIODIC_INQUIRY_ACTIVE 0x8 /* a periodic inquiry is active */
  179. #define BTM_SSP_INQUIRY_ACTIVE 0x4 /* SSP is active, so inquiry is disallowed (work around for FW bug) */
  180. #define BTM_LE_GENERAL_INQUIRY_ACTIVE BTM_BLE_GENERAL_INQUIRY /* a general inquiry is in progress */
  181. #define BTM_LE_LIMITED_INQUIRY_ACTIVE BTM_BLE_LIMITED_INQUIRY /* a limited inquiry is in progress */
  182. /* inquiry activity mask */
  183. #define BTM_BR_INQ_ACTIVE_MASK (BTM_GENERAL_INQUIRY_ACTIVE|BTM_LIMITED_INQUIRY_ACTIVE|BTM_PERIODIC_INQUIRY_ACTIVE) /* BR/EDR inquiry activity mask */
  184. #define BTM_BLE_SCAN_ACTIVE_MASK 0xF0 /* LE scan activity mask */
  185. #define BTM_BLE_INQ_ACTIVE_MASK (BTM_LE_GENERAL_INQUIRY_ACTIVE|BTM_LE_LIMITED_INQUIRY_ACTIVE) /* LE inquiry activity mask*/
  186. #define BTM_INQUIRY_ACTIVE_MASK (BTM_BR_INQ_ACTIVE_MASK | BTM_BLE_INQ_ACTIVE_MASK) /* inquiry activity mask */
  187. /* Define scan types */
  188. #define BTM_SCAN_TYPE_STANDARD 0
  189. #define BTM_SCAN_TYPE_INTERLACED 1 /* 1.2 devices only */
  190. /* Define inquiry results mode */
  191. #define BTM_INQ_RESULT_STANDARD 0
  192. #define BTM_INQ_RESULT_WITH_RSSI 1
  193. #define BTM_INQ_RESULT_EXTENDED 2
  194. #define BTM_INQ_RES_IGNORE_RSSI 0x7f /* RSSI value not supplied (ignore it) */
  195. /* Inquiry Filter Condition types (see tBTM_INQ_PARMS) */
  196. #define BTM_CLR_INQUIRY_FILTER 0 /* Inquiry Filtering is turned off */
  197. #define BTM_FILTER_COND_DEVICE_CLASS HCI_FILTER_COND_DEVICE_CLASS /* Filter on device class */
  198. #define BTM_FILTER_COND_BD_ADDR HCI_FILTER_COND_BD_ADDR /* Filter on device addr */
  199. /* State of the remote name retrieval during inquiry operations.
  200. ** Used in the tBTM_INQ_INFO structure, and returned in the
  201. ** BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext functions.
  202. ** The name field is valid when the state returned is
  203. ** BTM_INQ_RMT_NAME_DONE */
  204. #define BTM_INQ_RMT_NAME_EMPTY 0
  205. #define BTM_INQ_RMT_NAME_PENDING 1
  206. #define BTM_INQ_RMT_NAME_DONE 2
  207. #define BTM_INQ_RMT_NAME_FAILED 3
  208. /*********************************
  209. *** Class of Device constants ***
  210. *********************************/
  211. #define BTM_FORMAT_TYPE_1 0x00
  212. /****************************
  213. ** minor device class field
  214. *****************************/
  215. /* 0x00 is used as unclassified for all minor device classes */
  216. #define BTM_COD_MINOR_UNCLASSIFIED 0x00
  217. /* minor device class field for Computer Major Class */
  218. /* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
  219. #define BTM_COD_MINOR_DESKTOP_WORKSTATION 0x04
  220. #define BTM_COD_MINOR_SERVER_COMPUTER 0x08
  221. #define BTM_COD_MINOR_LAPTOP 0x0C
  222. #define BTM_COD_MINOR_HANDHELD_PC_PDA 0x10 /* clam shell */
  223. #define BTM_COD_MINOR_PALM_SIZE_PC_PDA 0x14
  224. #define BTM_COD_MINOR_WEARABLE_COMPUTER 0x18 /* watch sized */
  225. /* minor device class field for Phone Major Class */
  226. /* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
  227. #define BTM_COD_MINOR_CELLULAR 0x04
  228. #define BTM_COD_MINOR_CORDLESS 0x08
  229. #define BTM_COD_MINOR_SMART_PHONE 0x0C
  230. #define BTM_COD_MINOR_WIRED_MDM_V_GTWY 0x10 /* wired modem or voice gatway */
  231. #define BTM_COD_MINOR_ISDN_ACCESS 0x14
  232. /* minor device class field for LAN Access Point Major Class */
  233. /* Load Factor Field bit 5-7 */
  234. #define BTM_COD_MINOR_FULLY_AVAILABLE 0x00
  235. #define BTM_COD_MINOR_1_17_UTILIZED 0x20
  236. #define BTM_COD_MINOR_17_33_UTILIZED 0x40
  237. #define BTM_COD_MINOR_33_50_UTILIZED 0x60
  238. #define BTM_COD_MINOR_50_67_UTILIZED 0x80
  239. #define BTM_COD_MINOR_67_83_UTILIZED 0xA0
  240. #define BTM_COD_MINOR_83_99_UTILIZED 0xC0
  241. #define BTM_COD_MINOR_NO_SERVICE_AVAILABLE 0xE0
  242. /* sub-Field bit 2-4 */
  243. /* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
  244. /* minor device class field for Audio/Video Major Class */
  245. /* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
  246. #define BTM_COD_MINOR_CONFM_HEADSET 0x04
  247. #define BTM_COD_MINOR_CONFM_HANDSFREE 0x08
  248. #define BTM_COD_MINOR_MICROPHONE 0x10
  249. #define BTM_COD_MINOR_LOUDSPEAKER 0x14
  250. #define BTM_COD_MINOR_HEADPHONES 0x18
  251. #define BTM_COD_MINOR_PORTABLE_AUDIO 0x1C
  252. #define BTM_COD_MINOR_CAR_AUDIO 0x20
  253. #define BTM_COD_MINOR_SET_TOP_BOX 0x24
  254. #define BTM_COD_MINOR_HIFI_AUDIO 0x28
  255. #define BTM_COD_MINOR_VCR 0x2C
  256. #define BTM_COD_MINOR_VIDEO_CAMERA 0x30
  257. #define BTM_COD_MINOR_CAMCORDER 0x34
  258. #define BTM_COD_MINOR_VIDEO_MONITOR 0x38
  259. #define BTM_COD_MINOR_VIDDISP_LDSPKR 0x3C
  260. #define BTM_COD_MINOR_VIDEO_CONFERENCING 0x40
  261. #define BTM_COD_MINOR_GAMING_TOY 0x48
  262. /* minor device class field for Peripheral Major Class */
  263. /* Bits 6-7 independently specify mouse, keyboard, or combo mouse/keyboard */
  264. #define BTM_COD_MINOR_KEYBOARD 0x40
  265. #define BTM_COD_MINOR_POINTING 0x80
  266. #define BTM_COD_MINOR_COMBO 0xC0
  267. /* Bits 2-5 OR'd with selection from bits 6-7 */
  268. /* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
  269. #define BTM_COD_MINOR_JOYSTICK 0x04
  270. #define BTM_COD_MINOR_GAMEPAD 0x08
  271. #define BTM_COD_MINOR_REMOTE_CONTROL 0x0C
  272. #define BTM_COD_MINOR_SENSING_DEVICE 0x10
  273. #define BTM_COD_MINOR_DIGITIZING_TABLET 0x14
  274. #define BTM_COD_MINOR_CARD_READER 0x18 /* e.g. SIM card reader */
  275. #define BTM_COD_MINOR_DIGITAL_PAN 0x1C
  276. #define BTM_COD_MINOR_HAND_SCANNER 0x20
  277. #define BTM_COD_MINOR_HAND_GESTURAL_INPUT 0x24
  278. /* minor device class field for Imaging Major Class */
  279. /* Bits 5-7 independently specify display, camera, scanner, or printer */
  280. #define BTM_COD_MINOR_DISPLAY 0x10
  281. #define BTM_COD_MINOR_CAMERA 0x20
  282. #define BTM_COD_MINOR_SCANNER 0x40
  283. #define BTM_COD_MINOR_PRINTER 0x80
  284. /* Bits 2-3 Reserved */
  285. /* #define BTM_COD_MINOR_UNCLASSIFIED 0x00 */
  286. /* minor device class field for Wearable Major Class */
  287. /* Bits 2-7 meaningful */
  288. #define BTM_COD_MINOR_WRIST_WATCH 0x04
  289. #define BTM_COD_MINOR_PAGER 0x08
  290. #define BTM_COD_MINOR_JACKET 0x0C
  291. #define BTM_COD_MINOR_HELMET 0x10
  292. #define BTM_COD_MINOR_GLASSES 0x14
  293. /* minor device class field for Toy Major Class */
  294. /* Bits 2-7 meaningful */
  295. #define BTM_COD_MINOR_ROBOT 0x04
  296. #define BTM_COD_MINOR_VEHICLE 0x08
  297. #define BTM_COD_MINOR_DOLL_ACTION_FIGURE 0x0C
  298. #define BTM_COD_MINOR_CONTROLLER 0x10
  299. #define BTM_COD_MINOR_GAME 0x14
  300. /* minor device class field for Health Major Class */
  301. /* Bits 2-7 meaningful */
  302. #define BTM_COD_MINOR_BLOOD_MONITOR 0x04
  303. #define BTM_COD_MINOR_THERMOMETER 0x08
  304. #define BTM_COD_MINOR_WEIGHING_SCALE 0x0C
  305. #define BTM_COD_MINOR_GLUCOSE_METER 0x10
  306. #define BTM_COD_MINOR_PULSE_OXIMETER 0x14
  307. #define BTM_COD_MINOR_HEART_PULSE_MONITOR 0x18
  308. #define BTM_COD_MINOR_HEALTH_DATA_DISPLAY 0x1C
  309. #define BTM_COD_MINOR_STEP_COUNTER 0x20
  310. #define BTM_COD_MINOR_BODY_COM_ANALYZER 0x24
  311. #define BTM_COD_MINOR_PEAK_FLOW_MONITOR 0x28
  312. #define BTM_COD_MINOR_MEDICATION_MONITOR 0x2C
  313. #define BTM_COD_MINOR_KNEE_PROSTHESIS 0x30
  314. #define BTM_COD_MINOR_ANKLE_PROSTHESIS 0x34
  315. /***************************
  316. ** major device class field
  317. ****************************/
  318. #define BTM_COD_MAJOR_MISCELLANEOUS 0x00
  319. #define BTM_COD_MAJOR_COMPUTER 0x01
  320. #define BTM_COD_MAJOR_PHONE 0x02
  321. #define BTM_COD_MAJOR_LAN_ACCESS_PT 0x03
  322. #define BTM_COD_MAJOR_AUDIO 0x04
  323. #define BTM_COD_MAJOR_PERIPHERAL 0x05
  324. #define BTM_COD_MAJOR_IMAGING 0x06
  325. #define BTM_COD_MAJOR_WEARABLE 0x07
  326. #define BTM_COD_MAJOR_TOY 0x08
  327. #define BTM_COD_MAJOR_HEALTH 0x09
  328. #define BTM_COD_MAJOR_UNCLASSIFIED 0x1F
  329. /***************************
  330. ** service class fields
  331. ****************************/
  332. #define BTM_COD_SERVICE_LMTD_DISCOVER 0x0020
  333. #define BTM_COD_SERVICE_POSITIONING 0x0100
  334. #define BTM_COD_SERVICE_NETWORKING 0x0200
  335. #define BTM_COD_SERVICE_RENDERING 0x0400
  336. #define BTM_COD_SERVICE_CAPTURING 0x0800
  337. #define BTM_COD_SERVICE_OBJ_TRANSFER 0x1000
  338. #define BTM_COD_SERVICE_AUDIO 0x2000
  339. #define BTM_COD_SERVICE_TELEPHONY 0x4000
  340. #define BTM_COD_SERVICE_INFORMATION 0x8000
  341. /* class of device field macros */
  342. #define BTM_COD_FORMAT_TYPE(u8, pd) {u8 = pd[2]&0x03;}
  343. #define BTM_COD_MINOR_CLASS(u8, pd) {u8 = pd[2]&0xFC;}
  344. #define BTM_COD_MAJOR_CLASS(u8, pd) {u8 = pd[1]&0x1F;}
  345. #define BTM_COD_SERVICE_CLASS(u16, pd) {u16 = pd[0]; u16<<=8; u16 += pd[1]&0xE0;}
  346. /* to set the fields (assumes that format type is always 0) */
  347. #define FIELDS_TO_COD(pd, mn, mj, sv) {pd[2] = mn; pd[1] = \
  348. mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \
  349. pd[0] = (sv) >> 8;}
  350. /* the COD masks */
  351. #define BTM_COD_FORMAT_TYPE_MASK 0x03
  352. #define BTM_COD_MINOR_CLASS_MASK 0xFC
  353. #define BTM_COD_MAJOR_CLASS_MASK 0x1F
  354. #define BTM_COD_SERVICE_CLASS_LO_B 0x00E0
  355. #define BTM_COD_SERVICE_CLASS_MASK 0xFFE0
  356. /* BTM service definitions
  357. ** Used for storing EIR data to bit mask
  358. */
  359. enum {
  360. BTM_EIR_UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER,
  361. /* BTM_EIR_UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR, */
  362. /* BTM_EIR_UUID_SERVCLASS_PUBLIC_BROWSE_GROUP, */
  363. BTM_EIR_UUID_SERVCLASS_SERIAL_PORT,
  364. BTM_EIR_UUID_SERVCLASS_LAN_ACCESS_USING_PPP,
  365. BTM_EIR_UUID_SERVCLASS_DIALUP_NETWORKING,
  366. BTM_EIR_UUID_SERVCLASS_IRMC_SYNC,
  367. BTM_EIR_UUID_SERVCLASS_OBEX_OBJECT_PUSH,
  368. BTM_EIR_UUID_SERVCLASS_OBEX_FILE_TRANSFER,
  369. BTM_EIR_UUID_SERVCLASS_IRMC_SYNC_COMMAND,
  370. BTM_EIR_UUID_SERVCLASS_HEADSET,
  371. BTM_EIR_UUID_SERVCLASS_CORDLESS_TELEPHONY,
  372. BTM_EIR_UUID_SERVCLASS_AUDIO_SOURCE,
  373. BTM_EIR_UUID_SERVCLASS_AUDIO_SINK,
  374. BTM_EIR_UUID_SERVCLASS_AV_REM_CTRL_TARGET,
  375. /* BTM_EIR_UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION, */
  376. BTM_EIR_UUID_SERVCLASS_AV_REMOTE_CONTROL,
  377. /* BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING, */
  378. BTM_EIR_UUID_SERVCLASS_INTERCOM,
  379. BTM_EIR_UUID_SERVCLASS_FAX,
  380. BTM_EIR_UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY,
  381. /* BTM_EIR_UUID_SERVCLASS_WAP, */
  382. /* BTM_EIR_UUID_SERVCLASS_WAP_CLIENT, */
  383. BTM_EIR_UUID_SERVCLASS_PANU,
  384. BTM_EIR_UUID_SERVCLASS_NAP,
  385. BTM_EIR_UUID_SERVCLASS_GN,
  386. BTM_EIR_UUID_SERVCLASS_DIRECT_PRINTING,
  387. /* BTM_EIR_UUID_SERVCLASS_REFERENCE_PRINTING, */
  388. BTM_EIR_UUID_SERVCLASS_IMAGING,
  389. BTM_EIR_UUID_SERVCLASS_IMAGING_RESPONDER,
  390. BTM_EIR_UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE,
  391. BTM_EIR_UUID_SERVCLASS_IMAGING_REF_OBJECTS,
  392. BTM_EIR_UUID_SERVCLASS_HF_HANDSFREE,
  393. BTM_EIR_UUID_SERVCLASS_AG_HANDSFREE,
  394. BTM_EIR_UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE,
  395. /* BTM_EIR_UUID_SERVCLASS_REFLECTED_UI, */
  396. BTM_EIR_UUID_SERVCLASS_BASIC_PRINTING,
  397. BTM_EIR_UUID_SERVCLASS_PRINTING_STATUS,
  398. BTM_EIR_UUID_SERVCLASS_HUMAN_INTERFACE,
  399. BTM_EIR_UUID_SERVCLASS_CABLE_REPLACEMENT,
  400. BTM_EIR_UUID_SERVCLASS_HCRP_PRINT,
  401. BTM_EIR_UUID_SERVCLASS_HCRP_SCAN,
  402. /* BTM_EIR_UUID_SERVCLASS_COMMON_ISDN_ACCESS, */
  403. /* BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING_GW, */
  404. /* BTM_EIR_UUID_SERVCLASS_UDI_MT, */
  405. /* BTM_EIR_UUID_SERVCLASS_UDI_TA, */
  406. /* BTM_EIR_UUID_SERVCLASS_VCP, */
  407. BTM_EIR_UUID_SERVCLASS_SAP,
  408. BTM_EIR_UUID_SERVCLASS_PBAP_PCE,
  409. BTM_EIR_UUID_SERVCLASS_PBAP_PSE,
  410. /* BTM_EIR_UUID_SERVCLASS_TE_PHONE_ACCESS, */
  411. /* BTM_EIR_UUID_SERVCLASS_ME_PHONE_ACCESS, */
  412. BTM_EIR_UUID_SERVCLASS_PHONE_ACCESS,
  413. BTM_EIR_UUID_SERVCLASS_HEADSET_HS,
  414. BTM_EIR_UUID_SERVCLASS_PNP_INFORMATION,
  415. /* BTM_EIR_UUID_SERVCLASS_GENERIC_NETWORKING, */
  416. /* BTM_EIR_UUID_SERVCLASS_GENERIC_FILETRANSFER, */
  417. /* BTM_EIR_UUID_SERVCLASS_GENERIC_AUDIO, */
  418. /* BTM_EIR_UUID_SERVCLASS_GENERIC_TELEPHONY, */
  419. /* BTM_EIR_UUID_SERVCLASS_UPNP_SERVICE, */
  420. /* BTM_EIR_UUID_SERVCLASS_UPNP_IP_SERVICE, */
  421. /* BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_PAN, */
  422. /* BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_LAP, */
  423. /* BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP, */
  424. BTM_EIR_UUID_SERVCLASS_VIDEO_SOURCE,
  425. BTM_EIR_UUID_SERVCLASS_VIDEO_SINK,
  426. /* BTM_EIR_UUID_SERVCLASS_VIDEO_DISTRIBUTION */
  427. /* BTM_EIR_UUID_SERVCLASS_HDP_PROFILE */
  428. BTM_EIR_UUID_SERVCLASS_MESSAGE_ACCESS,
  429. BTM_EIR_UUID_SERVCLASS_MESSAGE_NOTIFICATION,
  430. BTM_EIR_UUID_SERVCLASS_HDP_SOURCE,
  431. BTM_EIR_UUID_SERVCLASS_HDP_SINK,
  432. BTM_EIR_MAX_SERVICES
  433. };
  434. /* search result in EIR of inquiry database */
  435. #define BTM_EIR_FOUND 0
  436. #define BTM_EIR_NOT_FOUND 1
  437. #define BTM_EIR_UNKNOWN 2
  438. typedef UINT8 tBTM_EIR_SEARCH_RESULT;
  439. #define BTM_EIR_FLAGS_TYPE HCI_EIR_FLAGS_TYPE /* 0x01 */
  440. #define BTM_EIR_MORE_16BITS_UUID_TYPE HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */
  441. #define BTM_EIR_COMPLETE_16BITS_UUID_TYPE HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */
  442. #define BTM_EIR_MORE_32BITS_UUID_TYPE HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */
  443. #define BTM_EIR_COMPLETE_32BITS_UUID_TYPE HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */
  444. #define BTM_EIR_MORE_128BITS_UUID_TYPE HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */
  445. #define BTM_EIR_COMPLETE_128BITS_UUID_TYPE HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */
  446. #define BTM_EIR_SHORTENED_LOCAL_NAME_TYPE HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */
  447. #define BTM_EIR_COMPLETE_LOCAL_NAME_TYPE HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */
  448. #define BTM_EIR_TX_POWER_LEVEL_TYPE HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */
  449. #define BTM_EIR_MANUFACTURER_SPECIFIC_TYPE HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xFF */
  450. /* the following EIR tags are defined to OOB, not regular EIR data */
  451. #define BTM_EIR_OOB_BD_ADDR_TYPE HCI_EIR_OOB_BD_ADDR_TYPE /* 6 bytes */
  452. #define BTM_EIR_OOB_COD_TYPE HCI_EIR_OOB_COD_TYPE /* 3 bytes */
  453. #define BTM_EIR_OOB_SSP_HASH_C_TYPE HCI_EIR_OOB_SSP_HASH_C_TYPE /* 16 bytes */
  454. #define BTM_EIR_OOB_SSP_RAND_R_TYPE HCI_EIR_OOB_SSP_RAND_R_TYPE /* 16 bytes */
  455. #define BTM_OOB_MANDATORY_SIZE 8 /* include 2 bytes length & 6 bytes bd_addr */
  456. #define BTM_OOB_DATA_LEN_SIZE 2
  457. #define BTM_OOB_BD_ADDR_SIZE 6
  458. #define BTM_OOB_COD_SIZE BT_OOB_COD_SIZE
  459. #define BTM_OOB_HASH_C_SIZE BT_OOB_HASH_C_SIZE
  460. #define BTM_OOB_RAND_R_SIZE BT_OOB_RAND_R_SIZE
  461. #if BLE_INCLUDED == TRUE
  462. #define BTM_BLE_SEC_NONE 0
  463. #define BTM_BLE_SEC_ENCRYPT 1 /* encrypt the link using current key */
  464. #define BTM_BLE_SEC_ENCRYPT_NO_MITM 2
  465. #define BTM_BLE_SEC_ENCRYPT_MITM 3
  466. typedef UINT8 tBTM_BLE_SEC_ACT;
  467. #endif
  468. /************************************************************************************************
  469. ** BTM Services MACROS handle array of UINT32 bits for more than 32 services
  470. *************************************************************************************************/
  471. /* Determine the number of UINT32's necessary for services */
  472. #define BTM_EIR_ARRAY_BITS 32 /* Number of bits in each array element */
  473. #define BTM_EIR_SERVICE_ARRAY_SIZE (((UINT32)BTM_EIR_MAX_SERVICES / BTM_EIR_ARRAY_BITS) + \
  474. (((UINT32)BTM_EIR_MAX_SERVICES % BTM_EIR_ARRAY_BITS) ? 1 : 0))
  475. /* MACRO to set the service bit mask in a bit stream */
  476. #define BTM_EIR_SET_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] |= \
  477. ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
  478. /* MACRO to clear the service bit mask in a bit stream */
  479. #define BTM_EIR_CLR_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] &= \
  480. ~((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
  481. /* MACRO to check the service bit mask in a bit stream */
  482. #define BTM_EIR_HAS_SERVICE(p, service) ((((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] & \
  483. ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))) >> (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))
  484. /* start of EIR in HCI buffer, 4 bytes = HCI Command(2) + Length(1) + FEC_Req(1) */
  485. #define BTM_HCI_EIR_OFFSET (BT_HDR_SIZE + 4)
  486. /***************************
  487. ** Device Discovery Types
  488. ****************************/
  489. /* Definitions of the parameters passed to BTM_StartInquiry and
  490. ** BTM_SetPeriodicInquiryMode.
  491. */
  492. typedef struct { /* contains the two device class condition fields */
  493. DEV_CLASS dev_class;
  494. DEV_CLASS dev_class_mask;
  495. } tBTM_COD_COND;
  496. typedef union { /* contains the inquiry filter condition */
  497. BD_ADDR bdaddr_cond;
  498. tBTM_COD_COND cod_cond;
  499. } tBTM_INQ_FILT_COND;
  500. typedef struct { /* contains the parameters passed to the inquiry functions */
  501. UINT8 mode; /* general or limited */
  502. UINT8 duration; /* duration of the inquiry (1.28 sec increments) */
  503. UINT8 max_resps; /* maximum number of responses to return */
  504. BOOLEAN report_dup; /* report duplicated inquiry response with higher RSSI value */
  505. UINT8 filter_cond_type; /* new devices, BD ADDR, COD, or No filtering */
  506. tBTM_INQ_FILT_COND filter_cond; /* filter value based on filter cond type */
  507. #if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
  508. UINT8 intl_duration[4]; /*duration array storing the interleave scan's time portions*/
  509. #endif
  510. } tBTM_INQ_PARMS;
  511. #define BTM_INQ_RESULT_BR 0x01
  512. #define BTM_INQ_RESULT_BLE 0x02
  513. #if (BLE_INCLUDED == TRUE)
  514. #define BTM_BLE_EVT_CONN_ADV 0x00
  515. #define BTM_BLE_EVT_CONN_DIR_ADV 0x01
  516. #define BTM_BLE_EVT_DISC_ADV 0x02
  517. #define BTM_BLE_EVT_NON_CONN_ADV 0x03
  518. #define BTM_BLE_EVT_SCAN_RSP 0x04
  519. typedef UINT8 tBTM_BLE_EVT_TYPE;
  520. #endif
  521. /* These are the fields returned in each device's response to the inquiry. It
  522. ** is returned in the results callback if registered.
  523. */
  524. typedef struct {
  525. UINT16 clock_offset;
  526. BD_ADDR remote_bd_addr;
  527. DEV_CLASS dev_class;
  528. UINT8 page_scan_rep_mode;
  529. UINT8 page_scan_per_mode;
  530. UINT8 page_scan_mode;
  531. INT8 rssi; /* Set to BTM_INQ_RES_IGNORE_RSSI if not valid */
  532. UINT32 eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
  533. BOOLEAN eir_complete_list;
  534. #if (BLE_INCLUDED == TRUE)
  535. tBT_DEVICE_TYPE device_type;
  536. UINT8 inq_result_type;
  537. UINT8 ble_addr_type;
  538. tBTM_BLE_EVT_TYPE ble_evt_type;
  539. UINT8 flag;
  540. UINT8 adv_data_len;
  541. UINT8 scan_rsp_len;
  542. #endif
  543. } tBTM_INQ_RESULTS;
  544. /* This is the inquiry response information held in its database by BTM, and available
  545. ** to applications via BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext.
  546. */
  547. typedef struct {
  548. tBTM_INQ_RESULTS results;
  549. BOOLEAN appl_knows_rem_name; /* set by application if it knows the remote name of the peer device.
  550. This is later used by application to determine if remote name request is
  551. required to be done. Having the flag here avoid duplicate store of inquiry results */
  552. #if ( BLE_INCLUDED == TRUE)
  553. UINT16 remote_name_len;
  554. tBTM_BD_NAME remote_name;
  555. UINT8 remote_name_state;
  556. UINT8 remote_name_type;
  557. #endif
  558. } tBTM_INQ_INFO;
  559. /* Structure returned with inquiry complete callback */
  560. typedef struct {
  561. tBTM_STATUS status;
  562. UINT8 num_resp; /* Number of results from the current inquiry */
  563. } tBTM_INQUIRY_CMPL;
  564. /* Structure returned with remote name request */
  565. typedef struct {
  566. UINT16 status;
  567. BD_ADDR bd_addr;
  568. UINT16 length;
  569. BD_NAME remote_bd_name;
  570. } tBTM_REMOTE_DEV_NAME;
  571. typedef struct {
  572. UINT8 pcm_intf_rate; /* PCM interface rate: 0: 128kbps, 1: 256 kbps;
  573. 2:512 bps; 3: 1024kbps; 4: 2048kbps */
  574. UINT8 frame_type; /* frame type: 0: short; 1: long */
  575. UINT8 sync_mode; /* sync mode: 0: slave; 1: master */
  576. UINT8 clock_mode; /* clock mode: 0: slave; 1: master */
  577. } tBTM_SCO_PCM_PARAM;
  578. /****************************************
  579. ** Device Discovery Callback Functions
  580. *****************************************/
  581. /* Callback function for asynchronous notifications when the BTM inquiry DB
  582. ** changes. First param is inquiry database, second is if added to or removed
  583. ** from the inquiry database.
  584. */
  585. typedef void (tBTM_INQ_DB_CHANGE_CB) (void *p1, BOOLEAN is_new);
  586. /* Callback function for notifications when the BTM gets inquiry response.
  587. ** First param is inquiry results database, second is pointer of EIR.
  588. */
  589. typedef void (tBTM_INQ_RESULTS_CB) (tBTM_INQ_RESULTS *p_inq_results, UINT8 *p_eir);
  590. /*****************************************************************************
  591. ** ACL CHANNEL MANAGEMENT
  592. *****************************************************************************/
  593. /******************
  594. ** ACL Constants
  595. *******************/
  596. /* ACL modes */
  597. #define BTM_ACL_MODE_NORMAL HCI_MODE_ACTIVE
  598. #define BTM_ACL_MODE_HOLD HCI_MODE_HOLD
  599. #define BTM_ACL_MODE_SNIFF HCI_MODE_SNIFF
  600. #define BTM_ACL_MODE_PARK HCI_MODE_PARK
  601. /* Returned with structure in role switch callback (tBTM_ROLE_SWITCH_CMPL) */
  602. #define BTM_ROLE_MASTER HCI_ROLE_MASTER
  603. #define BTM_ROLE_SLAVE HCI_ROLE_SLAVE
  604. #define BTM_ROLE_UNDEFINED 0xff /* undefined value (error status) */
  605. /* ACL Packet Types */
  606. #define BTM_ACL_PKT_TYPES_MASK_DM1 HCI_PKT_TYPES_MASK_DM1
  607. #define BTM_ACL_PKT_TYPES_MASK_DH1 HCI_PKT_TYPES_MASK_DH1
  608. #define BTM_ACL_PKT_TYPES_MASK_DM3 HCI_PKT_TYPES_MASK_DM3
  609. #define BTM_ACL_PKT_TYPES_MASK_DH3 HCI_PKT_TYPES_MASK_DH3
  610. #define BTM_ACL_PKT_TYPES_MASK_DM5 HCI_PKT_TYPES_MASK_DM5
  611. #define BTM_ACL_PKT_TYPES_MASK_DH5 HCI_PKT_TYPES_MASK_DH5
  612. #define BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 HCI_PKT_TYPES_MASK_NO_2_DH1
  613. #define BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 HCI_PKT_TYPES_MASK_NO_3_DH1
  614. #define BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 HCI_PKT_TYPES_MASK_NO_2_DH3
  615. #define BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 HCI_PKT_TYPES_MASK_NO_3_DH3
  616. #define BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 HCI_PKT_TYPES_MASK_NO_2_DH5
  617. #define BTM_ACL_PKT_TYPES_MASK_NO_3_DH5 HCI_PKT_TYPES_MASK_NO_3_DH5
  618. /***************
  619. ** ACL Types
  620. ****************/
  621. /* Structure returned with Role Switch information (in tBTM_CMPL_CB callback function)
  622. ** in response to BTM_SwitchRole call.
  623. */
  624. typedef struct {
  625. UINT8 hci_status; /* HCI status returned with the event */
  626. UINT8 role; /* BTM_ROLE_MASTER or BTM_ROLE_SLAVE */
  627. BD_ADDR remote_bd_addr; /* Remote BD addr involved with the switch */
  628. } tBTM_ROLE_SWITCH_CMPL;
  629. /* Structure returned with QoS information (in tBTM_CMPL_CB callback function)
  630. ** in response to BTM_SetQoS call.
  631. */
  632. typedef struct {
  633. FLOW_SPEC flow;
  634. UINT16 handle;
  635. UINT8 status;
  636. } tBTM_QOS_SETUP_CMPL;
  637. /* Structure returned with read RSSI event (in tBTM_CMPL_CB callback function)
  638. ** in response to BTM_ReadRSSI call.
  639. */
  640. typedef struct {
  641. tBTM_STATUS status;
  642. UINT8 hci_status;
  643. INT8 rssi;
  644. BD_ADDR rem_bda;
  645. } tBTM_RSSI_RESULTS;
  646. /* Structure returned with read current TX power event (in tBTM_CMPL_CB callback function)
  647. ** in response to BTM_ReadTxPower call.
  648. */
  649. typedef struct {
  650. tBTM_STATUS status;
  651. UINT8 hci_status;
  652. INT8 tx_power;
  653. BD_ADDR rem_bda;
  654. } tBTM_TX_POWER_RESULTS;
  655. /* Structure returned with read link quality event (in tBTM_CMPL_CB callback function)
  656. ** in response to BTM_ReadLinkQuality call.
  657. */
  658. typedef struct {
  659. tBTM_STATUS status;
  660. UINT8 hci_status;
  661. UINT8 link_quality;
  662. BD_ADDR rem_bda;
  663. } tBTM_LINK_QUALITY_RESULTS;
  664. /* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function)
  665. ** in response to BTM_ReadInquiryRspTxPower call.
  666. */
  667. typedef struct {
  668. tBTM_STATUS status;
  669. UINT8 hci_status;
  670. INT8 tx_power;
  671. } tBTM_INQ_TXPWR_RESULTS;
  672. enum {
  673. BTM_BL_CONN_EVT,
  674. BTM_BL_DISCN_EVT,
  675. BTM_BL_UPDATE_EVT,
  676. BTM_BL_ROLE_CHG_EVT,
  677. BTM_BL_COLLISION_EVT
  678. };
  679. typedef UINT8 tBTM_BL_EVENT;
  680. typedef UINT16 tBTM_BL_EVENT_MASK;
  681. #define BTM_BL_CONN_MASK 0x0001
  682. #define BTM_BL_DISCN_MASK 0x0002
  683. #define BTM_BL_UPDATE_MASK 0x0004
  684. #define BTM_BL_ROLE_CHG_MASK 0x0008
  685. /* Device features mask definitions */
  686. #define BTM_FEATURE_BYTES_PER_PAGE HCI_FEATURE_BYTES_PER_PAGE
  687. #define BTM_EXT_FEATURES_PAGE_MAX HCI_EXT_FEATURES_PAGE_MAX
  688. /* the data type associated with BTM_BL_CONN_EVT */
  689. typedef struct {
  690. tBTM_BL_EVENT event; /* The event reported. */
  691. BD_ADDR_PTR p_bda; /* The address of the newly connected device */
  692. DEV_CLASS_PTR p_dc; /* The device class */
  693. BD_NAME_PTR p_bdn; /* The device name */
  694. UINT8 *p_features; /* pointer to the remote device's features page[0] (supported features page) */
  695. #if BLE_INCLUDED == TRUE
  696. UINT16 handle; /* connection handle */
  697. tBT_TRANSPORT transport; /* link is LE or not */
  698. #endif
  699. } tBTM_BL_CONN_DATA;
  700. /* the data type associated with BTM_BL_DISCN_EVT */
  701. typedef struct {
  702. tBTM_BL_EVENT event; /* The event reported. */
  703. BD_ADDR_PTR p_bda; /* The address of the disconnected device */
  704. #if BLE_INCLUDED == TRUE
  705. UINT16 handle; /* disconnected connection handle */
  706. tBT_TRANSPORT transport; /* link is LE link or not */
  707. #endif
  708. } tBTM_BL_DISCN_DATA;
  709. /* Busy-Level shall have the inquiry_paging mask set when
  710. * inquiry/paging is in progress, Else the number of ACL links */
  711. #define BTM_BL_INQUIRY_PAGING_MASK 0x10
  712. #define BTM_BL_INQUIRY_STARTED (BTM_BL_INQUIRY_PAGING_MASK | 0x1)
  713. #define BTM_BL_INQUIRY_CANCELLED (BTM_BL_INQUIRY_PAGING_MASK | 0x2)
  714. #define BTM_BL_INQUIRY_COMPLETE (BTM_BL_INQUIRY_PAGING_MASK | 0x3)
  715. #define BTM_BL_PAGING_STARTED (BTM_BL_INQUIRY_PAGING_MASK | 0x4)
  716. #define BTM_BL_PAGING_COMPLETE (BTM_BL_INQUIRY_PAGING_MASK | 0x5)
  717. /* the data type associated with BTM_BL_UPDATE_EVT */
  718. typedef struct {
  719. tBTM_BL_EVENT event; /* The event reported. */
  720. UINT8 busy_level;/* when paging or inquiring, level is 10.
  721. * Otherwise, the number of ACL links. */
  722. UINT8 busy_level_flags; /* Notifies actual inquiry/page activities */
  723. } tBTM_BL_UPDATE_DATA;
  724. /* the data type associated with BTM_BL_ROLE_CHG_EVT */
  725. typedef struct {
  726. tBTM_BL_EVENT event; /* The event reported. */
  727. BD_ADDR_PTR p_bda; /* The address of the peer connected device */
  728. UINT8 new_role;
  729. UINT8 hci_status; /* HCI status returned with the event */
  730. } tBTM_BL_ROLE_CHG_DATA;
  731. typedef union {
  732. tBTM_BL_EVENT event; /* The event reported. */
  733. tBTM_BL_CONN_DATA conn; /* The data associated with BTM_BL_CONN_EVT */
  734. tBTM_BL_DISCN_DATA discn; /* The data associated with BTM_BL_DISCN_EVT */
  735. tBTM_BL_UPDATE_DATA update; /* The data associated with BTM_BL_UPDATE_EVT */
  736. tBTM_BL_ROLE_CHG_DATA role_chg;/*The data associated with BTM_BL_ROLE_CHG_EVT */
  737. } tBTM_BL_EVENT_DATA;
  738. /* Callback function for notifications when the BTM busy level
  739. ** changes.
  740. */
  741. typedef void (tBTM_BL_CHANGE_CB) (tBTM_BL_EVENT_DATA *p_data);
  742. /***************************
  743. ** ACL Callback Functions
  744. ****************************/
  745. /* Callback function for notifications when the BTM ACL connection DB
  746. ** changes. First param is BD address, second is if added or removed.
  747. ** Registered through BTM_AclRegisterForChanges call.
  748. */
  749. #if BLE_INCLUDED == TRUE
  750. typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
  751. BD_NAME p_bdn, UINT8 *features,
  752. BOOLEAN is_new, UINT16 handle,
  753. tBT_TRANSPORT transport);
  754. #else
  755. typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
  756. BD_NAME p_bdn, UINT8 *features,
  757. BOOLEAN is_new);
  758. #endif
  759. /*****************************************************************************
  760. ** SCO CHANNEL MANAGEMENT
  761. *****************************************************************************/
  762. /******************
  763. ** SCO Constants
  764. *******************/
  765. /* Define an invalid SCO index and an invalid HCI handle */
  766. #define BTM_INVALID_SCO_INDEX 0xFFFF
  767. #define BTM_INVALID_HCI_HANDLE 0xFFFF
  768. /* Define an invalid SCO disconnect reason */
  769. #define BTM_INVALID_SCO_DISC_REASON 0xFFFF
  770. /* Define first active SCO index */
  771. #define BTM_FIRST_ACTIVE_SCO_INDEX BTM_MAX_SCO_LINKS
  772. /* Define SCO packet types used in APIs */
  773. #define BTM_SCO_PKT_TYPES_MASK_HV1 HCI_ESCO_PKT_TYPES_MASK_HV1
  774. #define BTM_SCO_PKT_TYPES_MASK_HV2 HCI_ESCO_PKT_TYPES_MASK_HV2
  775. #define BTM_SCO_PKT_TYPES_MASK_HV3 HCI_ESCO_PKT_TYPES_MASK_HV3
  776. #define BTM_SCO_PKT_TYPES_MASK_EV3 HCI_ESCO_PKT_TYPES_MASK_EV3
  777. #define BTM_SCO_PKT_TYPES_MASK_EV4 HCI_ESCO_PKT_TYPES_MASK_EV4
  778. #define BTM_SCO_PKT_TYPES_MASK_EV5 HCI_ESCO_PKT_TYPES_MASK_EV5
  779. #define BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 HCI_ESCO_PKT_TYPES_MASK_NO_2_EV3
  780. #define BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 HCI_ESCO_PKT_TYPES_MASK_NO_3_EV3
  781. #define BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 HCI_ESCO_PKT_TYPES_MASK_NO_2_EV5
  782. #define BTM_SCO_PKT_TYPES_MASK_NO_3_EV5 HCI_ESCO_PKT_TYPES_MASK_NO_3_EV5
  783. #define BTM_SCO_LINK_ONLY_MASK (BTM_SCO_PKT_TYPES_MASK_HV1 | \
  784. BTM_SCO_PKT_TYPES_MASK_HV2 | \
  785. BTM_SCO_PKT_TYPES_MASK_HV3)
  786. #define BTM_ESCO_LINK_ONLY_MASK (BTM_SCO_PKT_TYPES_MASK_EV3 | \
  787. BTM_SCO_PKT_TYPES_MASK_EV4 | \
  788. BTM_SCO_PKT_TYPES_MASK_EV5)
  789. #define BTM_SCO_LINK_ALL_PKT_MASK (BTM_SCO_LINK_ONLY_MASK | \
  790. BTM_ESCO_LINK_ONLY_MASK)
  791. #define BTM_VALID_SCO_ALL_PKT_TYPE HCI_VALID_SCO_ALL_PKT_TYPE
  792. /* Passed in BTM_CreateSco if the packet type parameter should be ignored */
  793. #define BTM_IGNORE_SCO_PKT_TYPE 0
  794. /***************
  795. ** SCO Types
  796. ****************/
  797. #define BTM_LINK_TYPE_SCO HCI_LINK_TYPE_SCO
  798. #define BTM_LINK_TYPE_ESCO HCI_LINK_TYPE_ESCO
  799. typedef UINT8 tBTM_SCO_TYPE;
  800. /*******************
  801. ** SCO Routing Path
  802. ********************/
  803. #define BTM_SCO_ROUTE_PCM HCI_BRCM_SCO_ROUTE_PCM
  804. #define BTM_SCO_ROUTE_HCI HCI_BRCM_SCO_ROUTE_HCI
  805. typedef UINT8 tBTM_SCO_ROUTE_TYPE;
  806. /*******************
  807. ** SCO Codec Types
  808. ********************/
  809. // TODO(google) This should use common definitions
  810. // in hci/include/hci_audio.h
  811. #define BTM_SCO_CODEC_NONE 0x0000
  812. #define BTM_SCO_CODEC_CVSD 0x0001
  813. #define BTM_SCO_CODEC_MSBC 0x0002
  814. typedef UINT16 tBTM_SCO_CODEC_TYPE;
  815. /*******************
  816. ** SCO Air Mode Types
  817. ********************/
  818. #define BTM_SCO_AIR_MODE_U_LAW 0
  819. #define BTM_SCO_AIR_MODE_A_LAW 1
  820. #define BTM_SCO_AIR_MODE_CVSD 2
  821. #define BTM_SCO_AIR_MODE_TRANSPNT 3
  822. typedef UINT8 tBTM_SCO_AIR_MODE_TYPE;
  823. /*******************
  824. ** SCO Voice Settings
  825. ********************/
  826. #define BTM_VOICE_SETTING_CVSD ((UINT16) (HCI_INP_CODING_LINEAR | \
  827. HCI_INP_DATA_FMT_2S_COMPLEMENT | \
  828. HCI_INP_SAMPLE_SIZE_16BIT | \
  829. HCI_AIR_CODING_FORMAT_CVSD))
  830. #define BTM_VOICE_SETTING_TRANS ((UINT16) (HCI_INP_CODING_LINEAR | \
  831. HCI_INP_DATA_FMT_2S_COMPLEMENT | \
  832. HCI_INP_SAMPLE_SIZE_16BIT | \
  833. HCI_AIR_CODING_FORMAT_TRANSPNT))
  834. /*******************
  835. ** SCO Data Status
  836. ********************/
  837. enum {
  838. BTM_SCO_DATA_CORRECT,
  839. BTM_SCO_DATA_PAR_ERR,
  840. BTM_SCO_DATA_NONE,
  841. BTM_SCO_DATA_PAR_LOST
  842. };
  843. typedef UINT8 tBTM_SCO_DATA_FLAG;
  844. /***************************
  845. ** SCO Callback Functions
  846. ****************************/
  847. typedef void (tBTM_SCO_CB) (UINT16 sco_inx);
  848. typedef void (tBTM_SCO_DATA_CB) (UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_FLAG status);
  849. /******************
  850. ** eSCO Constants
  851. *******************/
  852. #define BTM_64KBITS_RATE 0x00001f40 /* 64 kbits/sec data rate */
  853. /* Retransmission effort */
  854. #define BTM_ESCO_RETRANS_OFF 0
  855. #define BTM_ESCO_RETRANS_POWER 1
  856. #define BTM_ESCO_RETRANS_QUALITY 2
  857. #define BTM_ESCO_RETRANS_DONTCARE 0xff
  858. /* Max Latency Don't Care */
  859. #define BTM_ESCO_MAX_LAT_DONTCARE 0xffff
  860. /***************
  861. ** eSCO Types
  862. ****************/
  863. /* tBTM_ESCO_CBACK event types */
  864. #define BTM_ESCO_CHG_EVT 1
  865. #define BTM_ESCO_CONN_REQ_EVT 2
  866. typedef UINT8 tBTM_ESCO_EVT;
  867. /* Passed into BTM_SetEScoMode() */
  868. typedef struct {
  869. UINT32 tx_bw;
  870. UINT32 rx_bw;
  871. UINT16 max_latency;
  872. UINT16 voice_contfmt; /* Voice Settings or Content Format */
  873. UINT16 packet_types;
  874. UINT8 retrans_effort;
  875. } tBTM_ESCO_PARAMS;
  876. typedef struct {
  877. UINT16 max_latency;
  878. UINT16 packet_types;
  879. UINT8 retrans_effort;
  880. } tBTM_CHG_ESCO_PARAMS;
  881. /* Returned by BTM_ReadEScoLinkParms() */
  882. typedef struct {
  883. UINT16 rx_pkt_len;
  884. UINT16 tx_pkt_len;
  885. BD_ADDR bd_addr;
  886. UINT8 link_type; /* BTM_LINK_TYPE_SCO or BTM_LINK_TYPE_ESCO */
  887. UINT8 tx_interval;
  888. UINT8 retrans_window;
  889. UINT8 air_mode;
  890. } tBTM_ESCO_DATA;
  891. typedef struct {
  892. UINT16 sco_inx;
  893. UINT16 rx_pkt_len;
  894. UINT16 tx_pkt_len;
  895. BD_ADDR bd_addr;
  896. UINT8 hci_status;
  897. UINT8 tx_interval;
  898. UINT8 retrans_window;
  899. } tBTM_CHG_ESCO_EVT_DATA;
  900. typedef struct {
  901. UINT16 sco_inx;
  902. BD_ADDR bd_addr;
  903. DEV_CLASS dev_class;
  904. tBTM_SCO_TYPE link_type;
  905. } tBTM_ESCO_CONN_REQ_EVT_DATA;
  906. typedef union {
  907. tBTM_CHG_ESCO_EVT_DATA chg_evt;
  908. tBTM_ESCO_CONN_REQ_EVT_DATA conn_evt;
  909. } tBTM_ESCO_EVT_DATA;
  910. /***************************
  911. ** eSCO Callback Functions
  912. ****************************/
  913. typedef void (tBTM_ESCO_CBACK) (tBTM_ESCO_EVT event, tBTM_ESCO_EVT_DATA *p_data);
  914. /*****************************************************************************
  915. ** SECURITY MANAGEMENT
  916. *****************************************************************************/
  917. /*******************************
  918. ** Security Manager Constants
  919. ********************************/
  920. /* Security Mode (BTM_SetSecurityMode) */
  921. #define BTM_SEC_MODE_UNDEFINED 0
  922. #define BTM_SEC_MODE_NONE 1
  923. #define BTM_SEC_MODE_SERVICE 2
  924. #define BTM_SEC_MODE_LINK 3
  925. #define BTM_SEC_MODE_SP 4
  926. #define BTM_SEC_MODE_SP_DEBUG 5
  927. #define BTM_SEC_MODE_SC 6
  928. /* Maximum Number of BTM Security Modes */
  929. #define BTM_SEC_MODES_MAX 7
  930. /* Security Service Levels [bit mask] (BTM_SetSecurityLevel)
  931. ** Encryption should not be used without authentication
  932. */
  933. #define BTM_SEC_NONE 0x0000 /* Nothing required */
  934. #define BTM_SEC_IN_AUTHORIZE 0x0001 /* Inbound call requires authorization */
  935. #define BTM_SEC_IN_AUTHENTICATE 0x0002 /* Inbound call requires authentication */
  936. #define BTM_SEC_IN_ENCRYPT 0x0004 /* Inbound call requires encryption */
  937. #define BTM_SEC_OUT_AUTHORIZE 0x0008 /* Outbound call requires authorization */
  938. #define BTM_SEC_OUT_AUTHENTICATE 0x0010 /* Outbound call requires authentication */
  939. #define BTM_SEC_OUT_ENCRYPT 0x0020 /* Outbound call requires encryption */
  940. #define BTM_SEC_MODE4_LEVEL4 0x0040 /* Secure Connections Only Mode */
  941. #define BTM_SEC_FORCE_MASTER 0x0100 /* Need to switch connection to be master */
  942. #define BTM_SEC_ATTEMPT_MASTER 0x0200 /* Try to switch connection to be master */
  943. #define BTM_SEC_FORCE_SLAVE 0x0400 /* Need to switch connection to be master */
  944. #define BTM_SEC_ATTEMPT_SLAVE 0x0800 /* Try to switch connection to be slave */
  945. #define BTM_SEC_IN_MITM 0x1000 /* inbound Do man in the middle protection */
  946. #define BTM_SEC_OUT_MITM 0x2000 /* outbound Do man in the middle protection */
  947. #define BTM_SEC_IN_MIN_16_DIGIT_PIN 0x4000 /* enforce a minimum of 16 digit for sec mode 2 */
  948. /* Security Flags [bit mask] (BTM_GetSecurityFlags)
  949. */
  950. #define BTM_SEC_FLAG_AUTHORIZED 0x01
  951. #define BTM_SEC_FLAG_AUTHENTICATED 0x02
  952. #define BTM_SEC_FLAG_ENCRYPTED 0x04
  953. #define BTM_SEC_FLAG_LKEY_KNOWN 0x10
  954. #define BTM_SEC_FLAG_LKEY_AUTHED 0x20
  955. /* PIN types */
  956. #define BTM_PIN_TYPE_VARIABLE HCI_PIN_TYPE_VARIABLE
  957. #define BTM_PIN_TYPE_FIXED HCI_PIN_TYPE_FIXED
  958. /* Link Key types used to generate the new link key.
  959. ** returned in link key notification callback function
  960. */
  961. #define BTM_LKEY_TYPE_COMBINATION HCI_LKEY_TYPE_COMBINATION
  962. #define BTM_LKEY_TYPE_LOCAL_UNIT HCI_LKEY_TYPE_LOCAL_UNIT
  963. #define BTM_LKEY_TYPE_REMOTE_UNIT HCI_LKEY_TYPE_REMOTE_UNIT
  964. #define BTM_LKEY_TYPE_DEBUG_COMB HCI_LKEY_TYPE_DEBUG_COMB
  965. #define BTM_LKEY_TYPE_UNAUTH_COMB HCI_LKEY_TYPE_UNAUTH_COMB
  966. #define BTM_LKEY_TYPE_AUTH_COMB HCI_LKEY_TYPE_AUTH_COMB
  967. #define BTM_LKEY_TYPE_CHANGED_COMB HCI_LKEY_TYPE_CHANGED_COMB
  968. #define BTM_LKEY_TYPE_UNAUTH_COMB_P_256 HCI_LKEY_TYPE_UNAUTH_COMB_P_256
  969. #define BTM_LKEY_TYPE_AUTH_COMB_P_256 HCI_LKEY_TYPE_AUTH_COMB_P_256
  970. #define BTM_LTK_DERIVED_LKEY_OFFSET 0x20 /* "easy" requirements for LK derived from LTK */
  971. #define BTM_LKEY_TYPE_IGNORE 0xff /* used when event is response from
  972. hci return link keys request */
  973. typedef UINT8 tBTM_LINK_KEY_TYPE;
  974. /* Protocol level security (BTM_SetSecurityLevel) */
  975. #define BTM_SEC_PROTO_L2CAP 0
  976. #define BTM_SEC_PROTO_SDP 1
  977. #define BTM_SEC_PROTO_TCS 2
  978. #define BTM_SEC_PROTO_RFCOMM 3
  979. #define BTM_SEC_PROTO_OBEX 4
  980. #define BTM_SEC_PROTO_BNEP 5
  981. #define BTM_SEC_PROTO_HID 6 /* HID */
  982. #define BTM_SEC_PROTO_AVDT 7
  983. #define BTM_SEC_PROTO_MCA 8
  984. /* Determine the number of UINT32's necessary for security services */
  985. #define BTM_SEC_ARRAY_BITS 32 /* Number of bits in each array element */
  986. #define BTM_SEC_SERVICE_ARRAY_SIZE (((UINT32)BTM_SEC_MAX_SERVICES / BTM_SEC_ARRAY_BITS) + \
  987. (((UINT32)BTM_SEC_MAX_SERVICES % BTM_SEC_ARRAY_BITS) ? 1 : 0))
  988. /* Security service definitions (BTM_SetSecurityLevel)
  989. ** Used for Authorization APIs
  990. */
  991. #define BTM_SEC_SERVICE_SDP_SERVER 0
  992. #define BTM_SEC_SERVICE_SERIAL_PORT 1
  993. #define BTM_SEC_SERVICE_LAN_ACCESS 2
  994. #define BTM_SEC_SERVICE_DUN 3
  995. #define BTM_SEC_SERVICE_IRMC_SYNC 4
  996. #define BTM_SEC_SERVICE_IRMC_SYNC_CMD 5
  997. #define BTM_SEC_SERVICE_OBEX 6
  998. #define BTM_SEC_SERVICE_OBEX_FTP 7
  999. #define BTM_SEC_SERVICE_HEADSET 8
  1000. #define BTM_SEC_SERVICE_CORDLESS 9
  1001. #define BTM_SEC_SERVICE_INTERCOM 10
  1002. #define BTM_SEC_SERVICE_FAX 11
  1003. #define BTM_SEC_SERVICE_HEADSET_AG 12
  1004. #define BTM_SEC_SERVICE_PNP_INFO 13
  1005. #define BTM_SEC_SERVICE_GEN_NET 14
  1006. #define BTM_SEC_SERVICE_GEN_FILE 15
  1007. #define BTM_SEC_SERVICE_GEN_AUDIO 16
  1008. #define BTM_SEC_SERVICE_GEN_TEL 17
  1009. #define BTM_SEC_SERVICE_CTP_DATA 18
  1010. #define BTM_SEC_SERVICE_HCRP_CTRL 19
  1011. #define BTM_SEC_SERVICE_HCRP_DATA 20
  1012. #define BTM_SEC_SERVICE_HCRP_NOTIF 21
  1013. #define BTM_SEC_SERVICE_BPP_JOB 22
  1014. #define BTM_SEC_SERVICE_BPP_STATUS 23
  1015. #define BTM_SEC_SERVICE_BPP_REF 24
  1016. #define BTM_SEC_SERVICE_BNEP_PANU 25
  1017. #define BTM_SEC_SERVICE_BNEP_GN 26
  1018. #define BTM_SEC_SERVICE_BNEP_NAP 27
  1019. #define BTM_SEC_SERVICE_HF_HANDSFREE 28
  1020. #define BTM_SEC_SERVICE_AG_HANDSFREE 29
  1021. #define BTM_SEC_SERVICE_TE_PHONE_ACCESS 30
  1022. #define BTM_SEC_SERVICE_ME_PHONE_ACCESS 31
  1023. #define BTM_SEC_SERVICE_HIDH_SEC_CTRL 32
  1024. #define BTM_SEC_SERVICE_HIDH_NOSEC_CTRL 33
  1025. #define BTM_SEC_SERVICE_HIDH_INTR 34
  1026. #define BTM_SEC_SERVICE_BIP 35
  1027. #define BTM_SEC_SERVICE_BIP_REF 36
  1028. #define BTM_SEC_SERVICE_AVDTP 37
  1029. #define BTM_SEC_SERVICE_AVDTP_NOSEC 38
  1030. #define BTM_SEC_SERVICE_AVCTP 39
  1031. #define BTM_SEC_SERVICE_SAP 40
  1032. #define BTM_SEC_SERVICE_PBAP 41
  1033. #define BTM_SEC_SERVICE_RFC_MUX 42
  1034. #define BTM_SEC_SERVICE_AVCTP_BROWSE 43
  1035. #define BTM_SEC_SERVICE_MAP 44
  1036. #define BTM_SEC_SERVICE_MAP_NOTIF 45
  1037. #define BTM_SEC_SERVICE_MCAP_CTRL 46
  1038. #define BTM_SEC_SERVICE_MCAP_DATA 47
  1039. #define BTM_SEC_SERVICE_HDP_SNK 48
  1040. #define BTM_SEC_SERVICE_HDP_SRC 49
  1041. #define BTM_SEC_SERVICE_ATT 50
  1042. /* Update these as services are added */
  1043. #define BTM_SEC_SERVICE_FIRST_EMPTY 51
  1044. #ifndef BTM_SEC_MAX_SERVICES
  1045. #define BTM_SEC_MAX_SERVICES 65
  1046. #endif
  1047. /************************************************************************************************
  1048. ** Security Services MACROS handle array of UINT32 bits for more than 32 trusted services
  1049. *************************************************************************************************/
  1050. /* MACRO to set the security service bit mask in a bit stream */
  1051. #define BTM_SEC_SET_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] |= \
  1052. ((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
  1053. /* MACRO to clear the security service bit mask in a bit stream */
  1054. #define BTM_SEC_CLR_SERVICE(p, service) (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] &= \
  1055. ~((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
  1056. /* MACRO to check the security service bit mask in a bit stream (Returns TRUE or FALSE) */
  1057. #define BTM_SEC_IS_SERVICE_TRUSTED(p, service) (((((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)]) & \
  1058. (UINT32)(((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))) ? TRUE : FALSE)
  1059. /* MACRO to copy two trusted device bitmask */
  1060. #define BTM_SEC_COPY_TRUSTED_DEVICE(p_src, p_dst) {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
  1061. ((UINT32 *)(p_dst))[trst] = ((UINT32 *)(p_src))[trst];}
  1062. /* MACRO to clear two trusted device bitmask */
  1063. #define BTM_SEC_CLR_TRUSTED_DEVICE(p_dst) {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
  1064. ((UINT32 *)(p_dst))[trst] = 0;}
  1065. /* Following bits can be provided by host in the trusted_mask array */
  1066. /* 0..31 bits of mask[0] (Least Significant Word) */
  1067. #define BTM_SEC_TRUST_SDP_SERVER (1 << BTM_SEC_SERVICE_SDP_SERVER)
  1068. #define BTM_SEC_TRUST_SERIAL_PORT (1 << BTM_SEC_SERVICE_SERIAL_PORT)
  1069. #define BTM_SEC_TRUST_LAN_ACCESS (1 << BTM_SEC_SERVICE_LAN_ACCESS)
  1070. #define BTM_SEC_TRUST_DUN (1 << BTM_SEC_SERVICE_DUN)
  1071. #define BTM_SEC_TRUST_IRMC_SYNC (1 << BTM_SEC_SERVICE_IRMC_SYNC)
  1072. #define BTM_SEC_TRUST_IRMC_SYNC_CMD (1 << BTM_SEC_SERVICE_IRMC_SYNC_CMD)
  1073. #define BTM_SEC_TRUST_OBEX (1 << BTM_SEC_SERVICE_OBEX)
  1074. #define BTM_SEC_TRUST_OBEX_FTP (1 << BTM_SEC_SERVICE_OBEX_FTP)
  1075. #define BTM_SEC_TRUST_HEADSET (1 << BTM_SEC_SERVICE_HEADSET)
  1076. #define BTM_SEC_TRUST_CORDLESS (1 << BTM_SEC_SERVICE_CORDLESS)
  1077. #define BTM_SEC_TRUST_INTERCOM (1 << BTM_SEC_SERVICE_INTERCOM)
  1078. #define BTM_SEC_TRUST_FAX (1 << BTM_SEC_SERVICE_FAX)
  1079. #define BTM_SEC_TRUST_HEADSET_AG (1 << BTM_SEC_SERVICE_HEADSET_AG)
  1080. #define BTM_SEC_TRUST_PNP_INFO (1 << BTM_SEC_SERVICE_PNP_INFO)
  1081. #define BTM_SEC_TRUST_GEN_NET (1 << BTM_SEC_SERVICE_GEN_NET)
  1082. #define BTM_SEC_TRUST_GEN_FILE (1 << BTM_SEC_SERVICE_GEN_FILE)
  1083. #define BTM_SEC_TRUST_GEN_AUDIO (1 << BTM_SEC_SERVICE_GEN_AUDIO)
  1084. #define BTM_SEC_TRUST_GEN_TEL (1 << BTM_SEC_SERVICE_GEN_TEL)
  1085. #define BTM_SEC_TRUST_CTP_DATA (1 << BTM_SEC_SERVICE_CTP_DATA)
  1086. #define BTM_SEC_TRUST_HCRP_CTRL (1 << BTM_SEC_SERVICE_HCRP_CTRL)
  1087. #define BTM_SEC_TRUST_HCRP_DATA (1 << BTM_SEC_SERVICE_HCRP_DATA)
  1088. #define BTM_SEC_TRUST_HCRP_NOTIF (1 << BTM_SEC_SERVICE_HCRP_NOTIF)
  1089. #define BTM_SEC_TRUST_BPP_JOB (1 << BTM_SEC_SERVICE_JOB)
  1090. #define BTM_SEC_TRUST_BPP_STATUS (1 << BTM_SEC_SERVICE_STATUS)
  1091. #define BTM_SEC_TRUST_BPP_REF (1 << BTM_SEC_SERVICE_REF)
  1092. #define BTM_SEC_TRUST_BNEP_PANU (1 << BTM_SEC_SERVICE_BNEP_PANU)
  1093. #define BTM_SEC_TRUST_BNEP_GN (1 << BTM_SEC_SERVICE_BNEP_GN)
  1094. #define BTM_SEC_TRUST_BNEP_NAP (1 << BTM_SEC_SERVICE_BNEP_NAP)
  1095. #define BTM_SEC_TRUST_HFP_HF (1 << BTM_SEC_SERVICE_HF_HANDSFREE)
  1096. #define BTM_SEC_TRUST_HFP_AG (1 << BTM_SEC_SERVICE_AG_HANDSFREE)
  1097. #define BTM_SEC_TRUST_TE_PHONE_ACCESS (1 << BTM_SEC_SERVICE_TE_PHONE_ACCESS)
  1098. #define BTM_SEC_TRUST_ME_PHONE_ACCESS (1 << BTM_SEC_SERVICE_ME_PHONE_ACCESS)
  1099. /* 0..31 bits of mask[1] (Most Significant Word) */
  1100. #define BTM_SEC_TRUST_HIDH_CTRL (1 << (BTM_SEC_SERVICE_HIDH_SEC_CTRL - 32))
  1101. #define BTM_SEC_TRUST_HIDH_NOSEC_CTRL (1 << (BTM_SEC_SERVICE_HIDH_NOSEC_CTRL - 32))
  1102. #define BTM_SEC_TRUST_HIDH_INTR (1 << (BTM_SEC_SERVICE_HIDH_INTR - 32))
  1103. #define BTM_SEC_TRUST_BIP (1 << (BTM_SEC_SERVICE_BIP - 32))
  1104. #define BTM_SEC_TRUST_BIP_REF (1 << (BTM_SEC_SERVICE_BIP_REF - 32))
  1105. #define BTM_SEC_TRUST_AVDTP (1 << (BTM_SEC_SERVICE_AVDTP - 32))
  1106. #define BTM_SEC_TRUST_AVDTP_NOSEC (1 << (BTM_SEC_SERVICE_AVDTP_NOSEC - 32))
  1107. #define BTM_SEC_TRUST_AVCTP (1 << (BTM_SEC_SERVICE_AVCTP - 32))
  1108. #define BTM_SEC_TRUST_SAP (1 << (BTM_SEC_SERVICE_SAP - 32))
  1109. #define BTM_SEC_TRUST_PBAP (1 << (BTM_SEC_SERVICE_PBAP - 32))
  1110. #define BTM_SEC_TRUST_RFC_MUX (1 << (BTM_SEC_SERVICE_RFC_MUX - 32))
  1111. #define BTM_SEC_TRUST_AVCTP_BROWSE (1 << (BTM_SEC_SERVICE_AVCTP_BROWSE - 32))
  1112. #define BTM_SEC_TRUST_MAP (1 << (BTM_SEC_SERVICE_MAP - 32))
  1113. #define BTM_SEC_TRUST_MAP_NOTIF (1 << (BTM_SEC_SERVICE_MAP_NOTIF - 32))
  1114. #define BTM_SEC_TRUST_MCAP_CTRL (1 << (BTM_SEC_SERVICE_MCAP_CTRL - 32))
  1115. #define BTM_SEC_TRUST_MCAP_DATA (1 << (BTM_SEC_SERVICE_MCAP_DATA - 32))
  1116. #define BTM_SEC_TRUST_HDP_SNK (1 << (BTM_SEC_SERVICE_HDP_SNK - 32))
  1117. #define BTM_SEC_TRUST_HDP_SRC (1 << (BTM_SEC_SERVICE_HDP_SRC - 32))
  1118. #define BTM_SEC_TRUST_ALL 0xFFFFFFFF /* for each array element */
  1119. /****************************************
  1120. ** Security Manager Callback Functions
  1121. *****************************************/
  1122. /* Authorize device for service. Parameters are
  1123. ** BD Address of remote
  1124. ** Device Class of remote
  1125. ** BD Name of remote
  1126. ** Service name
  1127. ** Service Id (NULL - unknown service or unused
  1128. ** [BTM_SEC_SERVICE_NAME_LEN set to 0])
  1129. ** Is originator of the connection
  1130. ** Result of the operation
  1131. */
  1132. typedef UINT8 (tBTM_AUTHORIZE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
  1133. tBTM_BD_NAME bd_name, UINT8 *service_name,
  1134. UINT8 service_id, BOOLEAN is_originator);
  1135. /* Get PIN for the connection. Parameters are
  1136. ** BD Address of remote
  1137. ** Device Class of remote
  1138. ** BD Name of remote
  1139. ** Flag indicating the minimum pin code length to be 16 digits
  1140. */
  1141. typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
  1142. tBTM_BD_NAME bd_name, BOOLEAN min_16_digit);
  1143. /* New Link Key for the connection. Parameters are
  1144. ** BD Address of remote
  1145. ** Link Key
  1146. ** Key Type: Combination, Local Unit, or Remote Unit
  1147. */
  1148. typedef UINT8 (tBTM_LINK_KEY_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
  1149. tBTM_BD_NAME bd_name, UINT8 *key,
  1150. UINT8 key_type);
  1151. /* Remote Name Resolved. Parameters are
  1152. ** BD Address of remote
  1153. ** BD Name of remote
  1154. */
  1155. typedef void (tBTM_RMT_NAME_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dc,
  1156. tBTM_BD_NAME bd_name);
  1157. /* Authentication complete for the connection. Parameters are
  1158. ** BD Address of remote
  1159. ** Device Class of remote
  1160. ** BD Name of remote
  1161. **
  1162. */
  1163. typedef UINT8 (tBTM_AUTH_COMPLETE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
  1164. tBTM_BD_NAME bd_name, int result);
  1165. enum {
  1166. BTM_SP_IO_REQ_EVT, /* received IO_CAPABILITY_REQUEST event */
  1167. BTM_SP_IO_RSP_EVT, /* received IO_CAPABILITY_RESPONSE event */
  1168. BTM_SP_CFM_REQ_EVT, /* received USER_CONFIRMATION_REQUEST event */
  1169. BTM_SP_KEY_NOTIF_EVT, /* received USER_PASSKEY_NOTIFY event */
  1170. BTM_SP_KEY_REQ_EVT, /* received USER_PASSKEY_REQUEST event */
  1171. BTM_SP_KEYPRESS_EVT, /* received KEYPRESS_NOTIFY event */
  1172. BTM_SP_LOC_OOB_EVT, /* received result for READ_LOCAL_OOB_DATA command */
  1173. BTM_SP_RMT_OOB_EVT, /* received REMOTE_OOB_DATA_REQUEST event */
  1174. BTM_SP_COMPLT_EVT, /* received SIMPLE_PAIRING_COMPLETE event */
  1175. BTM_SP_UPGRADE_EVT /* check if the application wants to upgrade the link key */
  1176. };
  1177. typedef UINT8 tBTM_SP_EVT;
  1178. #define BTM_IO_CAP_OUT 0 /* DisplayOnly */
  1179. #define BTM_IO_CAP_IO 1 /* DisplayYesNo */
  1180. #define BTM_IO_CAP_IN 2 /* KeyboardOnly */
  1181. #define BTM_IO_CAP_NONE 3 /* NoInputNoOutput */
  1182. #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
  1183. #define BTM_IO_CAP_KBDISP 4 /* Keyboard display */
  1184. #define BTM_IO_CAP_MAX 5
  1185. #else
  1186. #define BTM_IO_CAP_MAX 4
  1187. #endif
  1188. typedef UINT8 tBTM_IO_CAP;
  1189. #define BTM_MAX_PASSKEY_VAL (999999)
  1190. #define BTM_MIN_PASSKEY_VAL (0)
  1191. #define BTM_AUTH_SP_NO 0 /* MITM Protection Not Required - Single Profile/non-bonding
  1192. Numeric comparison with automatic accept allowed */
  1193. #define BTM_AUTH_SP_YES 1 /* MITM Protection Required - Single Profile/non-bonding
  1194. Use IO Capabilities to determine authentication procedure */
  1195. #define BTM_AUTH_AP_NO 2 /* MITM Protection Not Required - All Profiles/dedicated bonding
  1196. Numeric comparison with automatic accept allowed */
  1197. #define BTM_AUTH_AP_YES 3 /* MITM Protection Required - All Profiles/dedicated bonding
  1198. Use IO Capabilities to determine authentication procedure */
  1199. #define BTM_AUTH_SPGB_NO 4 /* MITM Protection Not Required - Single Profiles/general bonding
  1200. Numeric comparison with automatic accept allowed */
  1201. #define BTM_AUTH_SPGB_YES 5 /* MITM Protection Required - Single Profiles/general bonding
  1202. Use IO Capabilities to determine authentication procedure */
  1203. #define BTM_AUTH_DD_BOND 2 /* this bit is ORed to the BTM_AUTH_SP_* when IO exchange for dedicated bonding */
  1204. #define BTM_AUTH_GB_BIT 4 /* the genernal bonding bit */
  1205. #define BTM_AUTH_BONDS 6 /* the general/dedicated bonding bits */
  1206. #define BTM_AUTH_YN_BIT 1 /* this is the Yes or No bit */
  1207. #define BTM_BLE_ENC_KEY_MASK (1 << 0)
  1208. #define BTM_BLE_ID_KEY_MASK (1 << 1)
  1209. #define BTM_BLE_CSR_KEY_MASK (1 << 2)
  1210. #define BTM_BLE_LINK_KEY_MASK (1 << 3)
  1211. #define BTM_BLE_INITIATOR_KEY_SIZE 15
  1212. #define BTM_BLE_RESPONDER_KEY_SIZE 15
  1213. #define BTM_BLE_MAX_KEY_SIZE 16
  1214. typedef UINT8 tBTM_AUTH_REQ;
  1215. enum {
  1216. BTM_OOB_NONE,
  1217. BTM_OOB_PRESENT
  1218. #if BTM_OOB_INCLUDED == TRUE
  1219. , BTM_OOB_UNKNOWN
  1220. #endif
  1221. };
  1222. typedef UINT8 tBTM_OOB_DATA;
  1223. /* data type for BTM_SP_IO_REQ_EVT */
  1224. typedef struct {
  1225. BD_ADDR bd_addr; /* peer address */
  1226. tBTM_IO_CAP io_cap; /* local IO capabilities */
  1227. tBTM_OOB_DATA oob_data; /* OOB data present (locally) for the peer device */
  1228. tBTM_AUTH_REQ auth_req; /* Authentication required (for local device) */
  1229. BOOLEAN is_orig; /* TRUE, if local device initiated the SP process */
  1230. } tBTM_SP_IO_REQ;
  1231. /* data type for BTM_SP_IO_RSP_EVT */
  1232. typedef struct {
  1233. BD_ADDR bd_addr; /* peer address */
  1234. tBTM_IO_CAP io_cap; /* peer IO capabilities */
  1235. tBTM_OOB_DATA oob_data; /* OOB data present at peer device for the local device */
  1236. tBTM_AUTH_REQ auth_req; /* Authentication required for peer device */
  1237. } tBTM_SP_IO_RSP;
  1238. /* data type for BTM_SP_CFM_REQ_EVT */
  1239. typedef struct {
  1240. BD_ADDR bd_addr; /* peer address */
  1241. DEV_CLASS dev_class; /* peer CoD */
  1242. tBTM_BD_NAME bd_name; /* peer device name */
  1243. UINT32 num_val; /* the numeric value for comparison. If just_works, do not show this number to UI */
  1244. BOOLEAN just_works; /* TRUE, if "Just Works" association model */
  1245. tBTM_AUTH_REQ loc_auth_req; /* Authentication required for local device */
  1246. tBTM_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */
  1247. tBTM_IO_CAP loc_io_caps; /* IO Capabilities of the local device */
  1248. tBTM_IO_CAP rmt_io_caps; /* IO Capabilities of the remot device */
  1249. } tBTM_SP_CFM_REQ;
  1250. /* data type for BTM_SP_KEY_REQ_EVT */
  1251. typedef struct {
  1252. BD_ADDR bd_addr; /* peer address */
  1253. DEV_CLASS dev_class; /* peer CoD */
  1254. tBTM_BD_NAME bd_name; /* peer device name */
  1255. } tBTM_SP_KEY_REQ;
  1256. /* data type for BTM_SP_KEY_NOTIF_EVT */
  1257. typedef struct {
  1258. BD_ADDR bd_addr; /* peer address */
  1259. DEV_CLASS dev_class; /* peer CoD */
  1260. tBTM_BD_NAME bd_name; /* peer device name */
  1261. UINT32 passkey; /* passkey */
  1262. } tBTM_SP_KEY_NOTIF;
  1263. enum {
  1264. BTM_SP_KEY_STARTED, /* 0 - passkey entry started */
  1265. BTM_SP_KEY_ENTERED, /* 1 - passkey digit entered */
  1266. BTM_SP_KEY_ERASED, /* 2 - passkey digit erased */
  1267. BTM_SP_KEY_CLEARED, /* 3 - passkey cleared */
  1268. BTM_SP_KEY_COMPLT, /* 4 - passkey entry completed */
  1269. BTM_SP_KEY_OUT_OF_RANGE /* 5 - out of range */
  1270. };
  1271. typedef UINT8 tBTM_SP_KEY_TYPE;
  1272. /* data type for BTM_SP_KEYPRESS_EVT */
  1273. typedef struct {
  1274. BD_ADDR bd_addr; /* peer address */
  1275. tBTM_SP_KEY_TYPE notif_type;
  1276. } tBTM_SP_KEYPRESS;
  1277. /* data type for BTM_SP_LOC_OOB_EVT */
  1278. typedef struct {
  1279. tBTM_STATUS status; /* */
  1280. BT_OCTET16 c; /* Simple Pairing Hash C */
  1281. BT_OCTET16 r; /* Simple Pairing Randomnizer R */
  1282. } tBTM_SP_LOC_OOB;
  1283. /* data type for BTM_SP_RMT_OOB_EVT */
  1284. typedef struct {
  1285. BD_ADDR bd_addr; /* peer address */
  1286. DEV_CLASS dev_class; /* peer CoD */
  1287. tBTM_BD_NAME bd_name; /* peer device name */
  1288. } tBTM_SP_RMT_OOB;
  1289. /* data type for BTM_SP_COMPLT_EVT */
  1290. typedef struct {
  1291. BD_ADDR bd_addr; /* peer address */
  1292. DEV_CLASS dev_class; /* peer CoD */
  1293. tBTM_BD_NAME bd_name; /* peer device name */
  1294. tBTM_STATUS status; /* status of the simple pairing process */
  1295. } tBTM_SP_COMPLT;
  1296. /* data type for BTM_SP_UPGRADE_EVT */
  1297. typedef struct {
  1298. BD_ADDR bd_addr; /* peer address */
  1299. BOOLEAN upgrade; /* TRUE, to upgrade the link key */
  1300. } tBTM_SP_UPGRADE;
  1301. typedef union {
  1302. tBTM_SP_IO_REQ io_req; /* BTM_SP_IO_REQ_EVT */
  1303. tBTM_SP_IO_RSP io_rsp; /* BTM_SP_IO_RSP_EVT */
  1304. tBTM_SP_CFM_REQ cfm_req; /* BTM_SP_CFM_REQ_EVT */
  1305. tBTM_SP_KEY_NOTIF key_notif; /* BTM_SP_KEY_NOTIF_EVT */
  1306. tBTM_SP_KEY_REQ key_req; /* BTM_SP_KEY_REQ_EVT */
  1307. tBTM_SP_KEYPRESS key_press; /* BTM_SP_KEYPRESS_EVT */
  1308. tBTM_SP_LOC_OOB loc_oob; /* BTM_SP_LOC_OOB_EVT */
  1309. tBTM_SP_RMT_OOB rmt_oob; /* BTM_SP_RMT_OOB_EVT */
  1310. tBTM_SP_COMPLT complt; /* BTM_SP_COMPLT_EVT */
  1311. tBTM_SP_UPGRADE upgrade; /* BTM_SP_UPGRADE_EVT */
  1312. } tBTM_SP_EVT_DATA;
  1313. /* Simple Pairing Events. Called by the stack when Simple Pairing related
  1314. ** events occur.
  1315. */
  1316. typedef UINT8 (tBTM_SP_CALLBACK) (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
  1317. typedef void (tBTM_MKEY_CALLBACK) (BD_ADDR bd_addr, UINT8 status, UINT8 key_flag) ;
  1318. /* Encryption enabled/disabled complete: Optionally passed with BTM_SetEncryption.
  1319. ** Parameters are
  1320. ** BD Address of remote
  1321. ** optional data passed in by BTM_SetEncryption
  1322. ** tBTM_STATUS - result of the operation
  1323. */
  1324. typedef void (tBTM_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
  1325. void *p_ref_data, tBTM_STATUS result);
  1326. /* Bond Cancel complete. Parameters are
  1327. ** Result of the cancel operation
  1328. **
  1329. */
  1330. typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result);
  1331. /* LE related event and data structure
  1332. */
  1333. #define BTM_LE_IO_REQ_EVT SMP_IO_CAP_REQ_EVT /* received IO_CAPABILITY_REQUEST event */
  1334. #define BTM_LE_SEC_REQUEST_EVT SMP_SEC_REQUEST_EVT /* security request event */
  1335. #define BTM_LE_KEY_NOTIF_EVT SMP_PASSKEY_NOTIF_EVT /* received USER_PASSKEY_NOTIFY event */
  1336. #define BTM_LE_KEY_REQ_EVT SMP_PASSKEY_REQ_EVT /* received USER_PASSKEY_REQUEST event */
  1337. #define BTM_LE_OOB_REQ_EVT SMP_OOB_REQ_EVT /* OOB data request event */
  1338. #define BTM_LE_NC_REQ_EVT SMP_NC_REQ_EVT /* Numeric Comparison request event */
  1339. #define BTM_LE_PR_KEYPR_NOT_EVT SMP_PEER_KEYPR_NOT_EVT /* Peer keypress notification recd event */
  1340. /* SC OOB request event (both local and peer OOB data) can be expected in response */
  1341. #define BTM_LE_SC_OOB_REQ_EVT SMP_SC_OOB_REQ_EVT
  1342. /* SC OOB local data set is created (as result of SMP_CrLocScOobData(...)) */
  1343. #define BTM_LE_SC_LOC_OOB_EVT SMP_SC_LOC_OOB_DATA_UP_EVT
  1344. #define BTM_LE_BR_KEYS_REQ_EVT SMP_BR_KEYS_REQ_EVT /* SMP over BR keys request event */
  1345. #define BTM_LE_COMPLT_EVT SMP_COMPLT_EVT /* SMP complete event */
  1346. #define BTM_LE_LAST_FROM_SMP BTM_LE_BR_KEYS_REQ_EVT
  1347. #define BTM_LE_KEY_EVT BTM_LE_LAST_FROM_SMP + 1 /* KEY update event */
  1348. typedef UINT8 tBTM_LE_EVT;
  1349. #define BTM_LE_KEY_NONE 0
  1350. #define BTM_LE_KEY_PENC SMP_SEC_KEY_TYPE_ENC /* encryption information of peer device */
  1351. #define BTM_LE_KEY_PID SMP_SEC_KEY_TYPE_ID /* identity key of the peer device */
  1352. #define BTM_LE_KEY_PCSRK SMP_SEC_KEY_TYPE_CSRK /* peer SRK */
  1353. #define BTM_LE_KEY_PLK SMP_SEC_KEY_TYPE_LK
  1354. #define BTM_LE_KEY_LLK (SMP_SEC_KEY_TYPE_LK << 4)
  1355. #define BTM_LE_KEY_LENC (SMP_SEC_KEY_TYPE_ENC << 4) /* master role security information:div */
  1356. #define BTM_LE_KEY_LID (SMP_SEC_KEY_TYPE_ID << 4) /* master device ID key */
  1357. #define BTM_LE_KEY_LCSRK (SMP_SEC_KEY_TYPE_CSRK << 4) /* local CSRK has been deliver to peer */
  1358. typedef UINT8 tBTM_LE_KEY_TYPE;
  1359. #define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND /* 0 */
  1360. #define BTM_LE_AUTH_REQ_BOND SMP_AUTH_GEN_BOND /* 1 << 0 */
  1361. #define BTM_LE_AUTH_REQ_MITM SMP_AUTH_YN_BIT /* 1 << 2 */
  1362. typedef UINT8 tBTM_LE_AUTH_REQ;
  1363. #define BTM_LE_SC_SUPPORT_BIT SMP_SC_SUPPORT_BIT /* (1 << 3) */
  1364. #define BTM_LE_KP_SUPPORT_BIT SMP_KP_SUPPORT_BIT /* (1 << 4) */
  1365. #define BTM_LE_AUTH_REQ_SC_ONLY SMP_AUTH_SC_ENC_ONLY /* 1 << 3 */
  1366. #define BTM_LE_AUTH_REQ_SC_BOND SMP_AUTH_SC_GB /* 1001 */
  1367. #define BTM_LE_AUTH_REQ_SC_MITM SMP_AUTH_SC_MITM_NB /* 1100 */
  1368. #define BTM_LE_AUTH_REQ_SC_MITM_BOND SMP_AUTH_SC_MITM_GB /* 1101 */
  1369. #define BTM_LE_AUTH_REQ_MASK SMP_AUTH_MASK /* 0x1D */
  1370. /* LE security level */
  1371. #define BTM_LE_SEC_NONE SMP_SEC_NONE
  1372. #define BTM_LE_SEC_UNAUTHENTICATE SMP_SEC_UNAUTHENTICATE /* 1 */
  1373. #define BTM_LE_SEC_AUTHENTICATED SMP_SEC_AUTHENTICATED /* 4 */
  1374. typedef UINT8 tBTM_LE_SEC;
  1375. typedef struct {
  1376. tBTM_IO_CAP io_cap; /* local IO capabilities */
  1377. UINT8 oob_data; /* OOB data present (locally) for the peer device */
  1378. tBTM_LE_AUTH_REQ auth_req; /* Authentication request (for local device) contain bonding and MITM info */
  1379. UINT8 max_key_size; /* max encryption key size */
  1380. tBTM_LE_KEY_TYPE init_keys; /* keys to be distributed, bit mask */
  1381. tBTM_LE_KEY_TYPE resp_keys; /* keys to be distributed, bit mask */
  1382. } tBTM_LE_IO_REQ;
  1383. #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
  1384. /* data type for tBTM_LE_COMPLT */
  1385. typedef struct {
  1386. UINT8 reason;
  1387. UINT8 sec_level;
  1388. BOOLEAN is_pair_cancel;
  1389. BOOLEAN smp_over_br;
  1390. } tBTM_LE_COMPLT;
  1391. #endif
  1392. /* BLE encryption keys */
  1393. typedef struct {
  1394. BT_OCTET16 ltk;
  1395. BT_OCTET8 rand;
  1396. UINT16 ediv;
  1397. UINT8 sec_level;
  1398. UINT8 key_size;
  1399. } tBTM_LE_PENC_KEYS;
  1400. /* BLE CSRK keys */
  1401. typedef struct {
  1402. UINT32 counter;
  1403. BT_OCTET16 csrk;
  1404. UINT8 sec_level;
  1405. } tBTM_LE_PCSRK_KEYS;
  1406. /* BLE Encryption reproduction keys */
  1407. typedef struct {
  1408. BT_OCTET16 ltk;
  1409. UINT16 div;
  1410. UINT8 key_size;
  1411. UINT8 sec_level;
  1412. } tBTM_LE_LENC_KEYS;
  1413. /* BLE SRK keys */
  1414. typedef struct {
  1415. UINT32 counter;
  1416. UINT16 div;
  1417. UINT8 sec_level;
  1418. BT_OCTET16 csrk;
  1419. } tBTM_LE_LCSRK_KEYS;
  1420. typedef struct {
  1421. BT_OCTET16 irk;
  1422. tBLE_ADDR_TYPE addr_type;
  1423. BD_ADDR static_addr;
  1424. } tBTM_LE_PID_KEYS;
  1425. typedef union {
  1426. tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
  1427. tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
  1428. tBTM_LE_PID_KEYS pid_key; /* peer device ID key */
  1429. tBTM_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
  1430. tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
  1431. } tBTM_LE_KEY_VALUE;
  1432. typedef struct {
  1433. tBTM_LE_KEY_TYPE key_type;
  1434. tBTM_LE_KEY_VALUE *p_key_value;
  1435. } tBTM_LE_KEY;
  1436. typedef union {
  1437. tBTM_LE_IO_REQ io_req; /* BTM_LE_IO_REQ_EVT */
  1438. UINT32 key_notif; /* BTM_LE_KEY_NOTIF_EVT */
  1439. /* BTM_LE_NC_REQ_EVT */
  1440. /* no callback data for BTM_LE_KEY_REQ_EVT */
  1441. /* and BTM_LE_OOB_REQ_EVT */
  1442. #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
  1443. tBTM_LE_COMPLT complt; /* BTM_LE_COMPLT_EVT */
  1444. tSMP_OOB_DATA_TYPE req_oob_type;
  1445. #endif
  1446. tBTM_LE_KEY key;
  1447. } tBTM_LE_EVT_DATA;
  1448. /* Simple Pairing Events. Called by the stack when Simple Pairing related
  1449. ** events occur.
  1450. */
  1451. typedef UINT8 (tBTM_LE_CALLBACK) (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
  1452. #define BTM_BLE_KEY_TYPE_ID 1
  1453. #define BTM_BLE_KEY_TYPE_ER 2
  1454. #define BTM_BLE_KEY_TYPE_COUNTER 3 //tobe obsolete
  1455. typedef struct {
  1456. BT_OCTET16 ir;
  1457. BT_OCTET16 irk;
  1458. BT_OCTET16 dhk;
  1459. } tBTM_BLE_LOCAL_ID_KEYS;
  1460. typedef union {
  1461. tBTM_BLE_LOCAL_ID_KEYS id_keys;
  1462. BT_OCTET16 er;
  1463. } tBTM_BLE_LOCAL_KEYS;
  1464. /* New LE identity key for local device.
  1465. */
  1466. typedef void (tBTM_LE_KEY_CALLBACK) (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
  1467. /***************************
  1468. ** Security Manager Types
  1469. ****************************/
  1470. /* Structure that applications use to register with BTM_SecRegister */
  1471. typedef struct {
  1472. tBTM_AUTHORIZE_CALLBACK *p_authorize_callback;
  1473. tBTM_PIN_CALLBACK *p_pin_callback;
  1474. tBTM_LINK_KEY_CALLBACK *p_link_key_callback;
  1475. tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback;
  1476. tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_callback;
  1477. tBTM_SP_CALLBACK *p_sp_callback;
  1478. #if BLE_INCLUDED == TRUE
  1479. #if SMP_INCLUDED == TRUE
  1480. tBTM_LE_CALLBACK *p_le_callback;
  1481. #endif
  1482. tBTM_LE_KEY_CALLBACK *p_le_key_callback;
  1483. #endif
  1484. } tBTM_APPL_INFO;
  1485. /* Callback function for when a link supervision timeout event occurs.
  1486. ** This asynchronous event is enabled/disabled by calling BTM_RegForLstoEvt().
  1487. */
  1488. typedef void (tBTM_LSTO_CBACK) (BD_ADDR remote_bda, UINT16 timeout);
  1489. /*****************************************************************************
  1490. ** POWER MANAGEMENT
  1491. *****************************************************************************/
  1492. /****************************
  1493. ** Power Manager Constants
  1494. *****************************/
  1495. /* BTM Power manager status codes */
  1496. enum {
  1497. BTM_PM_STS_ACTIVE = HCI_MODE_ACTIVE,
  1498. BTM_PM_STS_HOLD = HCI_MODE_HOLD,
  1499. BTM_PM_STS_SNIFF = HCI_MODE_SNIFF,
  1500. BTM_PM_STS_PARK = HCI_MODE_PARK,
  1501. BTM_PM_STS_SSR, /* report the SSR parameters in HCI_SNIFF_SUB_RATE_EVT */
  1502. BTM_PM_STS_PENDING, /* when waiting for status from controller */
  1503. BTM_PM_STS_ERROR /* when HCI command status returns error */
  1504. };
  1505. typedef UINT8 tBTM_PM_STATUS;
  1506. /* BTM Power manager modes */
  1507. enum {
  1508. BTM_PM_MD_ACTIVE = BTM_PM_STS_ACTIVE,
  1509. BTM_PM_MD_HOLD = BTM_PM_STS_HOLD,
  1510. BTM_PM_MD_SNIFF = BTM_PM_STS_SNIFF,
  1511. BTM_PM_MD_PARK = BTM_PM_STS_PARK,
  1512. BTM_PM_MD_FORCE = 0x10 /* OR this to force ACL link to a certain mode */
  1513. };
  1514. typedef UINT8 tBTM_PM_MODE;
  1515. #define BTM_PM_SET_ONLY_ID 0x80
  1516. /* Operation codes */
  1517. #define BTM_PM_REG_SET 1 /* The module wants to set the desired power mode */
  1518. #define BTM_PM_REG_NOTIF 2 /* The module wants to receive mode change event */
  1519. #define BTM_PM_DEREG 4 /* The module does not want to involve with PM anymore */
  1520. /************************
  1521. ** Power Manager Types
  1522. *************************/
  1523. typedef struct {
  1524. UINT16 max;
  1525. UINT16 min;
  1526. UINT16 attempt;
  1527. UINT16 timeout;
  1528. tBTM_PM_MODE mode;
  1529. } tBTM_PM_PWR_MD;
  1530. /*************************************
  1531. ** Power Manager Callback Functions
  1532. **************************************/
  1533. typedef void (tBTM_PM_STATUS_CBACK) (BD_ADDR p_bda, tBTM_PM_STATUS status,
  1534. UINT16 value, UINT8 hci_status);
  1535. /************************
  1536. ** Stored Linkkey Types
  1537. *************************/
  1538. #define BTM_CB_EVT_DELETE_STORED_LINK_KEYS 4
  1539. typedef struct {
  1540. UINT8 event;
  1541. UINT8 status;
  1542. UINT16 num_keys;
  1543. } tBTM_DELETE_STORED_LINK_KEY_COMPLETE;
  1544. /* MIP evnets, callbacks */
  1545. enum {
  1546. BTM_MIP_MODE_CHG_EVT,
  1547. BTM_MIP_DISCONNECT_EVT,
  1548. BTM_MIP_PKTS_COMPL_EVT,
  1549. BTM_MIP_RXDATA_EVT
  1550. };
  1551. typedef UINT8 tBTM_MIP_EVT;
  1552. typedef struct {
  1553. tBTM_MIP_EVT event;
  1554. BD_ADDR bd_addr;
  1555. UINT16 mip_id;
  1556. } tBTM_MIP_MODE_CHANGE;
  1557. typedef struct {
  1558. tBTM_MIP_EVT event;
  1559. UINT16 mip_id;
  1560. UINT8 disc_reason;
  1561. } tBTM_MIP_CONN_TIMEOUT;
  1562. #define BTM_MIP_MAX_RX_LEN 17
  1563. typedef struct {
  1564. tBTM_MIP_EVT event;
  1565. UINT16 mip_id;
  1566. UINT8 rx_len;
  1567. UINT8 rx_data[BTM_MIP_MAX_RX_LEN];
  1568. } tBTM_MIP_RXDATA;
  1569. typedef struct {
  1570. tBTM_MIP_EVT event;
  1571. BD_ADDR bd_addr;
  1572. UINT8 data[11]; /* data[0] shows Vender-specific device type */
  1573. } tBTM_MIP_EIR_HANDSHAKE;
  1574. typedef struct {
  1575. tBTM_MIP_EVT event;
  1576. UINT16 num_sent; /* Number of packets completed at the controller */
  1577. } tBTM_MIP_PKTS_COMPL;
  1578. typedef union {
  1579. tBTM_MIP_EVT event;
  1580. tBTM_MIP_MODE_CHANGE mod_chg;
  1581. tBTM_MIP_CONN_TIMEOUT conn_tmo;
  1582. tBTM_MIP_EIR_HANDSHAKE eir;
  1583. tBTM_MIP_PKTS_COMPL completed;
  1584. tBTM_MIP_RXDATA rxdata;
  1585. } tBTM_MIP_EVENT_DATA;
  1586. /* MIP event callback function */
  1587. typedef void (tBTM_MIP_EVENTS_CB) (tBTM_MIP_EVT event, tBTM_MIP_EVENT_DATA data);
  1588. /* MIP Device query callback function */
  1589. typedef BOOLEAN (tBTM_MIP_QUERY_CB) (BD_ADDR dev_addr, UINT8 *p_mode, LINK_KEY link_key);
  1590. #define BTM_CONTRL_ACTIVE 1 /* ACL link on, SCO link ongoing, sniff mode */
  1591. #define BTM_CONTRL_SCAN 2 /* Scan state - paging/inquiry/trying to connect*/
  1592. #define BTM_CONTRL_IDLE 3 /* Idle state - page scan, LE advt, inquiry scan */
  1593. typedef UINT8 tBTM_CONTRL_STATE;
  1594. /*****************************************************************************
  1595. ** EXTERNAL FUNCTION DECLARATIONS
  1596. *****************************************************************************/
  1597. /*
  1598. #ifdef __cplusplus
  1599. extern "C" {
  1600. #endif
  1601. */
  1602. /*****************************************************************************
  1603. ** DEVICE CONTROL and COMMON FUNCTIONS
  1604. *****************************************************************************/
  1605. /*******************************************************************************
  1606. **
  1607. ** Function BTM_DeviceReset
  1608. **
  1609. ** Description This function is called to reset the controller.The Callback function
  1610. ** if provided is called when startup of the device has
  1611. ** completed.
  1612. **
  1613. ** Returns void
  1614. **
  1615. *******************************************************************************/
  1616. //extern
  1617. void BTM_DeviceReset (tBTM_CMPL_CB *p_cb);
  1618. /*******************************************************************************
  1619. **
  1620. ** Function BTM_IsDeviceUp
  1621. **
  1622. ** Description This function is called to check if the device is up.
  1623. **
  1624. ** Returns TRUE if device is up, else FALSE
  1625. **
  1626. *******************************************************************************/
  1627. //extern
  1628. BOOLEAN BTM_IsDeviceUp (void);
  1629. /*******************************************************************************
  1630. **
  1631. ** Function BTM_SetLocalDeviceName
  1632. **
  1633. ** Description This function is called to set the local device name.
  1634. **
  1635. ** Returns BTM_CMD_STARTED if successful, otherwise an error
  1636. **
  1637. *******************************************************************************/
  1638. //extern
  1639. tBTM_STATUS BTM_SetLocalDeviceName (char *p_name);
  1640. /*******************************************************************************
  1641. **
  1642. ** Function BTM_SetDeviceClass
  1643. **
  1644. ** Description This function is called to set the local device class
  1645. **
  1646. ** Returns BTM_SUCCESS if successful, otherwise an error
  1647. **
  1648. *******************************************************************************/
  1649. //extern
  1650. tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class);
  1651. /*******************************************************************************
  1652. **
  1653. ** Function BTM_ReadLocalDeviceName
  1654. **
  1655. ** Description This function is called to read the local device name.
  1656. **
  1657. ** Returns status of the operation
  1658. ** If success, BTM_SUCCESS is returned and p_name points stored
  1659. ** local device name
  1660. ** If BTM doesn't store local device name, BTM_NO_RESOURCES is
  1661. ** is returned and p_name is set to NULL
  1662. **
  1663. *******************************************************************************/
  1664. //extern
  1665. tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name);
  1666. /*******************************************************************************
  1667. **
  1668. ** Function BTM_ReadLocalDeviceNameFromController
  1669. **
  1670. ** Description Get local device name from controller. Do not use cached
  1671. ** name (used to get chip-id prior to btm reset complete).
  1672. **
  1673. ** Returns BTM_CMD_STARTED if successful, otherwise an error
  1674. **
  1675. *******************************************************************************/
  1676. //extern
  1677. tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback);
  1678. /*******************************************************************************
  1679. **
  1680. ** Function BTM_ReadDeviceClass
  1681. **
  1682. ** Description This function is called to read the local device class
  1683. **
  1684. ** Returns pointer to the device class
  1685. **
  1686. *******************************************************************************/
  1687. //extern
  1688. UINT8 *BTM_ReadDeviceClass (void);
  1689. /*******************************************************************************
  1690. **
  1691. ** Function BTM_ReadLocalFeatures
  1692. **
  1693. ** Description This function is called to read the local features
  1694. **
  1695. ** Returns pointer to the local features string
  1696. **
  1697. *******************************************************************************/
  1698. //extern
  1699. UINT8 *BTM_ReadLocalFeatures (void);
  1700. /*******************************************************************************
  1701. **
  1702. ** Function BTM_RegisterForDeviceStatusNotif
  1703. **
  1704. ** Description This function is called to register for device status
  1705. ** change notifications.
  1706. **
  1707. ** Returns pointer to previous caller's callback function or NULL if first
  1708. ** registration.
  1709. **
  1710. *******************************************************************************/
  1711. //extern
  1712. tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb);
  1713. /*******************************************************************************
  1714. **
  1715. ** Function BTM_RegisterForVSEvents
  1716. **
  1717. ** Description This function is called to register/deregister for vendor
  1718. ** specific HCI events.
  1719. **
  1720. ** If is_register=TRUE, then the function will be registered;
  1721. ** if is_register=FALSE, then the function will be deregistered.
  1722. **
  1723. ** Returns BTM_SUCCESS if successful,
  1724. ** BTM_BUSY if maximum number of callbacks have already been
  1725. ** registered.
  1726. **
  1727. *******************************************************************************/
  1728. //extern
  1729. tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register);
  1730. /*******************************************************************************
  1731. **
  1732. ** Function BTM_VendorSpecificCommand
  1733. **
  1734. ** Description Send a vendor specific HCI command to the controller.
  1735. **
  1736. ** Returns
  1737. ** BTM_SUCCESS Command sent. Does not expect command complete
  1738. ** event. (command cmpl callback param is NULL)
  1739. ** BTM_CMD_STARTED Command sent. Waiting for command cmpl event.
  1740. ** BTM_BUSY Command not sent. Waiting for cmd cmpl event for
  1741. ** prior command.
  1742. **
  1743. *******************************************************************************/
  1744. //extern
  1745. tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
  1746. UINT8 param_len,
  1747. UINT8 *p_param_buf,
  1748. tBTM_VSC_CMPL_CB *p_cb);
  1749. /*******************************************************************************
  1750. **
  1751. ** Function BTM_AllocateSCN
  1752. **
  1753. ** Description Look through the Server Channel Numbers for a free one to be
  1754. ** used with an RFCOMM connection.
  1755. **
  1756. ** Returns Allocated SCN number or 0 if none.
  1757. **
  1758. *******************************************************************************/
  1759. //extern
  1760. UINT8 BTM_AllocateSCN(void);
  1761. // btla-specific ++
  1762. /*******************************************************************************
  1763. **
  1764. ** Function BTM_TryAllocateSCN
  1765. **
  1766. ** Description Try to allocate a fixed server channel
  1767. **
  1768. ** Returns Returns TRUE if server channel was available
  1769. **
  1770. *******************************************************************************/
  1771. //extern
  1772. BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
  1773. // btla-specific --
  1774. /*******************************************************************************
  1775. **
  1776. ** Function BTM_FreeSCN
  1777. **
  1778. ** Description Free the specified SCN.
  1779. **
  1780. ** Returns TRUE if successful, FALSE if SCN is not in use or invalid
  1781. **
  1782. *******************************************************************************/
  1783. //extern
  1784. BOOLEAN BTM_FreeSCN(UINT8 scn);
  1785. /*******************************************************************************
  1786. **
  1787. ** Function BTM_SetTraceLevel
  1788. **
  1789. ** Description This function sets the trace level for BTM. If called with
  1790. ** a value of 0xFF, it simply returns the current trace level.
  1791. **
  1792. ** Returns The new or current trace level
  1793. **
  1794. *******************************************************************************/
  1795. //extern
  1796. UINT8 BTM_SetTraceLevel (UINT8 new_level);
  1797. /*******************************************************************************
  1798. **
  1799. ** Function BTM_WritePageTimeout
  1800. **
  1801. ** Description Send HCI Wite Page Timeout.
  1802. **
  1803. ** Returns
  1804. ** BTM_SUCCESS Command sent.
  1805. ** BTM_NO_RESOURCES If out of resources to send the command.
  1806. **
  1807. *******************************************************************************/
  1808. //extern
  1809. tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout);
  1810. /*******************************************************************************
  1811. **
  1812. ** Function BTM_WriteVoiceSettings
  1813. **
  1814. ** Description Send HCI Write Voice Settings command.
  1815. ** See hcidefs.h for settings bitmask values.
  1816. **
  1817. ** Returns
  1818. ** BTM_SUCCESS Command sent.
  1819. ** BTM_NO_RESOURCES If out of resources to send the command.
  1820. **
  1821. **
  1822. *******************************************************************************/
  1823. //extern
  1824. tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings);
  1825. /*******************************************************************************
  1826. **
  1827. ** Function BTM_EnableTestMode
  1828. **
  1829. ** Description Send HCI the enable device under test command.
  1830. **
  1831. ** Note: Controller can only be taken out of this mode by
  1832. ** resetting the controller.
  1833. **
  1834. ** Returns
  1835. ** BTM_SUCCESS Command sent.
  1836. ** BTM_NO_RESOURCES If out of resources to send the command.
  1837. **
  1838. **
  1839. *******************************************************************************/
  1840. //extern
  1841. tBTM_STATUS BTM_EnableTestMode(void);
  1842. /*****************************************************************************
  1843. ** DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
  1844. *****************************************************************************/
  1845. /*******************************************************************************
  1846. **
  1847. ** Function BTM_SetDiscoverability
  1848. **
  1849. ** Description This function is called to set the device into or out of
  1850. ** discoverable mode. Discoverable mode means inquiry
  1851. ** scans are enabled. If a value of '0' is entered for window or
  1852. ** interval, the default values are used.
  1853. **
  1854. ** Returns BTM_SUCCESS if successful
  1855. ** BTM_BUSY if a setting of the filter is already in progress
  1856. ** BTM_NO_RESOURCES if couldn't get a memory pool buffer
  1857. ** BTM_ILLEGAL_VALUE if a bad parameter was detected
  1858. ** BTM_WRONG_MODE if the device is not up.
  1859. **
  1860. *******************************************************************************/
  1861. //extern
  1862. tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window,
  1863. UINT16 interval);
  1864. /*******************************************************************************
  1865. **
  1866. ** Function BTM_ReadDiscoverability
  1867. **
  1868. ** Description This function is called to read the current discoverability
  1869. ** mode of the device.
  1870. **
  1871. ** Output Params: p_window - current inquiry scan duration
  1872. ** p_interval - current inquiry scan interval
  1873. **
  1874. ** Returns BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
  1875. ** BTM_GENERAL_DISCOVERABLE
  1876. **
  1877. *******************************************************************************/
  1878. //extern
  1879. UINT16 BTM_ReadDiscoverability (UINT16 *p_window,
  1880. UINT16 *p_interval);
  1881. /*******************************************************************************
  1882. **
  1883. ** Function BTM_SetPeriodicInquiryMode
  1884. **
  1885. ** Description This function is called to set the device periodic inquiry mode.
  1886. ** If the duration is zero, the periodic inquiry mode is cancelled.
  1887. **
  1888. ** Parameters: p_inqparms - pointer to the inquiry information
  1889. ** mode - GENERAL or LIMITED inquiry
  1890. ** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
  1891. ** max_resps - maximum amount of devices to search for before ending the inquiry
  1892. ** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
  1893. ** BTM_FILTER_COND_BD_ADDR
  1894. ** filter_cond - value for the filter (based on filter_cond_type)
  1895. **
  1896. ** max_delay - maximum amount of time between successive inquiries
  1897. ** min_delay - minimum amount of time between successive inquiries
  1898. ** p_results_cb - callback returning pointer to results (tBTM_INQ_RESULTS)
  1899. **
  1900. ** Returns BTM_CMD_STARTED if successfully started
  1901. ** BTM_ILLEGAL_VALUE if a bad parameter is detected
  1902. ** BTM_NO_RESOURCES if could not allocate a message buffer
  1903. ** BTM_SUCCESS - if cancelling the periodic inquiry
  1904. ** BTM_BUSY - if an inquiry is already active
  1905. ** BTM_WRONG_MODE if the device is not up.
  1906. **
  1907. *******************************************************************************/
  1908. //extern
  1909. tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms,
  1910. UINT16 max_delay, UINT16 min_delay,
  1911. tBTM_INQ_RESULTS_CB *p_results_cb);
  1912. /*******************************************************************************
  1913. **
  1914. ** Function BTM_StartInquiry
  1915. **
  1916. ** Description This function is called to start an inquiry.
  1917. **
  1918. ** Parameters: p_inqparms - pointer to the inquiry information
  1919. ** mode - GENERAL or LIMITED inquiry
  1920. ** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
  1921. ** max_resps - maximum amount of devices to search for before ending the inquiry
  1922. ** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
  1923. ** BTM_FILTER_COND_BD_ADDR
  1924. ** filter_cond - value for the filter (based on filter_cond_type)
  1925. **
  1926. ** p_results_cb - Pointer to the callback routine which gets called
  1927. ** upon receipt of an inquiry result. If this field is
  1928. ** NULL, the application is not notified.
  1929. **
  1930. ** p_cmpl_cb - Pointer to the callback routine which gets called
  1931. ** upon completion. If this field is NULL, the
  1932. ** application is not notified when completed.
  1933. ** Returns tBTM_STATUS
  1934. ** BTM_CMD_STARTED if successfully initiated
  1935. ** BTM_BUSY if already in progress
  1936. ** BTM_ILLEGAL_VALUE if parameter(s) are out of range
  1937. ** BTM_NO_RESOURCES if could not allocate resources to start the command
  1938. ** BTM_WRONG_MODE if the device is not up.
  1939. **
  1940. *******************************************************************************/
  1941. //extern
  1942. tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms,
  1943. tBTM_INQ_RESULTS_CB *p_results_cb,
  1944. tBTM_CMPL_CB *p_cmpl_cb);
  1945. /*******************************************************************************
  1946. **
  1947. ** Function BTM_IsInquiryActive
  1948. **
  1949. ** Description This function returns a bit mask of the current inquiry state
  1950. **
  1951. ** Returns BTM_INQUIRY_INACTIVE if inactive (0)
  1952. ** BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
  1953. ** BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
  1954. ** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
  1955. **
  1956. *******************************************************************************/
  1957. //extern
  1958. UINT16 BTM_IsInquiryActive (void);
  1959. /*******************************************************************************
  1960. **
  1961. ** Function BTM_CancelInquiry
  1962. **
  1963. ** Description This function cancels an inquiry if active
  1964. **
  1965. ** Returns BTM_SUCCESS if successful
  1966. ** BTM_NO_RESOURCES if could not allocate a message buffer
  1967. ** BTM_WRONG_MODE if the device is not up.
  1968. **
  1969. *******************************************************************************/
  1970. //extern
  1971. tBTM_STATUS BTM_CancelInquiry(void);
  1972. /*******************************************************************************
  1973. **
  1974. ** Function BTM_CancelPeriodicInquiry
  1975. **
  1976. ** Description This function cancels a periodic inquiry
  1977. **
  1978. ** Returns
  1979. ** BTM_NO_RESOURCES if could not allocate a message buffer
  1980. ** BTM_SUCCESS - if cancelling the periodic inquiry
  1981. ** BTM_WRONG_MODE if the device is not up.
  1982. **
  1983. *******************************************************************************/
  1984. //extern
  1985. tBTM_STATUS BTM_CancelPeriodicInquiry(void);
  1986. /*******************************************************************************
  1987. **
  1988. ** Function BTM_SetConnectability
  1989. **
  1990. ** Description This function is called to set the device into or out of
  1991. ** connectable mode. Discoverable mode means page scans enabled.
  1992. **
  1993. ** Returns BTM_SUCCESS if successful
  1994. ** BTM_ILLEGAL_VALUE if a bad parameter is detected
  1995. ** BTM_NO_RESOURCES if could not allocate a message buffer
  1996. ** BTM_WRONG_MODE if the device is not up.
  1997. **
  1998. *******************************************************************************/
  1999. //extern
  2000. tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window,
  2001. UINT16 interval);
  2002. /*******************************************************************************
  2003. **
  2004. ** Function BTM_ReadConnectability
  2005. **
  2006. ** Description This function is called to read the current discoverability
  2007. ** mode of the device.
  2008. ** Output Params p_window - current page scan duration
  2009. ** p_interval - current time between page scans
  2010. **
  2011. ** Returns BTM_NON_CONNECTABLE or BTM_CONNECTABLE
  2012. **
  2013. *******************************************************************************/
  2014. //extern
  2015. UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval);
  2016. /*******************************************************************************
  2017. **
  2018. ** Function BTM_SetInquiryMode
  2019. **
  2020. ** Description This function is called to set standard, with RSSI
  2021. ** mode or extended of the inquiry for local device.
  2022. **
  2023. ** Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
  2024. ** BTM_INQ_RESULT_EXTENDED
  2025. **
  2026. ** Returns BTM_SUCCESS if successful
  2027. ** BTM_NO_RESOURCES if couldn't get a memory pool buffer
  2028. ** BTM_ILLEGAL_VALUE if a bad parameter was detected
  2029. ** BTM_WRONG_MODE if the device is not up.
  2030. **
  2031. *******************************************************************************/
  2032. //extern
  2033. tBTM_STATUS BTM_SetInquiryMode (UINT8 mode);
  2034. /*******************************************************************************
  2035. **
  2036. ** Function BTM_SetInquiryScanType
  2037. **
  2038. ** Description This function is called to set the iquiry scan-type to
  2039. ** standard or interlaced.
  2040. **
  2041. ** Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
  2042. **
  2043. ** Returns BTM_SUCCESS if successful
  2044. ** BTM_MODE_UNSUPPORTED if not a 1.2 device
  2045. ** BTM_WRONG_MODE if the device is not up.
  2046. **
  2047. *******************************************************************************/
  2048. //extern
  2049. tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type);
  2050. /*******************************************************************************
  2051. **
  2052. ** Function BTM_SetPageScanType
  2053. **
  2054. ** Description This function is called to set the page scan-type to
  2055. ** standard or interlaced.
  2056. **
  2057. ** Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
  2058. **
  2059. ** Returns BTM_SUCCESS if successful
  2060. ** BTM_MODE_UNSUPPORTED if not a 1.2 device
  2061. ** BTM_WRONG_MODE if the device is not up.
  2062. **
  2063. *******************************************************************************/
  2064. //extern
  2065. tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type);
  2066. /*******************************************************************************
  2067. **
  2068. ** Function BTM_ReadRemoteDeviceName
  2069. **
  2070. ** Description This function initiates a remote device HCI command to the
  2071. ** controller and calls the callback when the process has completed.
  2072. **
  2073. ** Input Params: remote_bda - device address of name to retrieve
  2074. ** p_cb - callback function called when BTM_CMD_STARTED
  2075. ** is returned.
  2076. ** A pointer to tBTM_REMOTE_DEV_NAME is passed to the
  2077. ** callback.
  2078. **
  2079. ** Returns
  2080. ** BTM_CMD_STARTED is returned if the request was successfully sent
  2081. ** to HCI.
  2082. ** BTM_BUSY if already in progress
  2083. ** BTM_UNKNOWN_ADDR if device address is bad
  2084. ** BTM_NO_RESOURCES if could not allocate resources to start the command
  2085. ** BTM_WRONG_MODE if the device is not up.
  2086. **
  2087. *******************************************************************************/
  2088. //extern
  2089. tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda,
  2090. tBTM_CMPL_CB *p_cb,
  2091. tBT_TRANSPORT transport);
  2092. /*******************************************************************************
  2093. **
  2094. ** Function BTM_CancelRemoteDeviceName
  2095. **
  2096. ** Description This function initiates the cancel request for the specified
  2097. ** remote device.
  2098. **
  2099. ** Input Params: None
  2100. **
  2101. ** Returns
  2102. ** BTM_CMD_STARTED is returned if the request was successfully sent
  2103. ** to HCI.
  2104. ** BTM_NO_RESOURCES if could not allocate resources to start the command
  2105. ** BTM_WRONG_MODE if there is not an active remote name request.
  2106. **
  2107. *******************************************************************************/
  2108. //extern
  2109. tBTM_STATUS BTM_CancelRemoteDeviceName (void);
  2110. /*******************************************************************************
  2111. **
  2112. ** Function BTM_ReadRemoteVersion
  2113. **
  2114. ** Description This function is called to read a remote device's version
  2115. **
  2116. ** Returns BTM_SUCCESS if successful, otherwise an error
  2117. **
  2118. *******************************************************************************/
  2119. //extern
  2120. tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr,
  2121. UINT8 *lmp_version,
  2122. UINT16 *manufacturer,
  2123. UINT16 *lmp_sub_version);
  2124. /*******************************************************************************
  2125. **
  2126. ** Function BTM_ReadRemoteFeatures
  2127. **
  2128. ** Description This function is called to read a remote device's
  2129. ** supported features mask (features mask located at page 0)
  2130. **
  2131. ** Note: The size of device features mask page is
  2132. ** BTM_FEATURE_BYTES_PER_PAGE bytes.
  2133. **
  2134. ** Returns pointer to the remote supported features mask
  2135. **
  2136. *******************************************************************************/
  2137. //extern
  2138. UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr);
  2139. /*******************************************************************************
  2140. **
  2141. ** Function BTM_ReadRemoteExtendedFeatures
  2142. **
  2143. ** Description This function is called to read a specific extended features
  2144. ** page of the remote device
  2145. **
  2146. ** Note1: The size of device features mask page is
  2147. ** BTM_FEATURE_BYTES_PER_PAGE bytes.
  2148. ** Note2: The valid device features mask page number depends on
  2149. ** the remote device capabilities. It is expected to be in the
  2150. ** range [0 - BTM_EXT_FEATURES_PAGE_MAX].
  2151. ** Returns pointer to the remote extended features mask
  2152. ** or NULL if page_number is not valid
  2153. **
  2154. *******************************************************************************/
  2155. //extern
  2156. UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number);
  2157. /*******************************************************************************
  2158. **
  2159. ** Function BTM_ReadNumberRemoteFeaturesPages
  2160. **
  2161. ** Description This function is called to retrieve the number of feature pages
  2162. ** read from the remote device
  2163. **
  2164. ** Returns number of features pages read from the remote device
  2165. **
  2166. *******************************************************************************/
  2167. //extern
  2168. UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr);
  2169. /*******************************************************************************
  2170. **
  2171. ** Function BTM_ReadAllRemoteFeatures
  2172. **
  2173. ** Description This function is called to read all features of the remote device
  2174. **
  2175. ** Returns pointer to the byte[0] of the page[0] of the remote device
  2176. ** feature mask.
  2177. **
  2178. ** Note: the function returns the pointer to the array of the size
  2179. ** BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1).
  2180. **
  2181. *******************************************************************************/
  2182. //extern
  2183. UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr);
  2184. /*******************************************************************************
  2185. **
  2186. ** Function BTM_InqDbRead
  2187. **
  2188. ** Description This function looks through the inquiry database for a match
  2189. ** based on Bluetooth Device Address. This is the application's
  2190. ** interface to get the inquiry details of a specific BD address.
  2191. **
  2192. ** Returns pointer to entry, or NULL if not found
  2193. **
  2194. *******************************************************************************/
  2195. //extern
  2196. tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda);
  2197. /*******************************************************************************
  2198. **
  2199. ** Function BTM_InqDbFirst
  2200. **
  2201. ** Description This function looks through the inquiry database for the first
  2202. ** used entry, and returns that. This is used in conjunction with
  2203. ** BTM_InqDbNext by applications as a way to walk through the
  2204. ** inquiry database.
  2205. **
  2206. ** Returns pointer to first in-use entry, or NULL if DB is empty
  2207. **
  2208. *******************************************************************************/
  2209. //extern
  2210. tBTM_INQ_INFO *BTM_InqDbFirst (void);
  2211. /*******************************************************************************
  2212. **
  2213. ** Function BTM_InqDbNext
  2214. **
  2215. ** Description This function looks through the inquiry database for the next
  2216. ** used entry, and returns that. If the input parameter is NULL,
  2217. ** the first entry is returned.
  2218. **
  2219. ** Returns pointer to next in-use entry, or NULL if no more found.
  2220. **
  2221. *******************************************************************************/
  2222. //extern
  2223. tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur);
  2224. /*******************************************************************************
  2225. **
  2226. ** Function BTM_ClearInqDb
  2227. **
  2228. ** Description This function is called to clear out a device or all devices
  2229. ** from the inquiry database.
  2230. **
  2231. ** Parameter p_bda - (input) BD_ADDR -> Address of device to clear
  2232. ** (NULL clears all entries)
  2233. **
  2234. ** Returns BTM_BUSY if an inquiry, get remote name, or event filter
  2235. ** is active, otherwise BTM_SUCCESS
  2236. **
  2237. *******************************************************************************/
  2238. //extern
  2239. tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda);
  2240. /*******************************************************************************
  2241. **
  2242. ** Function BTM_ReadInquiryRspTxPower
  2243. **
  2244. ** Description This command will read the inquiry Transmit Power level used
  2245. ** to transmit the FHS and EIR data packets.
  2246. ** This can be used directly in the Tx Power Level EIR data type.
  2247. **
  2248. ** Returns BTM_SUCCESS if successful
  2249. **
  2250. *******************************************************************************/
  2251. //extern
  2252. tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
  2253. #if SDP_INCLUDED == TRUE
  2254. /*******************************************************************************
  2255. **
  2256. ** Function BTM_StartDiscovery
  2257. **
  2258. ** Description This function is called by an application (or profile)
  2259. ** when it wants to trigger an service discovery using the
  2260. ** BTM's discovery database.
  2261. **
  2262. ** Returns tBTM_STATUS
  2263. ** BTM_CMD_STARTED if the discovery was initiated
  2264. ** BTM_BUSY if one is already in progress
  2265. ** BTM_UNKNOWN_ADDR if no addresses are in the INQ DB
  2266. ** BTM_ERR_PROCESSING if err initiating the command
  2267. **
  2268. *******************************************************************************/
  2269. //extern
  2270. tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb,
  2271. BD_ADDR_PTR p_rem_addr);
  2272. /*******************************************************************************
  2273. **
  2274. ** Function BTM_FindAttribute
  2275. **
  2276. ** Description This function is called by an application (or profile)
  2277. ** when it wants to see if an attribute exists in the BTM
  2278. ** discovery database.
  2279. **
  2280. ** Returns Pointer to matching record, or NULL
  2281. **
  2282. *******************************************************************************/
  2283. //extern
  2284. tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id,
  2285. tSDP_DISC_REC *p_start_rec);
  2286. /*******************************************************************************
  2287. **
  2288. ** Function BTM_FindService
  2289. **
  2290. ** Description This function is called by an application (or profile)
  2291. ** when it wants to see if a service exists in the BTM
  2292. ** discovery database.
  2293. **
  2294. ** Returns Pointer to matching record, or NULL
  2295. **
  2296. *******************************************************************************/
  2297. //extern
  2298. tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid,
  2299. tSDP_DISC_REC *p_start_rec);
  2300. /*******************************************************************************
  2301. **
  2302. ** Function BTM_SetDiscoveryParams
  2303. **
  2304. ** Description This function is called to set the BTM default discovery parameters.
  2305. ** These UUID and attribute filters are used during the call to
  2306. ** BTM_StartDiscovery.
  2307. **
  2308. ** Returns void
  2309. **
  2310. *******************************************************************************/
  2311. //extern
  2312. void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list,
  2313. UINT16 num_attr, UINT16 *p_attr_list);
  2314. #endif /*SDP_INCLUDED*/
  2315. /*****************************************************************************
  2316. ** ACL CHANNEL MANAGEMENT FUNCTIONS
  2317. *****************************************************************************/
  2318. /*******************************************************************************
  2319. **
  2320. ** Function BTM_SetLinkPolicy
  2321. **
  2322. ** Description Create and send HCI "Write Policy Set" command
  2323. **
  2324. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  2325. **
  2326. *******************************************************************************/
  2327. //extern
  2328. tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda,
  2329. UINT16 *settings);
  2330. /*******************************************************************************
  2331. **
  2332. ** Function BTM_SetDefaultLinkPolicy
  2333. **
  2334. ** Description Set the default value for HCI "Write Policy Set" command
  2335. ** to use when an ACL link is created.
  2336. **
  2337. ** Returns void
  2338. **
  2339. *******************************************************************************/
  2340. //extern
  2341. void BTM_SetDefaultLinkPolicy (UINT16 settings);
  2342. /*******************************************************************************
  2343. **
  2344. ** Function BTM_SetDefaultLinkSuperTout
  2345. **
  2346. ** Description Set the default value for HCI "Write Link Supervision Timeout"
  2347. ** command to use when an ACL link is created.
  2348. **
  2349. ** Returns void
  2350. **
  2351. *******************************************************************************/
  2352. //extern
  2353. void BTM_SetDefaultLinkSuperTout (UINT16 timeout);
  2354. /*******************************************************************************
  2355. **
  2356. ** Function BTM_SetLinkSuperTout
  2357. **
  2358. ** Description Create and send HCI "Write Link Supervision Timeout" command
  2359. **
  2360. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  2361. **
  2362. *******************************************************************************/
  2363. //extern
  2364. tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda,
  2365. UINT16 timeout);
  2366. /*******************************************************************************
  2367. **
  2368. ** Function BTM_GetLinkSuperTout
  2369. **
  2370. ** Description Read the link supervision timeout value of the connection
  2371. **
  2372. ** Returns status of the operation
  2373. **
  2374. *******************************************************************************/
  2375. //extern
  2376. tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda,
  2377. UINT16 *p_timeout);
  2378. /*******************************************************************************
  2379. **
  2380. ** Function BTM_IsAclConnectionUp
  2381. **
  2382. ** Description This function is called to check if an ACL connection exists
  2383. ** to a specific remote BD Address.
  2384. **
  2385. ** Returns TRUE if connection is up, else FALSE.
  2386. **
  2387. *******************************************************************************/
  2388. //extern
  2389. BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport);
  2390. /*******************************************************************************
  2391. **
  2392. ** Function BTM_GetRole
  2393. **
  2394. ** Description This function is called to get the role of the local device
  2395. ** for the ACL connection with the specified remote device
  2396. **
  2397. ** Returns BTM_SUCCESS if connection exists.
  2398. ** BTM_UNKNOWN_ADDR if no active link with bd addr specified
  2399. **
  2400. *******************************************************************************/
  2401. //extern
  2402. tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role);
  2403. /*******************************************************************************
  2404. **
  2405. ** Function BTM_SwitchRole
  2406. **
  2407. ** Description This function is called to switch role between master and
  2408. ** slave. If role is already set it will do nothing. If the
  2409. ** command was initiated, the callback function is called upon
  2410. ** completion.
  2411. **
  2412. ** Returns BTM_SUCCESS if already in specified role.
  2413. ** BTM_CMD_STARTED if command issued to controller.
  2414. ** BTM_NO_RESOURCES if couldn't allocate memory to issue command
  2415. ** BTM_UNKNOWN_ADDR if no active link with bd addr specified
  2416. ** BTM_MODE_UNSUPPORTED if local device does not support role switching
  2417. **
  2418. *******************************************************************************/
  2419. //extern
  2420. tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
  2421. UINT8 new_role,
  2422. tBTM_CMPL_CB *p_cb);
  2423. /*******************************************************************************
  2424. **
  2425. ** Function BTM_ReadRSSI
  2426. **
  2427. ** Description This function is called to read the link policy settings.
  2428. ** The address of link policy results are returned in the callback.
  2429. ** (tBTM_RSSI_RESULTS)
  2430. **
  2431. ** Returns BTM_CMD_STARTED if command issued to controller.
  2432. ** BTM_NO_RESOURCES if couldn't allocate memory to issue command
  2433. ** BTM_UNKNOWN_ADDR if no active link with bd addr specified
  2434. ** BTM_BUSY if command is already in progress
  2435. **
  2436. *******************************************************************************/
  2437. //extern
  2438. tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
  2439. /*******************************************************************************
  2440. **
  2441. ** Function BTM_ReadTxPower
  2442. **
  2443. ** Description This function is called to read the current connection
  2444. ** TX power of the connection. The TX power level results
  2445. ** are returned in the callback.
  2446. ** (tBTM_RSSI_RESULTS)
  2447. **
  2448. ** Returns BTM_CMD_STARTED if command issued to controller.
  2449. ** BTM_NO_RESOURCES if couldn't allocate memory to issue command
  2450. ** BTM_UNKNOWN_ADDR if no active link with bd addr specified
  2451. ** BTM_BUSY if command is already in progress
  2452. **
  2453. *******************************************************************************/
  2454. //extern
  2455. tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
  2456. tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
  2457. /*******************************************************************************
  2458. **
  2459. ** Function BTM_ReadLinkQuality
  2460. **
  2461. ** Description This function is called to read the link quality.
  2462. ** The value of the link quality is returned in the callback.
  2463. ** (tBTM_LINK_QUALITY_RESULTS)
  2464. **
  2465. ** Returns BTM_CMD_STARTED if command issued to controller.
  2466. ** BTM_NO_RESOURCES if couldn't allocate memory to issue command
  2467. ** BTM_UNKNOWN_ADDR if no active link with bd addr specified
  2468. ** BTM_BUSY if command is already in progress
  2469. **
  2470. *******************************************************************************/
  2471. //extern
  2472. tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
  2473. /*******************************************************************************
  2474. **
  2475. ** Function BTM_RegBusyLevelNotif
  2476. **
  2477. ** Description This function is called to register a callback to receive
  2478. ** busy level change events.
  2479. **
  2480. ** Returns BTM_SUCCESS if successfully registered, otherwise error
  2481. **
  2482. *******************************************************************************/
  2483. //extern
  2484. tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
  2485. tBTM_BL_EVENT_MASK evt_mask);
  2486. /*******************************************************************************
  2487. **
  2488. ** Function BTM_AclRegisterForChanges
  2489. **
  2490. ** Description This function is called to register a callback to receive
  2491. ** ACL database change events, i.e. new connection or removed.
  2492. **
  2493. ** Returns BTM_SUCCESS if successfully initiated, otherwise error
  2494. **
  2495. *******************************************************************************/
  2496. //extern
  2497. tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb);
  2498. /*******************************************************************************
  2499. **
  2500. ** Function BTM_GetNumAclLinks
  2501. **
  2502. ** Description This function is called to count the number of
  2503. ** ACL links that are active.
  2504. **
  2505. ** Returns UINT16 Number of active ACL links
  2506. **
  2507. *******************************************************************************/
  2508. //extern
  2509. UINT16 BTM_GetNumAclLinks (void);
  2510. /*******************************************************************************
  2511. **
  2512. ** Function BTM_SetQoS
  2513. **
  2514. ** Description This function is called to setup QoS
  2515. **
  2516. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  2517. **
  2518. *******************************************************************************/
  2519. //extern
  2520. tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow,
  2521. tBTM_CMPL_CB *p_cb);
  2522. /*****************************************************************************
  2523. ** (e)SCO CHANNEL MANAGEMENT FUNCTIONS
  2524. *****************************************************************************/
  2525. /*******************************************************************************
  2526. **
  2527. ** Function BTM_CreateSco
  2528. **
  2529. ** Description This function is called to create an SCO connection. If the
  2530. ** "is_orig" flag is TRUE, the connection will be originated,
  2531. ** otherwise BTM will wait for the other side to connect.
  2532. **
  2533. ** Returns BTM_UNKNOWN_ADDR if the ACL connection is not up
  2534. ** BTM_BUSY if another SCO being set up to
  2535. ** the same BD address
  2536. ** BTM_NO_RESOURCES if the max SCO limit has been reached
  2537. ** BTM_CMD_STARTED if the connection establishment is started.
  2538. ** In this case, "*p_sco_inx" is filled in
  2539. ** with the sco index used for the connection.
  2540. **
  2541. *******************************************************************************/
  2542. //extern
  2543. tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig,
  2544. UINT16 pkt_types, UINT16 *p_sco_inx,
  2545. tBTM_SCO_CB *p_conn_cb,
  2546. tBTM_SCO_CB *p_disc_cb);
  2547. /*******************************************************************************
  2548. **
  2549. ** Function BTM_RemoveSco
  2550. **
  2551. ** Description This function is called to remove a specific SCO connection.
  2552. **
  2553. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  2554. **
  2555. *******************************************************************************/
  2556. //extern
  2557. tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx);
  2558. /*******************************************************************************
  2559. **
  2560. ** Function BTM_SetScoPacketTypes
  2561. **
  2562. ** Description This function is called to set the packet types used for
  2563. ** a specific SCO connection,
  2564. **
  2565. ** Parameters pkt_types - One or more of the following
  2566. ** BTM_SCO_PKT_TYPES_MASK_HV1
  2567. ** BTM_SCO_PKT_TYPES_MASK_HV2
  2568. ** BTM_SCO_PKT_TYPES_MASK_HV3
  2569. ** BTM_SCO_PKT_TYPES_MASK_EV3
  2570. ** BTM_SCO_PKT_TYPES_MASK_EV4
  2571. ** BTM_SCO_PKT_TYPES_MASK_EV5
  2572. **
  2573. ** BTM_SCO_LINK_ALL_MASK - enables all supported types
  2574. **
  2575. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  2576. **
  2577. *******************************************************************************/
  2578. //extern
  2579. tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types);
  2580. /*******************************************************************************
  2581. **
  2582. ** Function BTM_ReadScoPacketTypes
  2583. **
  2584. ** Description This function is read the packet types used for a specific
  2585. ** SCO connection.
  2586. **
  2587. ** Returns One or more of the following (bitmask)
  2588. ** BTM_SCO_PKT_TYPES_MASK_HV1
  2589. ** BTM_SCO_PKT_TYPES_MASK_HV2
  2590. ** BTM_SCO_PKT_TYPES_MASK_HV3
  2591. ** BTM_SCO_PKT_TYPES_MASK_EV3
  2592. ** BTM_SCO_PKT_TYPES_MASK_EV4
  2593. ** BTM_SCO_PKT_TYPES_MASK_EV5
  2594. **
  2595. ** Returns packet types supported for the connection
  2596. **
  2597. *******************************************************************************/
  2598. //extern
  2599. UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx);
  2600. /*******************************************************************************
  2601. **
  2602. ** Function BTM_ReadDeviceScoPacketTypes
  2603. **
  2604. ** Description This function is read the SCO packet types that
  2605. ** the device supports.
  2606. **
  2607. ** Returns packet types supported by the device.
  2608. **
  2609. *******************************************************************************/
  2610. //extern
  2611. UINT16 BTM_ReadDeviceScoPacketTypes (void);
  2612. /*******************************************************************************
  2613. **
  2614. ** Function BTM_ReadScoHandle
  2615. **
  2616. ** Description This function is used to read the HCI handle used for a specific
  2617. ** SCO connection,
  2618. **
  2619. ** Returns handle for the connection, or 0xFFFF if invalid SCO index.
  2620. **
  2621. *******************************************************************************/
  2622. //extern
  2623. UINT16 BTM_ReadScoHandle (UINT16 sco_inx);
  2624. /*******************************************************************************
  2625. **
  2626. ** Function BTM_ReadScoBdAddr
  2627. **
  2628. ** Description This function is read the remote BD Address for a specific
  2629. ** SCO connection,
  2630. **
  2631. ** Returns pointer to BD address or NULL if not known
  2632. **
  2633. *******************************************************************************/
  2634. //extern
  2635. UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx);
  2636. /*******************************************************************************
  2637. **
  2638. ** Function BTM_ReadScoDiscReason
  2639. **
  2640. ** Description This function is returns the reason why an (e)SCO connection
  2641. ** has been removed. It contains the value until read, or until
  2642. ** another (e)SCO connection has disconnected.
  2643. **
  2644. ** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
  2645. **
  2646. *******************************************************************************/
  2647. //extern
  2648. UINT16 BTM_ReadScoDiscReason (void);
  2649. /*******************************************************************************
  2650. **
  2651. ** Function BTM_SetEScoMode
  2652. **
  2653. ** Description This function sets up the negotiated parameters for SCO or
  2654. ** eSCO, and sets as the default mode used for calls to
  2655. ** BTM_CreateSco. It can be called only when there are no
  2656. ** active (e)SCO links.
  2657. **
  2658. ** Returns BTM_SUCCESS if the successful.
  2659. ** BTM_BUSY if there are one or more active (e)SCO links.
  2660. **
  2661. *******************************************************************************/
  2662. //extern
  2663. tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode,
  2664. tBTM_ESCO_PARAMS *p_parms);
  2665. /*******************************************************************************
  2666. **
  2667. ** Function BTM_SetWBSCodec
  2668. **
  2669. ** Description This function sends command to the controller to setup
  2670. ** WBS codec for the upcoming eSCO connection.
  2671. **
  2672. ** Returns BTM_SUCCESS.
  2673. **
  2674. **
  2675. *******************************************************************************/
  2676. //extern
  2677. tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type);
  2678. /*******************************************************************************
  2679. **
  2680. ** Function BTM_RegForEScoEvts
  2681. **
  2682. ** Description This function registers a SCO event callback with the
  2683. ** specified instance. It should be used to received
  2684. ** connection indication events and change of link parameter
  2685. ** events.
  2686. **
  2687. ** Returns BTM_SUCCESS if the successful.
  2688. ** BTM_ILLEGAL_VALUE if there is an illegal sco_inx
  2689. **
  2690. *******************************************************************************/
  2691. //extern
  2692. tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx,
  2693. tBTM_ESCO_CBACK *p_esco_cback);
  2694. /*******************************************************************************
  2695. **
  2696. ** Function BTM_ReadEScoLinkParms
  2697. **
  2698. ** Description This function returns the current eSCO link parameters for
  2699. ** the specified handle. This can be called anytime a connection
  2700. ** is active, but is typically called after receiving the SCO
  2701. ** opened callback.
  2702. **
  2703. ** Note: If called over a 1.1 controller, only the packet types
  2704. ** field has meaning.
  2705. ** Note: If the upper layer doesn't know the current sco index,
  2706. ** BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first parameter to
  2707. ** find the first active SCO index
  2708. **
  2709. ** Returns BTM_SUCCESS if returned data is valid connection.
  2710. ** BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
  2711. ** BTM_MODE_UNSUPPORTED if local controller does not support
  2712. ** 1.2 specification.
  2713. **
  2714. *******************************************************************************/
  2715. //extern
  2716. tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx,
  2717. tBTM_ESCO_DATA *p_parms);
  2718. /*******************************************************************************
  2719. **
  2720. ** Function BTM_ChangeEScoLinkParms
  2721. **
  2722. ** Description This function requests renegotiation of the parameters on
  2723. ** the current eSCO Link. If any of the changes are accepted
  2724. ** by the controllers, the BTM_ESCO_CHG_EVT event is sent in
  2725. ** the tBTM_ESCO_CBACK function with the current settings of
  2726. ** the link. The callback is registered through the call to
  2727. ** BTM_SetEScoMode.
  2728. **
  2729. **
  2730. ** Returns BTM_CMD_STARTED if command is successfully initiated.
  2731. ** BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
  2732. ** BTM_NO_RESOURCES - not enough resources to initiate command.
  2733. ** BTM_MODE_UNSUPPORTED if local controller does not support
  2734. ** 1.2 specification.
  2735. **
  2736. *******************************************************************************/
  2737. //extern
  2738. tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx,
  2739. tBTM_CHG_ESCO_PARAMS *p_parms);
  2740. /*******************************************************************************
  2741. **
  2742. ** Function BTM_EScoConnRsp
  2743. **
  2744. ** Description This function is called upon receipt of an (e)SCO connection
  2745. ** request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
  2746. ** the request. Parameters used to negotiate eSCO links.
  2747. ** If p_parms is NULL, then values set through BTM_SetEScoMode
  2748. ** are used.
  2749. ** If the link type of the incoming request is SCO, then only
  2750. ** the tx_bw, max_latency, content format, and packet_types are
  2751. ** valid. The hci_status parameter should be
  2752. ** ([0x0] to accept, [0x0d..0x0f] to reject)
  2753. **
  2754. **
  2755. ** Returns void
  2756. **
  2757. *******************************************************************************/
  2758. //extern
  2759. void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status,
  2760. tBTM_ESCO_PARAMS *p_parms);
  2761. /*******************************************************************************
  2762. **
  2763. ** Function BTM_GetNumScoLinks
  2764. **
  2765. ** Description This function returns the number of active SCO links.
  2766. **
  2767. ** Returns UINT8
  2768. **
  2769. *******************************************************************************/
  2770. //extern
  2771. UINT8 BTM_GetNumScoLinks (void);
  2772. /*****************************************************************************
  2773. ** SECURITY MANAGEMENT FUNCTIONS
  2774. *****************************************************************************/
  2775. /*******************************************************************************
  2776. **
  2777. ** Function BTM_SecRegister
  2778. **
  2779. ** Description Application manager calls this function to register for
  2780. ** security services. There can be one and only one application
  2781. ** saving link keys. BTM allows only first registration.
  2782. **
  2783. ** Returns TRUE if registered OK, else FALSE
  2784. **
  2785. *******************************************************************************/
  2786. //extern
  2787. BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info);
  2788. /*******************************************************************************
  2789. **
  2790. ** Function BTM_SecRegisterLinkKeyNotificationCallback
  2791. **
  2792. ** Description Profiles can register to be notified when a new Link Key
  2793. ** is generated per connection.
  2794. **
  2795. ** Returns TRUE if registered OK, else FALSE
  2796. **
  2797. *******************************************************************************/
  2798. //extern
  2799. BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback(
  2800. tBTM_LINK_KEY_CALLBACK *p_callback);
  2801. /*******************************************************************************
  2802. **
  2803. ** Function BTM_SecAddRmtNameNotifyCallback
  2804. **
  2805. ** Description Profiles can register to be notified when name of the
  2806. ** remote device is resolved (up to BTM_SEC_MAX_RMT_NAME_CALLBACKS).
  2807. **
  2808. ** Returns TRUE if registered OK, else FALSE
  2809. **
  2810. *******************************************************************************/
  2811. //extern
  2812. BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
  2813. /*******************************************************************************
  2814. **
  2815. ** Function BTM_SecDeleteRmtNameNotifyCallback
  2816. **
  2817. ** Description A profile can deregister notification when a new Link Key
  2818. ** is generated per connection.
  2819. **
  2820. ** Returns TRUE if OK, else FALSE
  2821. **
  2822. *******************************************************************************/
  2823. //extern
  2824. BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
  2825. /*******************************************************************************
  2826. **
  2827. ** Function BTM_GetSecurityFlags
  2828. **
  2829. ** Description Get security flags for the device
  2830. **
  2831. ** Returns BOOLEAN TRUE or FALSE is device found
  2832. **
  2833. *******************************************************************************/
  2834. //extern
  2835. BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 *p_sec_flags);
  2836. /*******************************************************************************
  2837. **
  2838. ** Function BTM_GetSecurityFlagsByTransport
  2839. **
  2840. ** Description Get security flags for the device on a particular transport
  2841. **
  2842. ** Parameters bd_addr: BD address of remote device
  2843. ** p_sec_flags : Out parameter to be filled with security flags for the connection
  2844. ** transport : Physical transport of the connection (BR/EDR or LE)
  2845. **
  2846. ** Returns BOOLEAN TRUE or FALSE is device found
  2847. **
  2848. *******************************************************************************/
  2849. //extern
  2850. BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr,
  2851. UINT8 *p_sec_flags, tBT_TRANSPORT transport);
  2852. /*******************************************************************************
  2853. **
  2854. ** Function BTM_ReadTrustedMask
  2855. **
  2856. ** Description Get trusted mask for the device
  2857. **
  2858. ** Returns NULL, if the device record is not found.
  2859. ** otherwise, the trusted mask
  2860. **
  2861. *******************************************************************************/
  2862. //extern
  2863. UINT32 *BTM_ReadTrustedMask (BD_ADDR bd_addr);
  2864. /*******************************************************************************
  2865. **
  2866. ** Function BTM_SetPinType
  2867. **
  2868. ** Description Set PIN type for the device.
  2869. **
  2870. ** Returns void
  2871. **
  2872. *******************************************************************************/
  2873. //extern
  2874. void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len);
  2875. /*******************************************************************************
  2876. **
  2877. ** Function BTM_SetPairableMode
  2878. **
  2879. ** Description Enable or disable pairing
  2880. **
  2881. ** Parameters allow_pairing - (TRUE or FALSE) whether or not the device
  2882. ** allows pairing.
  2883. ** connect_only_paired - (TRUE or FALSE) whether or not to
  2884. ** only allow paired devices to connect.
  2885. **
  2886. ** Returns void
  2887. **
  2888. *******************************************************************************/
  2889. //extern
  2890. void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired);
  2891. /*******************************************************************************
  2892. **
  2893. ** Function BTM_SetSecureConnectionsOnly
  2894. **
  2895. ** Description Enable or disable default treatment for Mode 4 Level 0 services
  2896. **
  2897. ** Parameter secure_connections_only_mode - (TRUE or FALSE)
  2898. ** TRUE means that the device should treat Mode 4 Level 0 services as
  2899. ** services of other levels.
  2900. ** FALSE means that the device should provide default treatment for
  2901. ** Mode 4 Level 0 services.
  2902. **
  2903. ** Returns void
  2904. **
  2905. *******************************************************************************/
  2906. //extern
  2907. void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode);
  2908. /*******************************************************************************
  2909. **
  2910. ** Function BTM_SetSecurityLevel
  2911. **
  2912. ** Description Register service security level with Security Manager. Each
  2913. ** service must register its requirements regardless of the
  2914. ** security level that is used. This API is called once for originators
  2915. ** nad again for acceptors of connections.
  2916. **
  2917. ** Returns TRUE if registered OK, else FALSE
  2918. **
  2919. *******************************************************************************/
  2920. //extern
  2921. BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name,
  2922. UINT8 service_id, UINT16 sec_level,
  2923. UINT16 psm, UINT32 mx_proto_id,
  2924. UINT32 mx_chan_id);
  2925. /*******************************************************************************
  2926. **
  2927. ** Function BTM_SetOutService
  2928. **
  2929. ** Description This function is called to set the service for
  2930. ** outgoing connection.
  2931. **
  2932. ** Returns void
  2933. **
  2934. *******************************************************************************/
  2935. //extern
  2936. void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id);
  2937. /*******************************************************************************
  2938. **
  2939. ** Function BTM_SecClrService
  2940. **
  2941. ** Description Removes specified service record(s) from the security database.
  2942. ** All service records with the specified name are removed.
  2943. ** Typically used only by devices with limited RAM so that it can
  2944. ** reuse an old security service record.
  2945. ** records (except SDP).
  2946. **
  2947. ** Returns Number of records that were freed.
  2948. **
  2949. *******************************************************************************/
  2950. //extern
  2951. UINT8 BTM_SecClrService (UINT8 service_id);
  2952. /*******************************************************************************
  2953. **
  2954. ** Function BTM_SecAddDevice
  2955. **
  2956. ** Description Add/modify device. This function will be normally called
  2957. ** during host startup to restore all required information
  2958. ** stored in the NVRAM.
  2959. ** dev_class, bd_name, link_key, and features are NULL if unknown
  2960. **
  2961. ** Returns TRUE if added OK, else FALSE
  2962. **
  2963. *******************************************************************************/
  2964. //extern
  2965. BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
  2966. BD_NAME bd_name, UINT8 *features,
  2967. UINT32 trusted_mask[], LINK_KEY link_key,
  2968. UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length);
  2969. /*******************************************************************************
  2970. **
  2971. ** Function BTM_SecDeleteDevice
  2972. **
  2973. ** Description Free resources associated with the device.
  2974. **
  2975. ** Returns TRUE if rmoved OK, FALSE if not found
  2976. **
  2977. *******************************************************************************/
  2978. //extern
  2979. BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
  2980. /*******************************************************************************
  2981. **
  2982. ** Function BTM_SecGetDeviceLinkKey
  2983. **
  2984. ** Description This function is called to obtain link key for the device
  2985. ** it returns BTM_SUCCESS if link key is available, or
  2986. ** BTM_UNKNOWN_ADDR if Security Manager does not know about
  2987. ** the device or device record does not contain link key info
  2988. **
  2989. ** Returns BTM_SUCCESS if successful, otherwise error code
  2990. **
  2991. *******************************************************************************/
  2992. //extern
  2993. tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr,
  2994. LINK_KEY link_key);
  2995. /*******************************************************************************
  2996. **
  2997. ** Function BTM_SecGetDeviceLinkKeyType
  2998. **
  2999. ** Description This function is called to obtain link key type for the
  3000. ** device.
  3001. ** it returns BTM_SUCCESS if link key is available, or
  3002. ** BTM_UNKNOWN_ADDR if Security Manager does not know about
  3003. ** the device or device record does not contain link key info
  3004. **
  3005. ** Returns BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
  3006. ** otherwise.
  3007. **
  3008. *******************************************************************************/
  3009. //extern
  3010. tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType (BD_ADDR bd_addr);
  3011. /*******************************************************************************
  3012. **
  3013. ** Function BTM_PINCodeReply
  3014. **
  3015. ** Description This function is called after Security Manager submitted
  3016. ** PIN code request to the UI.
  3017. **
  3018. ** Parameters: bd_addr - Address of the device for which PIN was requested
  3019. ** res - result of the operation BTM_SUCCESS if success
  3020. ** pin_len - length in bytes of the PIN Code
  3021. ** p_pin - pointer to array with the PIN Code
  3022. ** trusted_mask - bitwise OR of trusted services (array of UINT32)
  3023. **
  3024. ** Returns void
  3025. **
  3026. *******************************************************************************/
  3027. //extern
  3028. void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
  3029. UINT8 *p_pin, UINT32 trusted_mask[]);
  3030. /*******************************************************************************
  3031. **
  3032. ** Function BTM_SecBond
  3033. **
  3034. ** Description This function is called to perform bonding with peer device.
  3035. **
  3036. ** Parameters: bd_addr - Address of the device to bond
  3037. ** pin_len - length in bytes of the PIN Code
  3038. ** p_pin - pointer to array with the PIN Code
  3039. ** trusted_mask - bitwise OR of trusted services (array of UINT32)
  3040. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  3041. **
  3042. *******************************************************************************/
  3043. //extern
  3044. tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr,
  3045. UINT8 pin_len, UINT8 *p_pin,
  3046. UINT32 trusted_mask[]);
  3047. /*******************************************************************************
  3048. **
  3049. ** Function BTM_SecBondByTransport
  3050. **
  3051. ** Description This function is called to perform bonding by designated transport
  3052. **
  3053. ** Parameters: bd_addr - Address of the device to bond
  3054. ** pin_len - length in bytes of the PIN Code
  3055. ** p_pin - pointer to array with the PIN Code
  3056. ** trusted_mask - bitwise OR of trusted services (array of UINT32)
  3057. ** transport : Physical transport to use for bonding (BR/EDR or LE)
  3058. **
  3059. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  3060. **
  3061. *******************************************************************************/
  3062. //extern
  3063. tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr,
  3064. tBT_TRANSPORT transport,
  3065. UINT8 pin_len, UINT8 *p_pin,
  3066. UINT32 trusted_mask[]);
  3067. /*******************************************************************************
  3068. **
  3069. ** Function BTM_SecBondCancel
  3070. **
  3071. ** Description This function is called to cancel ongoing bonding process
  3072. ** with peer device.
  3073. **
  3074. ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error
  3075. **
  3076. *******************************************************************************/
  3077. //extern
  3078. tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr);
  3079. /*******************************************************************************
  3080. **
  3081. ** Function BTM_SetEncryption
  3082. **
  3083. ** Description This function is called to ensure that connection is
  3084. ** encrypted. Should be called only on an open connection.
  3085. ** Typically only needed for connections that first want to
  3086. ** bring up unencrypted links, then later encrypt them.
  3087. **
  3088. ** Parameters: bd_addr - Address of the peer device
  3089. ** p_callback - Pointer to callback function called if
  3090. ** this function returns PENDING after required
  3091. ** procedures are completed. Can be set to NULL
  3092. ** if status is not desired.
  3093. ** p_ref_data - pointer to any data the caller wishes to receive
  3094. ** in the callback function upon completion.
  3095. * can be set to NULL if not used.
  3096. **
  3097. ** Returns BTM_SUCCESS - already encrypted
  3098. ** BTM_PENDING - command will be returned in the callback
  3099. ** BTM_WRONG_MODE- connection not up.
  3100. ** BTM_BUSY - security procedures are currently active
  3101. ** BTM_MODE_UNSUPPORTED - if security manager not linked in.
  3102. **
  3103. *******************************************************************************/
  3104. //extern
  3105. tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport,
  3106. tBTM_SEC_CBACK *p_callback, void *p_ref_data);
  3107. /*******************************************************************************
  3108. **
  3109. ** Function BTM_ConfirmReqReply
  3110. **
  3111. ** Description This function is called to confirm the numeric value for
  3112. ** Simple Pairing in response to BTM_SP_CFM_REQ_EVT
  3113. **
  3114. ** Parameters: res - result of the operation BTM_SUCCESS if success
  3115. ** bd_addr - Address of the peer device
  3116. **
  3117. *******************************************************************************/
  3118. //extern
  3119. void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr);
  3120. /*******************************************************************************
  3121. **
  3122. ** Function BTM_PasskeyReqReply
  3123. **
  3124. ** Description This function is called to provide the passkey for
  3125. ** Simple Pairing in response to BTM_SP_KEY_REQ_EVT
  3126. **
  3127. ** Parameters: res - result of the operation BTM_SUCCESS if success
  3128. ** bd_addr - Address of the peer device
  3129. ** passkey - numeric value in the range of 0 - 999999(0xF423F).
  3130. **
  3131. *******************************************************************************/
  3132. //extern
  3133. void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey);
  3134. /*******************************************************************************
  3135. **
  3136. ** Function BTM_SendKeypressNotif
  3137. **
  3138. ** Description This function is used during the passkey entry model
  3139. ** by a device with KeyboardOnly IO capabilities
  3140. ** (very likely to be a HID Device).
  3141. ** It is called by a HID Device to inform the remote device when
  3142. ** a key has been entered or erased.
  3143. **
  3144. ** Parameters: bd_addr - Address of the peer device
  3145. ** type - notification type
  3146. **
  3147. *******************************************************************************/
  3148. //extern
  3149. void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type);
  3150. /*******************************************************************************
  3151. **
  3152. ** Function BTM_IoCapRsp
  3153. **
  3154. ** Description This function is called in response to BTM_SP_IO_REQ_EVT
  3155. ** When the event data io_req.oob_data is set to BTM_OOB_UNKNOWN
  3156. ** by the tBTM_SP_CALLBACK implementation, this function is
  3157. ** called to provide the actual response
  3158. **
  3159. ** Parameters: bd_addr - Address of the peer device
  3160. ** io_cap - The IO capability of local device.
  3161. ** oob - BTM_OOB_NONE or BTM_OOB_PRESENT.
  3162. ** auth_req- MITM protection required or not.
  3163. **
  3164. *******************************************************************************/
  3165. //extern
  3166. void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap,
  3167. tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
  3168. /*******************************************************************************
  3169. **
  3170. ** Function BTM_ReadLocalOobData
  3171. **
  3172. ** Description This function is called to read the local OOB data from
  3173. ** LM
  3174. **
  3175. *******************************************************************************/
  3176. //extern
  3177. tBTM_STATUS BTM_ReadLocalOobData(void);
  3178. /*******************************************************************************
  3179. **
  3180. ** Function BTM_RemoteOobDataReply
  3181. **
  3182. ** Description This function is called to provide the remote OOB data for
  3183. ** Simple Pairing in response to BTM_SP_RMT_OOB_EVT
  3184. **
  3185. ** Parameters: bd_addr - Address of the peer device
  3186. ** c - simple pairing Hash C.
  3187. ** r - simple pairing Randomizer C.
  3188. **
  3189. *******************************************************************************/
  3190. //extern
  3191. void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr,
  3192. BT_OCTET16 c, BT_OCTET16 r);
  3193. /*******************************************************************************
  3194. **
  3195. ** Function BTM_BuildOobData
  3196. **
  3197. ** Description This function is called to build the OOB data payload to
  3198. ** be sent over OOB (non-Bluetooth) link
  3199. **
  3200. ** Parameters: p_data - the location for OOB data
  3201. ** max_len - p_data size.
  3202. ** c - simple pairing Hash C.
  3203. ** r - simple pairing Randomizer C.
  3204. ** name_len- 0, local device name would not be included.
  3205. ** otherwise, the local device name is included for
  3206. ** up to this specified length
  3207. **
  3208. ** Returns Number of bytes in p_data.
  3209. **
  3210. *******************************************************************************/
  3211. //extern
  3212. UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
  3213. BT_OCTET16 r, UINT8 name_len);
  3214. /*******************************************************************************
  3215. **
  3216. ** Function BTM_BothEndsSupportSecureConnections
  3217. **
  3218. ** Description This function is called to check if both the local device and the peer device
  3219. ** specified by bd_addr support BR/EDR Secure Connections.
  3220. **
  3221. ** Parameters: bd_addr - address of the peer
  3222. **
  3223. ** Returns TRUE if BR/EDR Secure Connections are supported by both local
  3224. ** and the remote device.
  3225. ** else FALSE.
  3226. **
  3227. *******************************************************************************/
  3228. //extern
  3229. BOOLEAN BTM_BothEndsSupportSecureConnections(BD_ADDR bd_addr);
  3230. /*******************************************************************************
  3231. **
  3232. ** Function BTM_PeerSupportsSecureConnections
  3233. **
  3234. ** Description This function is called to check if the peer supports
  3235. ** BR/EDR Secure Connections.
  3236. **
  3237. ** Parameters: bd_addr - address of the peer
  3238. **
  3239. ** Returns TRUE if BR/EDR Secure Connections are supported by the peer,
  3240. ** else FALSE.
  3241. **
  3242. *******************************************************************************/
  3243. //extern
  3244. BOOLEAN BTM_PeerSupportsSecureConnections(BD_ADDR bd_addr);
  3245. /*******************************************************************************
  3246. **
  3247. ** Function BTM_ReadOobData
  3248. **
  3249. ** Description This function is called to parse the OOB data payload
  3250. ** received over OOB (non-Bluetooth) link
  3251. **
  3252. ** Parameters: p_data - the location for OOB data
  3253. ** eir_tag - The associated EIR tag to read the data.
  3254. ** *p_len(output) - the length of the data with the given tag.
  3255. **
  3256. ** Returns the beginning of the data with the given tag.
  3257. ** NULL, if the tag is not found.
  3258. **
  3259. *******************************************************************************/
  3260. //extern
  3261. UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
  3262. /*******************************************************************************
  3263. **
  3264. ** Function BTM_SecReadDevName
  3265. **
  3266. ** Description Looks for the device name in the security database for the
  3267. ** specified BD address.
  3268. **
  3269. ** Returns Pointer to the name or NULL
  3270. **
  3271. *******************************************************************************/
  3272. //extern
  3273. char *BTM_SecReadDevName (BD_ADDR bd_addr);
  3274. /*****************************************************************************
  3275. ** POWER MANAGEMENT FUNCTIONS
  3276. *****************************************************************************/
  3277. /*******************************************************************************
  3278. **
  3279. ** Function BTM_PmRegister
  3280. **
  3281. ** Description register or deregister with power manager
  3282. **
  3283. ** Returns BTM_SUCCESS if successful,
  3284. ** BTM_NO_RESOURCES if no room to hold registration
  3285. ** BTM_ILLEGAL_VALUE
  3286. **
  3287. *******************************************************************************/
  3288. //extern
  3289. tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id,
  3290. tBTM_PM_STATUS_CBACK *p_cb);
  3291. /*******************************************************************************
  3292. **
  3293. ** Function BTM_SetPowerMode
  3294. **
  3295. ** Description store the mode in control block or
  3296. ** alter ACL connection behavior.
  3297. **
  3298. ** Returns BTM_SUCCESS if successful,
  3299. ** BTM_UNKNOWN_ADDR if bd addr is not active or bad
  3300. **
  3301. *******************************************************************************/
  3302. //extern
  3303. tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda,
  3304. tBTM_PM_PWR_MD *p_mode);
  3305. /*******************************************************************************
  3306. **
  3307. ** Function BTM_ReadPowerMode
  3308. **
  3309. ** Description This returns the current mode for a specific
  3310. ** ACL connection.
  3311. **
  3312. ** Input Param remote_bda - device address of desired ACL connection
  3313. **
  3314. ** Output Param p_mode - address where the current mode is copied into.
  3315. ** BTM_ACL_MODE_NORMAL
  3316. ** BTM_ACL_MODE_HOLD
  3317. ** BTM_ACL_MODE_SNIFF
  3318. ** BTM_ACL_MODE_PARK
  3319. ** (valid only if return code is BTM_SUCCESS)
  3320. **
  3321. ** Returns BTM_SUCCESS if successful,
  3322. ** BTM_UNKNOWN_ADDR if bd addr is not active or bad
  3323. **
  3324. *******************************************************************************/
  3325. //extern
  3326. tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda,
  3327. tBTM_PM_MODE *p_mode);
  3328. /*******************************************************************************
  3329. **
  3330. ** Function BTM_SetSsrParams
  3331. **
  3332. ** Description This sends the given SSR parameters for the given ACL
  3333. ** connection if it is in ACTIVE mode.
  3334. **
  3335. ** Input Param remote_bda - device address of desired ACL connection
  3336. ** max_lat - maximum latency (in 0.625ms)(0-0xFFFE)
  3337. ** min_rmt_to - minimum remote timeout
  3338. ** min_loc_to - minimum local timeout
  3339. **
  3340. **
  3341. ** Returns BTM_SUCCESS if the HCI command is issued successful,
  3342. ** BTM_UNKNOWN_ADDR if bd addr is not active or bad
  3343. ** BTM_CMD_STORED if the command is stored
  3344. **
  3345. *******************************************************************************/
  3346. //extern
  3347. tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
  3348. UINT16 min_rmt_to, UINT16 min_loc_to);
  3349. /*******************************************************************************
  3350. **
  3351. ** Function BTM_GetHCIConnHandle
  3352. **
  3353. ** Description This function is called to get the handle for an ACL connection
  3354. ** to a specific remote BD Address.
  3355. **
  3356. ** Returns the handle of the connection, or 0xFFFF if none.
  3357. **
  3358. *******************************************************************************/
  3359. //extern
  3360. UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
  3361. /*******************************************************************************
  3362. **
  3363. ** Function BTM_DeleteStoredLinkKey
  3364. **
  3365. ** Description This function is called to delete link key for the specified
  3366. ** device addresses from the NVRAM storage attached to the Bluetooth
  3367. ** controller.
  3368. **
  3369. ** Parameters: bd_addr - Addresses of the devices
  3370. ** p_cb - Call back function to be called to return
  3371. ** the results
  3372. **
  3373. *******************************************************************************/
  3374. //extern
  3375. tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
  3376. /*******************************************************************************
  3377. **
  3378. ** Function BTM_WriteEIR
  3379. **
  3380. ** Description This function is called to write EIR data to controller.
  3381. **
  3382. ** Parameters p_buff - allocated HCI command buffer including extended
  3383. ** inquriry response
  3384. **
  3385. ** Returns BTM_SUCCESS - if successful
  3386. ** BTM_MODE_UNSUPPORTED - if local device cannot support it
  3387. **
  3388. *******************************************************************************/
  3389. //extern
  3390. tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff );
  3391. /*******************************************************************************
  3392. **
  3393. ** Function BTM_CheckEirData
  3394. **
  3395. ** Description This function is called to get EIR data from significant part.
  3396. **
  3397. ** Parameters p_eir - pointer of EIR significant part
  3398. ** type - finding EIR data type
  3399. ** p_length - return the length of EIR data
  3400. **
  3401. ** Returns pointer of EIR data
  3402. **
  3403. *******************************************************************************/
  3404. //extern
  3405. UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length );
  3406. /*******************************************************************************
  3407. **
  3408. ** Function BTM_HasEirService
  3409. **
  3410. ** Description This function is called to know if UUID in bit map of UUID.
  3411. **
  3412. ** Parameters p_eir_uuid - bit map of UUID list
  3413. ** uuid16 - UUID 16-bit
  3414. **
  3415. ** Returns TRUE - if found
  3416. ** FALSE - if not found
  3417. **
  3418. *******************************************************************************/
  3419. //extern
  3420. BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
  3421. /*******************************************************************************
  3422. **
  3423. ** Function BTM_HasInquiryEirService
  3424. **
  3425. ** Description This function is called to know if UUID in bit map of UUID list.
  3426. **
  3427. ** Parameters p_results - inquiry results
  3428. ** uuid16 - UUID 16-bit
  3429. **
  3430. ** Returns BTM_EIR_FOUND - if found
  3431. ** BTM_EIR_NOT_FOUND - if not found and it is complete list
  3432. ** BTM_EIR_UNKNOWN - if not found and it is not complete list
  3433. **
  3434. *******************************************************************************/
  3435. //extern
  3436. tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
  3437. UINT16 uuid16 );
  3438. /*******************************************************************************
  3439. **
  3440. ** Function BTM_AddEirService
  3441. **
  3442. ** Description This function is called to add a service in bit map of UUID list.
  3443. **
  3444. ** Parameters p_eir_uuid - bit mask of UUID list for EIR
  3445. ** uuid16 - UUID 16-bit
  3446. **
  3447. ** Returns None
  3448. **
  3449. *******************************************************************************/
  3450. //extern
  3451. void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
  3452. /*******************************************************************************
  3453. **
  3454. ** Function BTM_RemoveEirService
  3455. **
  3456. ** Description This function is called to remove a service in bit map of UUID list.
  3457. **
  3458. ** Parameters p_eir_uuid - bit mask of UUID list for EIR
  3459. ** uuid16 - UUID 16-bit
  3460. **
  3461. ** Returns None
  3462. **
  3463. *******************************************************************************/
  3464. //extern
  3465. void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
  3466. /*******************************************************************************
  3467. **
  3468. ** Function BTM_GetEirSupportedServices
  3469. **
  3470. ** Description This function is called to get UUID list from bit map of UUID list.
  3471. **
  3472. ** Parameters p_eir_uuid - bit mask of UUID list for EIR
  3473. ** p - reference of current pointer of EIR
  3474. ** max_num_uuid16 - max number of UUID can be written in EIR
  3475. ** num_uuid16 - number of UUID have been written in EIR
  3476. **
  3477. ** Returns BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
  3478. ** BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
  3479. **
  3480. *******************************************************************************/
  3481. //extern
  3482. UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p,
  3483. UINT8 max_num_uuid16, UINT8 *p_num_uuid16);
  3484. /*******************************************************************************
  3485. **
  3486. ** Function BTM_GetEirUuidList
  3487. **
  3488. ** Description This function parses EIR and returns UUID list.
  3489. **
  3490. ** Parameters p_eir - EIR
  3491. ** uuid_size - LEN_UUID_16, LEN_UUID_32, LEN_UUID_128
  3492. ** p_num_uuid - return number of UUID in found list
  3493. ** p_uuid_list - return UUID 16-bit list
  3494. ** max_num_uuid - maximum number of UUID to be returned
  3495. **
  3496. ** Returns 0 - if not found
  3497. ** BTM_EIR_COMPLETE_16BITS_UUID_TYPE
  3498. ** BTM_EIR_MORE_16BITS_UUID_TYPE
  3499. ** BTM_EIR_COMPLETE_32BITS_UUID_TYPE
  3500. ** BTM_EIR_MORE_32BITS_UUID_TYPE
  3501. ** BTM_EIR_COMPLETE_128BITS_UUID_TYPE
  3502. ** BTM_EIR_MORE_128BITS_UUID_TYPE
  3503. **
  3504. *******************************************************************************/
  3505. //extern
  3506. UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid,
  3507. UINT8 *p_uuid_list, UINT8 max_num_uuid);
  3508. /*****************************************************************************
  3509. ** SCO OVER HCI
  3510. *****************************************************************************/
  3511. /*******************************************************************************
  3512. **
  3513. ** Function BTM_ConfigScoPath
  3514. **
  3515. ** Description This function enable/disable SCO over HCI and registers SCO
  3516. ** data callback if SCO over HCI is enabled.
  3517. **
  3518. ** Parameter path: SCO or HCI
  3519. ** p_sco_data_cb: callback function or SCO data if path is set
  3520. ** to transport.
  3521. ** p_pcm_param: pointer to the PCM interface parameter. If a NULL
  3522. ** pointer is used, PCM parameter maintained in
  3523. ** the control block will be used; otherwise update
  3524. ** control block value.
  3525. ** err_data_rpt: Lisbon feature to enable the erronous data report
  3526. ** or not.
  3527. **
  3528. ** Returns BTM_SUCCESS if the successful.
  3529. ** BTM_NO_RESOURCES: no rsource to start the command.
  3530. ** BTM_ILLEGAL_VALUE: invalid callback function pointer.
  3531. ** BTM_CMD_STARTED :Command sent. Waiting for command cmpl event.
  3532. **
  3533. **
  3534. *******************************************************************************/
  3535. //extern
  3536. tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path,
  3537. tBTM_SCO_DATA_CB *p_sco_data_cb,
  3538. tBTM_SCO_PCM_PARAM *p_pcm_param,
  3539. BOOLEAN err_data_rpt);
  3540. /*******************************************************************************
  3541. **
  3542. ** Function BTM_WriteScoData
  3543. **
  3544. ** Description This function write SCO data to a specified instance. The data
  3545. ** to be written p_buf needs to carry an offset of
  3546. ** HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
  3547. ** exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is set
  3548. ** to 60 and is configurable. Data longer than the maximum bytes
  3549. ** will be truncated.
  3550. **
  3551. ** Returns BTM_SUCCESS: data write is successful
  3552. ** BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
  3553. ** BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO packet
  3554. ** size.
  3555. ** BTM_NO_RESOURCES: no resources.
  3556. ** BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is not
  3557. ** routed via HCI.
  3558. **
  3559. **
  3560. *******************************************************************************/
  3561. //extern
  3562. tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf);
  3563. /*******************************************************************************
  3564. **
  3565. ** Function BTM_SetARCMode
  3566. **
  3567. ** Description Send Audio Routing Control command.
  3568. **
  3569. ** Returns void
  3570. **
  3571. *******************************************************************************/
  3572. //extern
  3573. void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb);
  3574. /*******************************************************************************
  3575. **
  3576. ** Function BTM_PCM2Setup_Write
  3577. **
  3578. ** Description Send PCM2_Setup write command.
  3579. **
  3580. ** Returns void
  3581. **
  3582. *******************************************************************************/
  3583. //extern
  3584. void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb);
  3585. /*******************************************************************************
  3586. **
  3587. ** Function BTM_PM_ReadControllerState
  3588. **
  3589. ** Description This function is called to obtain the controller state
  3590. **
  3591. ** Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and BTM_CONTRL_IDLE)
  3592. **
  3593. *******************************************************************************/
  3594. //extern
  3595. tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
  3596. /*
  3597. #ifdef __cplusplus
  3598. }
  3599. #endif
  3600. */
  3601. #endif /* BTM_API_H */