btm_api.h 166 KB

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