btm_api.h 163 KB

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