btm_api.h 164 KB

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