btm_ble_api.h 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703
  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_BLE_API_H
  25. #define BTM_BLE_API_H
  26. #include "common/bt_defs.h"
  27. #include "stack/btm_api.h"
  28. #include "common/bt_common_types.h"
  29. #define CHANNEL_MAP_LEN 5
  30. typedef UINT8 tBTM_BLE_CHNL_MAP[CHANNEL_MAP_LEN];
  31. /* 0x00-0x04 only used for set advertising parameter command */
  32. #define BTM_BLE_CONNECT_EVT 0x00 /* 0x00-0x04 only used for set advertising
  33. parameter command */
  34. #define BTM_BLE_CONNECT_DIR_EVT 0x01 /* Connectable directed advertising */
  35. #define BTM_BLE_DISCOVER_EVT 0x02 /* Scannable undirected advertising */
  36. #define BTM_BLE_NON_CONNECT_EVT 0x03 /* Non connectable undirected advertising */
  37. #define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04 /* Connectable low duty
  38. cycle directed advertising */
  39. /* 0x00 - 0x05 can be received on adv event type */
  40. #define BTM_BLE_SCAN_RSP_EVT 0x04
  41. #define BTM_BLE_SCAN_REQ_EVT 0x05
  42. #define BTM_BLE_UNKNOWN_EVT 0xff
  43. #define BTM_BLE_UNKNOWN_EVT 0xff
  44. typedef UINT8 tBTM_BLE_EVT;
  45. typedef UINT8 tBTM_BLE_CONN_MODE;
  46. typedef UINT32 tBTM_BLE_REF_VALUE;
  47. #define BTM_BLE_SCAN_MODE_PASS 0
  48. #define BTM_BLE_SCAN_MODE_ACTI 1
  49. #define BTM_BLE_SCAN_MODE_NONE 0xff
  50. typedef UINT8 tBLE_SCAN_MODE;
  51. #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0
  52. #define BTM_BLE_BATCH_SCAN_MODE_PASS 1
  53. #define BTM_BLE_BATCH_SCAN_MODE_ACTI 2
  54. #define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3
  55. typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE;
  56. /* advertising channel map */
  57. #define BTM_BLE_ADV_CHNL_37 (0x01 << 0)
  58. #define BTM_BLE_ADV_CHNL_38 (0x01 << 1)
  59. #define BTM_BLE_ADV_CHNL_39 (0x01 << 2)
  60. typedef UINT8 tBTM_BLE_ADV_CHNL_MAP;
  61. /*d efault advertising channel map */
  62. #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP
  63. #define BTM_BLE_DEFAULT_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39)
  64. #endif
  65. /* advertising filter policy */
  66. #define AP_SCAN_CONN_ALL 0x00 /* default */
  67. #define AP_SCAN_WL_CONN_ALL 0x01
  68. #define AP_SCAN_ALL_CONN_WL 0x02
  69. #define AP_SCAN_CONN_WL 0x03
  70. #define AP_SCAN_CONN_POLICY_MAX 0x04
  71. typedef UINT8 tBTM_BLE_AFP;
  72. /* default advertising filter policy */
  73. #ifndef BTM_BLE_DEFAULT_AFP
  74. #define BTM_BLE_DEFAULT_AFP AP_SCAN_CONN_ALL
  75. #endif
  76. /* scanning filter policy */
  77. #define SP_ADV_ALL 0x00 /* 0: accept adv packet from all, directed adv pkt not directed */
  78. /* to local device is ignored */
  79. #define SP_ADV_WL 0x01 /* 1: accept adv packet from device in white list, directed adv */
  80. /* packet not directed to local device is ignored */
  81. #define SP_ADV_ALL_RPA_DIR_ADV 0x02 /* 2: accept adv packet from all, directed adv pkt */
  82. /* not directed to me is ignored except direct adv with RPA */
  83. #define SP_ADV_WL_RPA_DIR_ADV 0x03 /* 3: accept adv packet from device in white list, directed */
  84. /* adv pkt not directed to me is ignored except direct adv */
  85. /* with RPA */
  86. typedef UINT8 tBTM_BLE_SFP;
  87. #ifndef BTM_BLE_DEFAULT_SFP
  88. #define BTM_BLE_DEFAULT_SFP SP_ADV_ALL
  89. #endif
  90. /* adv parameter boundary values */
  91. #if BLE_HIGH_DUTY_ADV_INTERVAL
  92. #define BTM_BLE_ADV_INT_MIN 0x0008 /* 5ms */
  93. #else
  94. #define BTM_BLE_ADV_INT_MIN 0x0020 /* 20ms */
  95. #endif
  96. #define BTM_BLE_ADV_INT_MAX 0x4000 /* 10240ms */
  97. /* Full scan boundary values */
  98. #define BTM_BLE_ADV_SCAN_FULL_MIN 0x00
  99. #define BTM_BLE_ADV_SCAN_FULL_MAX 0x64
  100. /* Partial scan boundary values */
  101. #define BTM_BLE_ADV_SCAN_TRUNC_MIN BTM_BLE_ADV_SCAN_FULL_MIN
  102. #define BTM_BLE_ADV_SCAN_TRUNC_MAX BTM_BLE_ADV_SCAN_FULL_MAX
  103. /* Threshold values */
  104. #define BTM_BLE_ADV_SCAN_THR_MIN BTM_BLE_ADV_SCAN_FULL_MIN
  105. #define BTM_BLE_ADV_SCAN_THR_MAX BTM_BLE_ADV_SCAN_FULL_MAX
  106. /* connection parameter boundary values */
  107. #define BTM_BLE_SCAN_INT_MIN 0x0004
  108. #define BTM_BLE_SCAN_INT_MAX 0x4000
  109. #define BTM_BLE_SCAN_WIN_MIN 0x0004
  110. #define BTM_BLE_SCAN_WIN_MAX 0x4000
  111. #define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF
  112. #define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF
  113. #define BTM_BLE_CONN_INT_MIN 0x0006
  114. #define BTM_BLE_CONN_INT_MAX 0x0C80
  115. #define BTM_BLE_CONN_LATENCY_MAX 499
  116. #define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
  117. #define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
  118. #define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
  119. #define BTM_BLE_SCAN_PARAM_UNDEF 0xffffffff
  120. /* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
  121. /* default scan interval */
  122. #ifndef BTM_BLE_SCAN_FAST_INT
  123. #define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */
  124. #endif
  125. /* default scan window for background connection, applicable for auto connection or selective conenction */
  126. #ifndef BTM_BLE_SCAN_FAST_WIN
  127. #define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */
  128. #endif
  129. /* default scan paramter used in reduced power cycle (background scanning) */
  130. #ifndef BTM_BLE_SCAN_SLOW_INT_1
  131. #define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */
  132. #endif
  133. #ifndef BTM_BLE_SCAN_SLOW_WIN_1
  134. #define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */
  135. #endif
  136. /* default scan paramter used in reduced power cycle (background scanning) */
  137. #ifndef BTM_BLE_SCAN_SLOW_INT_2
  138. #define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */
  139. #endif
  140. #ifndef BTM_BLE_SCAN_SLOW_WIN_2
  141. #define BTM_BLE_SCAN_SLOW_WIN_2 36 /* 22.5 ms = 36 *0.625 */
  142. #endif
  143. /* default connection interval min */
  144. #ifndef BTM_BLE_CONN_INT_MIN_DEF
  145. #define BTM_BLE_CONN_INT_MIN_DEF 10 /* recommended min: 12.5 ms = 10 * 1.25 */
  146. #endif
  147. /* default connection interval max */
  148. #ifndef BTM_BLE_CONN_INT_MAX_DEF
  149. #if CONFIG_IDF_TARGET_ESP32
  150. #define BTM_BLE_CONN_INT_MAX_DEF 12 /* recommended max: 15 ms = 12 * 1.25 */
  151. #else
  152. #define BTM_BLE_CONN_INT_MAX_DEF (((MAX_ACL_CONNECTIONS + 1) * 4) > 12 ? ((MAX_ACL_CONNECTIONS + 1) * 4) : 12) /* recommended max: BTM_BLE_CONN_INT_MAX_DEF * 1.25 ms*/
  153. #endif
  154. #endif
  155. /* default slave latency */
  156. #ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF
  157. #define BTM_BLE_CONN_SLAVE_LATENCY_DEF 0 /* 0 */
  158. #endif
  159. /* default supervision timeout */
  160. #ifndef BTM_BLE_CONN_TIMEOUT_DEF
  161. #define BTM_BLE_CONN_TIMEOUT_DEF 600
  162. #endif
  163. /* minimum acceptable connection interval */
  164. #ifndef BTM_BLE_CONN_INT_MIN_LIMIT
  165. #define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009
  166. #endif
  167. #define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1
  168. #define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2
  169. #ifndef BTM_BLE_DIR_CONN_FALLBACK
  170. #define BTM_BLE_DIR_CONN_FALLBACK BTM_BLE_DIR_CONN_FALLBACK_UNDIR
  171. #endif
  172. #define BTM_CMAC_TLEN_SIZE 8 /* 64 bits */
  173. #define BTM_BLE_AUTH_SIGN_LEN 12 /* BLE data signature length 8 Bytes + 4 bytes counter*/
  174. typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */
  175. #ifndef BTM_BLE_HOST_SUPPORT
  176. #define BTM_BLE_HOST_SUPPORT 0x01
  177. #endif
  178. #ifndef BTM_BLE_SIMULTANEOUS_HOST
  179. #define BTM_BLE_SIMULTANEOUS_HOST 0x01
  180. #endif
  181. /* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */
  182. #define BTM_BLE_APPEARANCE_UNKNOWN 0x0000
  183. #define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040
  184. #define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080
  185. #define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0
  186. #define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1
  187. #define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100
  188. #define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140
  189. #define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180
  190. #define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0
  191. #define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200
  192. #define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240
  193. #define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280
  194. #define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
  195. #define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300
  196. #define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301
  197. #define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340
  198. #define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341
  199. #define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380
  200. #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381
  201. #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382
  202. #define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0
  203. #define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1
  204. #define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2
  205. #define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3
  206. #define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4
  207. #define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5
  208. #define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6
  209. #define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7
  210. #define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8
  211. #define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400
  212. #define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440
  213. #define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441
  214. #define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442
  215. #define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443
  216. #define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480
  217. #define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481
  218. #define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482
  219. #define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483
  220. #define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484
  221. #define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485
  222. #define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40
  223. #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
  224. #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42
  225. #define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80
  226. #define BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE 0x0CC0
  227. #define BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR 0x0CC1
  228. #define BTM_BLE_APPEARANCE_MOBILITY_SCOOTER 0x0CC2
  229. #define BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR 0x0D00
  230. #define BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP 0x0D40
  231. #define BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP 0x0D41
  232. #define BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP 0x0D44
  233. #define BTM_BLE_APPEARANCE_INSULIN_PEN 0x0D48
  234. #define BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY 0x0D80
  235. #define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440
  236. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441
  237. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442
  238. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443
  239. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444
  240. /* Structure returned with Rand/Encrypt complete callback */
  241. typedef struct {
  242. UINT8 status;
  243. UINT8 param_len;
  244. UINT16 opcode;
  245. UINT8 param_buf[BT_OCTET16_LEN];
  246. } tBTM_RAND_ENC;
  247. /* General callback function for notifying an application that a synchronous
  248. ** BTM function is complete. The pointer contains the address of any returned data.
  249. */
  250. typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1);
  251. #define BTM_BLE_FILTER_TARGET_SCANNER 0x01
  252. #define BTM_BLE_FILTER_TARGET_ADVR 0x00
  253. #define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */
  254. #define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */
  255. #define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */
  256. #define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */
  257. /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
  258. #define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0)
  259. #define BTM_BLE_GEN_DISC_FLAG (0x01 << 1)
  260. #define BTM_BLE_BREDR_NOT_SPT (0x01 << 2)
  261. /* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */
  262. #define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3)
  263. #define BTM_BLE_DMT_HOST_SPT (0x01 << 4)
  264. #define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00 ) /* lowest bit unset */
  265. #define BTM_BLE_ADV_FLAG_MASK (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG)
  266. #define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG )
  267. #define BTM_BLE_AD_BIT_DEV_NAME (0x00000001 << 0)
  268. #define BTM_BLE_AD_BIT_FLAGS (0x00000001 << 1)
  269. #define BTM_BLE_AD_BIT_MANU (0x00000001 << 2)
  270. #define BTM_BLE_AD_BIT_TX_PWR (0x00000001 << 3)
  271. #define BTM_BLE_AD_BIT_INT_RANGE (0x00000001 << 5)
  272. #define BTM_BLE_AD_BIT_SERVICE (0x00000001 << 6)
  273. #define BTM_BLE_AD_BIT_SERVICE_SOL (0x00000001 << 7)
  274. #define BTM_BLE_AD_BIT_SERVICE_DATA (0x00000001 << 8)
  275. #define BTM_BLE_AD_BIT_SIGN_DATA (0x00000001 << 9)
  276. #define BTM_BLE_AD_BIT_SERVICE_128SOL (0x00000001 << 10)
  277. #define BTM_BLE_AD_BIT_APPEARANCE (0x00000001 << 11)
  278. #define BTM_BLE_AD_BIT_PUBLIC_ADDR (0x00000001 << 12)
  279. #define BTM_BLE_AD_BIT_RANDOM_ADDR (0x00000001 << 13)
  280. #define BTM_BLE_AD_BIT_SERVICE_32 (0x00000001 << 4)
  281. #define BTM_BLE_AD_BIT_SERVICE_32SOL (0x00000001 << 14)
  282. #define BTM_BLE_AD_BIT_PROPRIETARY (0x00000001 << 15)
  283. #define BTM_BLE_AD_BIT_SERVICE_128 (0x00000001 << 16) /*128-bit Service UUIDs*/
  284. typedef UINT32 tBTM_BLE_AD_MASK;
  285. /* relate to ESP_BLE_AD_TYPE_xxx in esp_gap_ble_api.h */
  286. #define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */
  287. #define BTM_BLE_AD_TYPE_16SRV_PART HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */
  288. #define BTM_BLE_AD_TYPE_16SRV_CMPL HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */
  289. #define BTM_BLE_AD_TYPE_32SRV_PART HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */
  290. #define BTM_BLE_AD_TYPE_32SRV_CMPL HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */
  291. #define BTM_BLE_AD_TYPE_128SRV_PART HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */
  292. #define BTM_BLE_AD_TYPE_128SRV_CMPL HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */
  293. #define BTM_BLE_AD_TYPE_NAME_SHORT HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */
  294. #define BTM_BLE_AD_TYPE_NAME_CMPL HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */
  295. #define BTM_BLE_AD_TYPE_TX_PWR HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */
  296. #define BTM_BLE_AD_TYPE_DEV_CLASS 0x0D
  297. #define BTM_BLE_AD_TYPE_SM_TK 0x10
  298. #define BTM_BLE_AD_TYPE_SM_OOB_FLAG 0x11
  299. #define BTM_BLE_AD_TYPE_INT_RANGE 0x12
  300. #define BTM_BLE_AD_TYPE_SOL_SRV_UUID 0x14
  301. #define BTM_BLE_AD_TYPE_128SOL_SRV_UUID 0x15
  302. #define BTM_BLE_AD_TYPE_SERVICE_DATA 0x16
  303. #define BTM_BLE_AD_TYPE_PUBLIC_TARGET 0x17
  304. #define BTM_BLE_AD_TYPE_RANDOM_TARGET 0x18
  305. #define BTM_BLE_AD_TYPE_APPEARANCE 0x19
  306. #define BTM_BLE_AD_TYPE_ADV_INT 0x1a
  307. #define BTM_BLE_AD_TYPE_LE_DEV_ADDR 0x1b
  308. #define BTM_BLE_AD_TYPE_LE_ROLE 0x1c
  309. #define BTM_BLE_AD_TYPE_SPAIR_C256 0x1d
  310. #define BTM_BLE_AD_TYPE_SPAIR_R256 0x1e
  311. #define BTM_BLE_AD_TYPE_32SOL_SRV_UUID 0x1f
  312. #define BTM_BLE_AD_TYPE_32SERVICE_DATA 0x20
  313. #define BTM_BLE_AD_TYPE_128SERVICE_DATA 0x21
  314. #define BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM 0x22
  315. #define BTM_BLE_AD_TYPE_LE_SECURE_RANDOM 0x23
  316. #define BTM_BLE_AD_TYPE_URI 0x24
  317. #define BTM_BLE_AD_TYPE_INDOOR_POSITION 0x25
  318. #define BTM_BLE_AD_TYPE_TRANS_DISC_DATA 0x26
  319. #define BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE 0x27
  320. #define BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE 0x28
  321. #define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */
  322. typedef UINT8 tBTM_BLE_AD_TYPE;
  323. #define BTM_BLE_LONG_ADV_MAX_LEN 249
  324. /* Security settings used with L2CAP LE COC */
  325. #define BTM_SEC_LE_LINK_ENCRYPTED 0x01
  326. #define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02
  327. #define BTM_SEC_LE_LINK_PAIRED_WITH_MITM 0x04
  328. /* Min/max Preferred number of payload octets that the local Controller
  329. should include in a single Link Layer Data Channel PDU. */
  330. #define BTM_BLE_DATA_SIZE_MAX 0x00fb
  331. #define BTM_BLE_DATA_SIZE_MIN 0x001b
  332. /* Preferred maximum number of microseconds that the local Controller
  333. should use to transmit a single Link Layer Data Channel PDU. */
  334. #define BTM_BLE_DATA_TX_TIME_MIN 0x0148
  335. #if (BLE_50_FEATURE_SUPPORT == TRUE)
  336. #define BTM_BLE_DATA_TX_TIME_MAX 0x04290 // define by spec v5.0
  337. #else
  338. #define BTM_BLE_DATA_TX_TIME_MAX 0x0848
  339. #endif
  340. /* adv tx power level */
  341. #define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
  342. #define BTM_BLE_ADV_TX_POWER_MAX BTM_TX_POWER_LEVEL_MAX /* maximum tx power */
  343. typedef UINT8 tBTM_BLE_ADV_TX_POWER;
  344. /* adv tx power in dBm */
  345. typedef struct {
  346. UINT8 adv_inst_max; /* max adv instance supported in controller */
  347. UINT8 rpa_offloading;
  348. UINT16 tot_scan_results_strg;
  349. UINT8 max_irk_list_sz;
  350. UINT8 filter_support;
  351. UINT8 max_filter;
  352. UINT8 energy_support;
  353. BOOLEAN values_read;
  354. UINT16 version_supported;
  355. UINT16 total_trackable_advertisers;
  356. UINT8 extended_scan_support;
  357. UINT8 debug_logging_supported;
  358. } tBTM_BLE_VSC_CB;
  359. /* slave preferred connection interval range */
  360. typedef struct {
  361. UINT16 low;
  362. UINT16 hi;
  363. } tBTM_BLE_INT_RANGE;
  364. /* Service tag supported in the device */
  365. typedef struct {
  366. UINT8 num_service;
  367. BOOLEAN list_cmpl;
  368. UINT16 *p_uuid;
  369. } tBTM_BLE_SERVICE;
  370. /* 32 bits Service supported in the device */
  371. typedef struct {
  372. UINT8 num_service;
  373. BOOLEAN list_cmpl;
  374. UINT32 *p_uuid;
  375. } tBTM_BLE_32SERVICE;
  376. /* 128 bits Service supported in the device */
  377. typedef struct {
  378. BOOLEAN list_cmpl;
  379. UINT8 uuid128[MAX_UUID_SIZE];
  380. } tBTM_BLE_128SERVICE;
  381. typedef struct {
  382. UINT8 len;
  383. UINT8 *p_val;
  384. } tBTM_BLE_MANU;
  385. typedef struct {
  386. tBT_UUID service_uuid;
  387. UINT8 len;
  388. UINT8 *p_val;
  389. } tBTM_BLE_SERVICE_DATA;
  390. typedef struct {
  391. UINT8 adv_type;
  392. UINT8 len;
  393. UINT8 *p_val; /* number of len byte */
  394. } tBTM_BLE_PROP_ELEM;
  395. typedef struct {
  396. UINT8 num_elem;
  397. tBTM_BLE_PROP_ELEM *p_elem;
  398. } tBTM_BLE_PROPRIETARY;
  399. typedef struct {
  400. tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
  401. tBTM_BLE_MANU *p_manu; /* manufacturer data */
  402. tBTM_BLE_SERVICE *p_services; /* services */
  403. tBTM_BLE_128SERVICE *p_services_128b; /* 128 bits service */
  404. tBTM_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */
  405. tBTM_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */
  406. tBTM_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */
  407. tBTM_BLE_128SERVICE *p_sol_service_128b; /* List of 128 bit Service Solicitation UUIDs */
  408. tBTM_BLE_PROPRIETARY *p_proprietary;
  409. tBTM_BLE_SERVICE_DATA *p_service_data; /* service data */
  410. UINT16 appearance;
  411. UINT8 flag;
  412. UINT8 tx_power;
  413. } tBTM_BLE_ADV_DATA;
  414. #ifndef BTM_BLE_MULTI_ADV_MAX
  415. #define BTM_BLE_MULTI_ADV_MAX 16 /* controller returned adv_inst_max should be less
  416. than this number */
  417. #endif
  418. #define BTM_BLE_MULTI_ADV_INVALID 0
  419. #define BTM_BLE_MULTI_ADV_ENB_EVT 1
  420. #define BTM_BLE_MULTI_ADV_DISABLE_EVT 2
  421. #define BTM_BLE_MULTI_ADV_PARAM_EVT 3
  422. #define BTM_BLE_MULTI_ADV_DATA_EVT 4
  423. typedef UINT8 tBTM_BLE_MULTI_ADV_EVT;
  424. #define BTM_BLE_MULTI_ADV_DEFAULT_STD 0
  425. typedef struct {
  426. UINT16 adv_int_min;
  427. UINT16 adv_int_max;
  428. UINT8 adv_type;
  429. tBTM_BLE_ADV_CHNL_MAP channel_map;
  430. tBTM_BLE_AFP adv_filter_policy;
  431. tBTM_BLE_ADV_TX_POWER tx_power;
  432. } tBTM_BLE_ADV_PARAMS;
  433. typedef struct {
  434. UINT8 *p_sub_code; /* dynamic array to store sub code */
  435. UINT8 *p_inst_id; /* dynamic array to store instance id */
  436. UINT8 pending_idx;
  437. UINT8 next_idx;
  438. } tBTM_BLE_MULTI_ADV_OPQ;
  439. typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id,
  440. void *p_ref, tBTM_STATUS status);
  441. typedef struct {
  442. UINT8 inst_id;
  443. BOOLEAN in_use;
  444. UINT8 adv_evt;
  445. BD_ADDR rpa;
  446. TIMER_LIST_ENT raddr_timer_ent;
  447. tBTM_BLE_MULTI_ADV_CBACK *p_cback;
  448. void *p_ref;
  449. UINT8 index;
  450. } tBTM_BLE_MULTI_ADV_INST;
  451. typedef struct {
  452. UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
  453. int front;
  454. int rear;
  455. } tBTM_BLE_MULTI_ADV_INST_IDX_Q;
  456. typedef struct {
  457. tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
  458. tBTM_BLE_MULTI_ADV_OPQ op_q;
  459. } tBTM_BLE_MULTI_ADV_CB;
  460. typedef UINT8 tGATT_IF;
  461. typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value);
  462. typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format,
  463. UINT8 num_records, UINT16 total_len,
  464. UINT8 *p_rep_data, UINT8 status);
  465. typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status);
  466. #ifndef BTM_BLE_BATCH_SCAN_MAX
  467. #define BTM_BLE_BATCH_SCAN_MAX 5
  468. #endif
  469. #ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE
  470. #define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2
  471. #endif
  472. typedef enum {
  473. BTM_BLE_SCAN_INVALID_STATE = 0,
  474. BTM_BLE_SCAN_ENABLE_CALLED = 1,
  475. BTM_BLE_SCAN_ENABLED_STATE = 2,
  476. BTM_BLE_SCAN_DISABLE_CALLED = 3,
  477. BTM_BLE_SCAN_DISABLED_STATE = 4
  478. } tBTM_BLE_BATCH_SCAN_STATE;
  479. enum {
  480. BTM_BLE_DISCARD_OLD_ITEMS,
  481. BTM_BLE_DISCARD_LOWER_RSSI_ITEMS
  482. };
  483. typedef UINT8 tBTM_BLE_DISCARD_RULE;
  484. typedef struct {
  485. UINT8 sub_code[BTM_BLE_BATCH_SCAN_MAX];
  486. tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX];
  487. tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_SCAN_MAX];
  488. UINT8 pending_idx;
  489. UINT8 next_idx;
  490. } tBTM_BLE_BATCH_SCAN_OPQ;
  491. typedef struct {
  492. UINT8 rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  493. tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  494. UINT8 num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  495. UINT16 data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  496. UINT8 *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  497. UINT8 pending_idx;
  498. UINT8 next_idx;
  499. } tBTM_BLE_BATCH_SCAN_REP_Q;
  500. typedef struct {
  501. tBTM_BLE_BATCH_SCAN_STATE cur_state;
  502. tBTM_BLE_BATCH_SCAN_MODE scan_mode;
  503. UINT32 scan_interval;
  504. UINT32 scan_window;
  505. tBLE_ADDR_TYPE addr_type;
  506. tBTM_BLE_DISCARD_RULE discard_rule;
  507. tBTM_BLE_BATCH_SCAN_OPQ op_q;
  508. tBTM_BLE_BATCH_SCAN_REP_Q main_rep_q;
  509. tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback;
  510. tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
  511. tBTM_BLE_SCAN_REP_CBACK *p_scan_rep_cback;
  512. tBTM_BLE_REF_VALUE ref_value;
  513. } tBTM_BLE_BATCH_SCAN_CB;
  514. /// Ble scan duplicate type
  515. enum {
  516. BTM_BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */
  517. BTM_BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */
  518. BTM_BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */
  519. };
  520. /* filter selection bit index */
  521. #define BTM_BLE_PF_ADDR_FILTER 0
  522. #define BTM_BLE_PF_SRVC_DATA 1
  523. #define BTM_BLE_PF_SRVC_UUID 2
  524. #define BTM_BLE_PF_SRVC_SOL_UUID 3
  525. #define BTM_BLE_PF_LOCAL_NAME 4
  526. #define BTM_BLE_PF_MANU_DATA 5
  527. #define BTM_BLE_PF_SRVC_DATA_PATTERN 6
  528. #define BTM_BLE_PF_TYPE_ALL 7 /* when passed in payload filter type all, only clear action is applicable */
  529. #define BTM_BLE_PF_TYPE_MAX 8
  530. /* max number of filter spot for different filter type */
  531. #ifndef BTM_BLE_MAX_UUID_FILTER
  532. #define BTM_BLE_MAX_UUID_FILTER 8
  533. #endif
  534. #ifndef BTM_BLE_MAX_ADDR_FILTER
  535. #define BTM_BLE_MAX_ADDR_FILTER 8
  536. #endif
  537. #ifndef BTM_BLE_PF_STR_COND_MAX
  538. #define BTM_BLE_PF_STR_COND_MAX 4 /* apply to manu data , or local name */
  539. #endif
  540. #ifndef BTM_BLE_PF_STR_LEN_MAX
  541. #define BTM_BLE_PF_STR_LEN_MAX 29 /* match for first 29 bytes */
  542. #endif
  543. typedef UINT8 tBTM_BLE_PF_COND_TYPE;
  544. #define BTM_BLE_PF_LOGIC_OR 0
  545. #define BTM_BLE_PF_LOGIC_AND 1
  546. typedef UINT8 tBTM_BLE_PF_LOGIC_TYPE;
  547. #define BTM_BLE_PF_ENABLE 1
  548. #define BTM_BLE_PF_CONFIG 2
  549. typedef UINT8 tBTM_BLE_PF_ACTION;
  550. typedef UINT8 tBTM_BLE_PF_FILT_INDEX;
  551. typedef UINT8 tBTM_BLE_PF_AVBL_SPACE;
  552. #define BTM_BLE_PF_BRDCAST_ADDR_FILT 1
  553. #define BTM_BLE_PF_SERV_DATA_CHG_FILT 2
  554. #define BTM_BLE_PF_SERV_UUID 4
  555. #define BTM_BLE_PF_SERV_SOLC_UUID 8
  556. #define BTM_BLE_PF_LOC_NAME_CHECK 16
  557. #define BTM_BLE_PF_MANUF_NAME_CHECK 32
  558. #define BTM_BLE_PF_SERV_DATA_CHECK 64
  559. typedef UINT16 tBTM_BLE_PF_FEAT_SEL;
  560. #define BTM_BLE_PF_LIST_LOGIC_OR 1
  561. #define BTM_BLE_PF_LIST_LOGIC_AND 2
  562. typedef UINT16 tBTM_BLE_PF_LIST_LOGIC_TYPE;
  563. #define BTM_BLE_PF_FILT_LOGIC_OR 0
  564. #define BTM_BLE_PF_FILT_LOGIC_AND 1
  565. typedef UINT16 tBTM_BLE_PF_FILT_LOGIC_TYPE;
  566. typedef UINT8 tBTM_BLE_PF_RSSI_THRESHOLD;
  567. typedef UINT8 tBTM_BLE_PF_DELIVERY_MODE;
  568. typedef UINT16 tBTM_BLE_PF_TIMEOUT;
  569. typedef UINT8 tBTM_BLE_PF_TIMEOUT_CNT;
  570. typedef UINT16 tBTM_BLE_PF_ADV_TRACK_ENTRIES;
  571. typedef struct {
  572. tBTM_BLE_PF_FEAT_SEL feat_seln;
  573. tBTM_BLE_PF_LIST_LOGIC_TYPE logic_type;
  574. tBTM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type;
  575. tBTM_BLE_PF_RSSI_THRESHOLD rssi_high_thres;
  576. tBTM_BLE_PF_RSSI_THRESHOLD rssi_low_thres;
  577. tBTM_BLE_PF_DELIVERY_MODE dely_mode;
  578. tBTM_BLE_PF_TIMEOUT found_timeout;
  579. tBTM_BLE_PF_TIMEOUT lost_timeout;
  580. tBTM_BLE_PF_TIMEOUT_CNT found_timeout_cnt;
  581. tBTM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries;
  582. } tBTM_BLE_PF_FILT_PARAMS;
  583. enum {
  584. BTM_BLE_SCAN_COND_ADD,
  585. BTM_BLE_SCAN_COND_DELETE,
  586. BTM_BLE_SCAN_COND_CLEAR = 2
  587. };
  588. typedef UINT8 tBTM_BLE_SCAN_COND_OP;
  589. enum {
  590. BTM_BLE_FILT_ENABLE_DISABLE = 1,
  591. BTM_BLE_FILT_CFG = 2,
  592. BTM_BLE_FILT_ADV_PARAM = 3
  593. };
  594. typedef UINT8 tBTM_BLE_FILT_CB_EVT;
  595. /* BLE adv payload filtering config complete callback */
  596. typedef void (tBTM_BLE_PF_CFG_CBACK)(tBTM_BLE_PF_ACTION action, tBTM_BLE_SCAN_COND_OP cfg_op,
  597. tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_STATUS status,
  598. tBTM_BLE_REF_VALUE ref_value);
  599. typedef void (tBTM_BLE_PF_CMPL_CBACK) (tBTM_BLE_PF_CFG_CBACK);
  600. /* BLE adv payload filtering status setup complete callback */
  601. typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status,
  602. tBTM_BLE_REF_VALUE ref_value);
  603. /* BLE adv payload filtering param setup complete callback */
  604. typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type,
  605. tBTM_BLE_PF_AVBL_SPACE avbl_space,
  606. tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status);
  607. #if (BLE_50_FEATURE_SUPPORT == TRUE)
  608. #define MAX_BLE_ADV_INSTANCE 10
  609. #define MIN_BLE_PERIODIC_ADV_REPORT_LEN 7
  610. typedef struct {
  611. UINT8 inst_id;
  612. BOOLEAN configured;
  613. BOOLEAN legacy_pdu;
  614. BOOLEAN directed;
  615. BOOLEAN scannable;
  616. BOOLEAN connetable;
  617. } tBTM_BLE_EXTENDED_INST;
  618. typedef struct {
  619. tBTM_BLE_EXTENDED_INST inst[MAX_BLE_ADV_INSTANCE]; /* dynamic array to store adv instance */
  620. UINT8 scan_duplicate;
  621. } tBTM_BLE_EXTENDED_CB;
  622. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0)
  623. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1)
  624. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2)
  625. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3)
  626. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4)
  627. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5)
  628. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6)
  629. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F)
  630. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
  631. ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
  632. ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
  633. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
  634. ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
  635. ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED)
  636. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
  637. ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
  638. ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED)
  639. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
  640. ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
  641. #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY)
  642. typedef UINT16 tBTM_BLE_EXT_ADV_TYPE_MASK;
  643. #define BTM_BLE_GAP_PHY_1M 1
  644. #define BTM_BLE_GAP_PHY_2M 2
  645. #define BTM_BLE_GAP_PHY_CODED 3
  646. typedef UINT8 tBTM_BLE_GAP_PHY;
  647. #define BTM_BLE_GAP_PHY_NO_TX_PREF_MASK (0x01)
  648. #define BTM_BLE_GAP_PHY_NO_RX_PREF_MASK (0x02)
  649. #define BTM_BLE_GAP_PHY_1M_PREF_MASK (0x03)
  650. #define BTM_BLE_GAP_PHY_2M_PREF_MASK (0x04)
  651. #define BTM_BLE_GAP_PHY_CODED_PREF_MASK (0x05)
  652. typedef UINT8 tBTM_BLE_GAP_PHY_MASK;
  653. #define BTM_BLE_GAP_EXT_SCAN_UNCODE_MASK 0x01
  654. #define BTM_BLE_GAP_EXT_SCAN_CODE_MASK 0x02
  655. typedef UINT8 tBTM_BLE_EXT_SCAN_CFG_MASK;
  656. typedef struct {
  657. tBTM_BLE_EXT_ADV_TYPE_MASK type;
  658. UINT32 interval_min;
  659. UINT32 interval_max;
  660. tBTM_BLE_ADV_CHNL_MAP channel_map;
  661. tBLE_ADDR_TYPE own_addr_type;
  662. tBLE_ADDR_TYPE peer_addr_type;
  663. BD_ADDR peer_addr;
  664. tBTM_BLE_AFP filter_policy;
  665. INT8 tx_power;
  666. tBTM_BLE_GAP_PHY primary_phy;
  667. UINT8 max_skip;
  668. tBTM_BLE_GAP_PHY secondary_phy;
  669. UINT8 sid;
  670. BOOLEAN scan_req_notif;
  671. } tBTM_BLE_GAP_EXT_ADV_PARAMS;
  672. typedef struct {
  673. UINT8 instance;
  674. int duration;
  675. int max_events;
  676. } tBTM_BLE_EXT_ADV;
  677. typedef struct {
  678. tBLE_SCAN_MODE scan_type;
  679. UINT16 scan_interval;
  680. UINT16 scan_window;
  681. } tBTM_BLE_EXT_SCAN_CFG;
  682. typedef struct {
  683. tBLE_ADDR_TYPE own_addr_type;
  684. UINT8 filter_policy;
  685. UINT8 scan_duplicate;
  686. tBTM_BLE_EXT_SCAN_CFG_MASK cfg_mask;
  687. tBTM_BLE_EXT_SCAN_CFG uncoded_cfg;
  688. tBTM_BLE_EXT_SCAN_CFG coded_cfg;
  689. } tBTM_BLE_EXT_SCAN_PARAMS;
  690. typedef struct {
  691. UINT16 interval_min;
  692. UINT16 interval_max;
  693. UINT8 properties;
  694. } tBTM_BLE_Periodic_Adv_Params;
  695. typedef struct {
  696. UINT8 filter_policy;
  697. UINT8 sid;
  698. tBLE_ADDR_TYPE addr_type;
  699. BD_ADDR addr;
  700. UINT16 skip;
  701. UINT16 sync_timeout;
  702. } tBTM_BLE_Periodic_Sync_Params;
  703. typedef struct {
  704. uint8_t status;
  705. uint16_t conn_idx;
  706. uint8_t tx_phy;
  707. uint8_t rx_phy;
  708. } tBTM_BLE_UPDATE_PHY;
  709. #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
  710. typedef union {
  711. UINT16 uuid16_mask;
  712. UINT32 uuid32_mask;
  713. UINT8 uuid128_mask[LEN_UUID_128];
  714. } tBTM_BLE_PF_COND_MASK;
  715. typedef struct {
  716. tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */
  717. tBT_UUID uuid; /* UUID condition */
  718. tBTM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */
  719. tBTM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID mask */
  720. } tBTM_BLE_PF_UUID_COND;
  721. typedef struct {
  722. UINT8 data_len; /* <= 20 bytes */
  723. UINT8 *p_data;
  724. } tBTM_BLE_PF_LOCAL_NAME_COND;
  725. typedef struct {
  726. UINT16 company_id; /* company ID */
  727. UINT8 data_len; /* <= 20 bytes */
  728. UINT8 *p_pattern;
  729. UINT16 company_id_mask; /* UUID value mask */
  730. UINT8 *p_pattern_mask; /* Manufacturer data matching mask,
  731. same length as data pattern,
  732. set to all 0xff, match exact data */
  733. } tBTM_BLE_PF_MANU_COND;
  734. typedef struct {
  735. UINT16 uuid; /* service ID */
  736. UINT8 data_len; /* <= 20 bytes */
  737. UINT8 *p_pattern;
  738. UINT8 *p_pattern_mask; /* Service data matching mask, same length as data pattern,
  739. set to all 0xff, match exact data */
  740. } tBTM_BLE_PF_SRVC_PATTERN_COND;
  741. typedef union {
  742. tBLE_BD_ADDR target_addr;
  743. tBTM_BLE_PF_LOCAL_NAME_COND local_name; /* local name filtering */
  744. tBTM_BLE_PF_MANU_COND manu_data; /* manufacturer data filtering */
  745. tBTM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */
  746. tBTM_BLE_PF_UUID_COND solicitate_uuid; /* solicited service UUID filtering */
  747. tBTM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */
  748. } tBTM_BLE_PF_COND_PARAM;
  749. typedef struct {
  750. UINT8 action_ocf[BTM_BLE_PF_TYPE_MAX];
  751. tBTM_BLE_REF_VALUE ref_value[BTM_BLE_PF_TYPE_MAX];
  752. tBTM_BLE_PF_PARAM_CBACK *p_filt_param_cback[BTM_BLE_PF_TYPE_MAX];
  753. tBTM_BLE_PF_CFG_CBACK *p_scan_cfg_cback[BTM_BLE_PF_TYPE_MAX];
  754. UINT8 cb_evt[BTM_BLE_PF_TYPE_MAX];
  755. UINT8 pending_idx;
  756. UINT8 next_idx;
  757. } tBTM_BLE_ADV_FILTER_ADV_OPQ;
  758. #define BTM_BLE_MAX_FILTER_COUNTER (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */
  759. #ifndef BTM_CS_IRK_LIST_MAX
  760. #define BTM_CS_IRK_LIST_MAX 0x20
  761. #endif
  762. typedef struct {
  763. BOOLEAN in_use;
  764. BD_ADDR bd_addr;
  765. UINT8 pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */
  766. } tBTM_BLE_PF_COUNT;
  767. typedef struct {
  768. BOOLEAN enable;
  769. UINT8 op_type;
  770. tBTM_BLE_PF_COUNT *p_addr_filter_count; /* per BDA filter array */
  771. tBLE_BD_ADDR cur_filter_target;
  772. tBTM_BLE_PF_STATUS_CBACK *p_filt_stat_cback;
  773. tBTM_BLE_ADV_FILTER_ADV_OPQ op_q;
  774. } tBTM_BLE_ADV_FILTER_CB;
  775. /* Sub codes */
  776. #define BTM_BLE_META_PF_ENABLE 0x00
  777. #define BTM_BLE_META_PF_FEAT_SEL 0x01
  778. #define BTM_BLE_META_PF_ADDR 0x02
  779. #define BTM_BLE_META_PF_UUID 0x03
  780. #define BTM_BLE_META_PF_SOL_UUID 0x04
  781. #define BTM_BLE_META_PF_LOCAL_NAME 0x05
  782. #define BTM_BLE_META_PF_MANU_DATA 0x06
  783. #define BTM_BLE_META_PF_SRVC_DATA 0x07
  784. #define BTM_BLE_META_PF_ALL 0x08
  785. typedef UINT8 BTM_BLE_ADV_STATE;
  786. typedef UINT8 BTM_BLE_ADV_INFO_PRESENT;
  787. typedef UINT8 BTM_BLE_RSSI_VALUE;
  788. typedef UINT16 BTM_BLE_ADV_INFO_TIMESTAMP;
  789. /* These are the fields returned in each device adv packet. It
  790. ** is returned in the results callback if registered.
  791. */
  792. typedef struct {
  793. UINT8 conn_mode;
  794. tBTM_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */
  795. UINT8 flag;
  796. UINT8 tx_power_level;
  797. UINT8 remote_name_len;
  798. UINT8 *p_remote_name;
  799. tBTM_BLE_SERVICE service;
  800. } tBTM_BLE_INQ_DATA;
  801. enum {
  802. BTM_BLE_CONN_NONE,
  803. BTM_BLE_CONN_AUTO,
  804. BTM_BLE_CONN_SELECTIVE
  805. };
  806. typedef UINT8 tBTM_BLE_CONN_TYPE;
  807. #define ADV_INFO_PRESENT 0x00
  808. #define NO_ADV_INFO_PRESENT 0x01
  809. typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA;
  810. typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data);
  811. typedef UINT8 tBTM_BLE_TRACK_ADV_EVT;
  812. typedef struct {
  813. tBTM_BLE_REF_VALUE ref_value;
  814. tBTM_BLE_TRACK_ADV_CBACK *p_track_cback;
  815. } tBTM_BLE_ADV_TRACK_CB;
  816. enum {
  817. BTM_BLE_TRACK_ADV_ADD,
  818. BTM_BLE_TRACK_ADV_REMOVE
  819. };
  820. typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION;
  821. #define BTM_BLE_MULTI_ADV_INVALID 0
  822. #define BTM_BLE_BATCH_SCAN_ENABLE_EVT 1
  823. #define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT 2
  824. #define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3
  825. #define BTM_BLE_BATCH_SCAN_THR_EVT 4
  826. #define BTM_BLE_BATCH_SCAN_PARAM_EVT 5
  827. #define BTM_BLE_BATCH_SCAN_DISABLE_EVT 6
  828. typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT;
  829. typedef UINT32 tBTM_BLE_TX_TIME_MS;
  830. typedef UINT32 tBTM_BLE_RX_TIME_MS;
  831. typedef UINT32 tBTM_BLE_IDLE_TIME_MS;
  832. typedef UINT32 tBTM_BLE_ENERGY_USED;
  833. typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
  834. tBTM_BLE_IDLE_TIME_MS idle_time,
  835. tBTM_BLE_ENERGY_USED energy_used,
  836. tBTM_STATUS status);
  837. typedef struct {
  838. tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback;
  839. } tBTM_BLE_ENERGY_INFO_CB;
  840. typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
  841. typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status);
  842. /* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
  843. typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
  844. typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match);
  845. /* random address set complete callback */
  846. typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
  847. typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
  848. typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status);
  849. tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
  850. typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
  851. typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
  852. typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info);
  853. #if (BLE_50_FEATURE_SUPPORT == TRUE)
  854. #define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1
  855. #define BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT 2
  856. #define BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT 3
  857. #define BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT 4
  858. #define BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT 5
  859. #define BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT 6
  860. #define BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT 7
  861. #define BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT 8
  862. #define BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT 9
  863. #define BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT 10
  864. #define BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT 11
  865. #define BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT 12
  866. #define BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT 13
  867. #define BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT 14
  868. #define BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT 15
  869. #define BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT 16
  870. #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT 17
  871. #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT 18
  872. #define BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT 19
  873. #define BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT 20
  874. #define BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT 21
  875. #define BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT 22
  876. #define BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT 23
  877. #define BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT 24
  878. #define BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT 25
  879. #define BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT 26
  880. #define BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT 27
  881. #define BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT 28
  882. #define BTM_BLE_5_GAP_ADV_TERMINATED_EVT 29
  883. #define BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT 30
  884. #define BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT 31
  885. #define BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT 32
  886. #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT 33
  887. #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT 34
  888. #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  889. #define BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT 35
  890. #define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT 36
  891. #define BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT 37
  892. #define BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT 38
  893. #define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT 39
  894. #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  895. #define BTM_BLE_5_GAP_UNKNOWN_EVT 40
  896. typedef UINT8 tBTM_BLE_5_GAP_EVENT;
  897. #define BTM_BLE_EXT_ADV_DATA_COMPLETE 0x00
  898. #define BTM_BLE_EXT_ADV_DATA_INCOMPLETE 0x01
  899. #define BTM_BLE_EXT_ADV_DATA_TRUNCATED 0x02
  900. typedef UINT8 tBTM_BLE_EXT_ADV_DATA_STATUS;
  901. #define BTM_BLE_ADV_DATA_COMPLETE_MASK (0x0000)
  902. #define BTM_BLE_ADV_DATA_INCOMPLETE_MASK (0x0020)
  903. #define BTM_BLE_ADV_DATA_TRUNCATED_MASK (0x0040)
  904. #define BTM_BLE_ADV_DATA_STATUS_MASK (0x0060)
  905. //#define BTM_BLE_ADV_CONN_MASK (0x0001)
  906. //#define BTM_BLE_ADV_SCAN_MASK (0x0002)
  907. //#define BTM_BLE_ADV_DIRECT_MASK (0x0004)
  908. //#define BTM_BLE_SCAN_RSP_MASK (0x0008)
  909. #define BTM_BLE_ADV_LEGACY_MASK (0x0010)
  910. typedef UINT8 tBTM_BLE_ADV_MASK;
  911. // /* Advertising report */
  912. // #define BTM_BLE_ADV_REPORT_ADV_IND (0)
  913. // #define BTM_BLE_ADV_REPORT_DIR_IND (1)
  914. // #define BTM_BLE_ADV_REPORT_SCAN_IND (2)
  915. // #define BTM_BLE_ADV_REPORT_NONCONN_IND (3)
  916. // #define BTM_BLE_ADV_REPORT_SCAN_RSP (4)
  917. // /* Bluetooth 5.0, Vol 2, Part E, 7.7.65.13 */
  918. // #define BTM_BLE_LEGACY_ADV_TYPE_IND (0x13)
  919. // #define BTM_BLE_LEGACY_ADV_TYPE_DIRECT_IND (0x15)
  920. // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_IND (0x12)
  921. // #define BTM_BLE_LEGACY_ADV_TYPE_NONCON_IND (0x10)
  922. // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_IND (0x1b)
  923. // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_SCAN_IND (0x1a)
  924. typedef struct {
  925. UINT8 status;
  926. BD_ADDR addr;
  927. UINT8 tx_phy;
  928. UINT8 rx_phy;
  929. } tBTM_BLE_READ_PHY_CMPL;
  930. typedef struct {
  931. UINT8 status;
  932. } tBTM_BLE_SET_PREF_DEF_PHY_CMPL;
  933. typedef struct {
  934. UINT8 status;
  935. } tBTM_BLE_SET_PERF_PHY_CMPL;
  936. typedef struct {
  937. UINT8 status;
  938. } tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL;
  939. typedef struct {
  940. UINT8 status;
  941. } tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL;
  942. typedef struct {
  943. UINT8 status;
  944. } tBTM_BLE_EXT_ADV_DATA_SET_CMPL;
  945. typedef struct {
  946. UINT8 status;
  947. } tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL;
  948. typedef struct {
  949. UINT8 status;
  950. } tBTM_BLE_EXT_ADV_START_CMPL;
  951. typedef struct {
  952. UINT8 status;
  953. } tBTM_BLE_EXT_ADV_STOP_CMPL;
  954. typedef struct {
  955. UINT8 status;
  956. } tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL;
  957. typedef struct {
  958. UINT8 status;
  959. } tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL;
  960. typedef struct {
  961. UINT8 status;
  962. } tBTM_BLE_PERIOD_ADV_START_CMPL;
  963. typedef struct {
  964. UINT8 status;
  965. } tBTM_BLE_PERIOD_ADV_STOP_CMPL;
  966. typedef struct {
  967. UINT8 status;
  968. } tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL;
  969. typedef struct {
  970. UINT8 status;
  971. } tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL;
  972. typedef struct {
  973. UINT8 status;
  974. } tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL;
  975. typedef struct {
  976. UINT8 status;
  977. } tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL;
  978. typedef struct {
  979. UINT8 status;
  980. } tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL;
  981. typedef struct {
  982. UINT8 status;
  983. } tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL;
  984. typedef struct {
  985. UINT8 status;
  986. } tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL;
  987. typedef struct {
  988. UINT8 status;
  989. } tBTM_BLE_EXT_SCAN_START_CMPL;
  990. typedef struct {
  991. UINT8 status;
  992. } tBTM_BLE_EXT_SCAN_STOP_CMPL;
  993. typedef struct {
  994. UINT8 status;
  995. } tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL;
  996. typedef struct {
  997. uint8_t status;
  998. BD_ADDR addr;
  999. uint8_t tx_phy;
  1000. uint8_t rx_phy;
  1001. } tBTM_BLE_PHY_UPDATE_CMPL;
  1002. typedef struct {
  1003. // UINT8 props;
  1004. // UINT8 legacy_event_type;
  1005. UINT8 event_type;
  1006. tBLE_ADDR_TYPE addr_type;
  1007. BD_ADDR addr;
  1008. UINT8 primary_phy;
  1009. UINT8 secondry_phy;
  1010. UINT8 sid;
  1011. UINT8 tx_power;
  1012. UINT8 rssi;
  1013. UINT16 per_adv_interval;
  1014. tBLE_ADDR_TYPE dir_addr_type;
  1015. BD_ADDR dir_addr;
  1016. tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
  1017. UINT8 adv_data_len;
  1018. UINT8 *adv_data;
  1019. } tBTM_BLE_EXT_ADV_REPORT;
  1020. typedef struct {
  1021. UINT8 status;
  1022. UINT8 adv_handle;
  1023. UINT16 conn_handle;
  1024. UINT8 completed_event;
  1025. } tBTM_BLE_ADV_TERMINAT;
  1026. typedef struct {
  1027. UINT8 adv_handle;
  1028. tBLE_ADDR_TYPE scan_addr_type;
  1029. BD_ADDR scan_addr;
  1030. } tBTM_BLE_SCAN_REQ_RECEIVED;
  1031. typedef struct {
  1032. UINT16 conn_handle;
  1033. UINT8 channel_sel_alg;
  1034. } tBTM_BLE_CHANNEL_SEL_ALG;
  1035. typedef struct {
  1036. UINT16 sync_handle;
  1037. UINT8 tx_power;
  1038. INT8 rssi;
  1039. tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
  1040. UINT8 data_length;
  1041. UINT8 *data;
  1042. } tBTM_PERIOD_ADV_REPORT;
  1043. typedef struct {
  1044. UINT16 sync_handle;
  1045. } tBTM_BLE_PERIOD_ADV_SYNC_LOST;
  1046. typedef struct {
  1047. UINT8 status;
  1048. UINT16 sync_handle;
  1049. UINT8 sid;
  1050. tBLE_ADDR_TYPE adv_addr_type;
  1051. BD_ADDR adv_addr;
  1052. UINT8 adv_phy;
  1053. UINT16 period_adv_interval;
  1054. UINT8 adv_clk_accuracy;
  1055. } tBTM_BLE_PERIOD_ADV_SYNC_ESTAB;
  1056. typedef struct {
  1057. UINT16 scan_interval;
  1058. UINT16 scan_window;
  1059. UINT16 interval_min;
  1060. UINT16 interval_max;
  1061. UINT16 latency;
  1062. UINT16 supervision_timeout;
  1063. UINT16 min_ce_len;
  1064. UINT16 max_ce_len;
  1065. } tBTM_BLE_CONN_PARAMS;
  1066. #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  1067. typedef struct {
  1068. UINT8 status;
  1069. } tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL;
  1070. typedef struct {
  1071. UINT8 status;
  1072. BD_ADDR addr;
  1073. } tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL;
  1074. typedef struct {
  1075. UINT8 status;
  1076. BD_ADDR addr;
  1077. } tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL;
  1078. typedef struct {
  1079. UINT8 status;
  1080. BD_ADDR addr;
  1081. } tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL;
  1082. typedef struct {
  1083. UINT8 status;
  1084. BD_ADDR addr;
  1085. UINT16 service_data;
  1086. UINT16 sync_handle;
  1087. UINT8 adv_sid;
  1088. UINT8 adv_addr_type;
  1089. BD_ADDR adv_addr;
  1090. UINT8 adv_phy;
  1091. UINT16 adv_interval;
  1092. UINT8 adv_clk_accuracy;
  1093. } tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV;
  1094. #endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  1095. typedef union {
  1096. UINT8 status;
  1097. tBTM_BLE_READ_PHY_CMPL read_phy;
  1098. tBTM_BLE_SET_PREF_DEF_PHY_CMPL set_perf_def_phy;
  1099. tBTM_BLE_SET_PERF_PHY_CMPL set_perf_phy;
  1100. tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL set_ext_rand_addr;
  1101. tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL set_params;
  1102. tBTM_BLE_EXT_ADV_DATA_SET_CMPL adv_data_set;
  1103. tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL scan_rsp_data_set;
  1104. tBTM_BLE_EXT_ADV_START_CMPL adv_start;
  1105. tBTM_BLE_EXT_ADV_STOP_CMPL adv_stop;
  1106. tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL per_adv_set_params;
  1107. tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL per_adv_data_set;
  1108. tBTM_BLE_PERIOD_ADV_START_CMPL per_adv_start;
  1109. tBTM_BLE_PERIOD_ADV_STOP_CMPL per_adv_stop;
  1110. tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL per_adv_sync_create;
  1111. tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL per_adv_sync_cancel;
  1112. tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL per_adv_sync_term;
  1113. tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL per_adv_add_dev;
  1114. tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL per_adv_remove_dev;
  1115. tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL per_adv_clear_dev;
  1116. tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL ext_scan;
  1117. tBTM_BLE_EXT_SCAN_START_CMPL scan_start;
  1118. tBTM_BLE_EXT_SCAN_STOP_CMPL scan_stop;
  1119. tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL ext_conn_set_params;
  1120. tBTM_BLE_PHY_UPDATE_CMPL phy_update;
  1121. tBTM_BLE_EXT_ADV_REPORT ext_adv_report;
  1122. tBTM_BLE_ADV_TERMINAT adv_term;
  1123. tBTM_BLE_SCAN_REQ_RECEIVED scan_req;
  1124. tBTM_BLE_CHANNEL_SEL_ALG channel_sel;
  1125. tBTM_PERIOD_ADV_REPORT period_adv_report;
  1126. tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost;
  1127. tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab;
  1128. #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  1129. tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL per_adv_recv_enable;
  1130. tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL per_adv_sync_trans;
  1131. tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL per_adv_set_info_trans;
  1132. tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL set_past_params;
  1133. tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV past_recv;
  1134. #endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  1135. } tBTM_BLE_5_GAP_CB_PARAMS;
  1136. typedef struct {
  1137. UINT8 phy_mask;
  1138. tBTM_BLE_CONN_PARAMS phy_1m_conn_params;
  1139. tBTM_BLE_CONN_PARAMS phy_2m_conn_params;
  1140. tBTM_BLE_CONN_PARAMS phy_coded_conn_params;
  1141. } tBTM_EXT_CONN_PARAMS;
  1142. typedef void (*tBTM_BLE_5_HCI_CBACK)(tBTM_BLE_5_GAP_EVENT event, tBTM_BLE_5_GAP_CB_PARAMS *params);
  1143. #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
  1144. /*****************************************************************************
  1145. ** EXTERNAL FUNCTION DECLARATIONS
  1146. *****************************************************************************/
  1147. /*
  1148. #ifdef __cplusplus
  1149. extern "C" {
  1150. #endif
  1151. */
  1152. /*******************************************************************************
  1153. **
  1154. ** Function BTM_BleRegiseterConnParamCallback
  1155. **
  1156. ** Description register connection parameters update callback func
  1157. **
  1158. ** Parameters: update_conn_param_cb
  1159. **
  1160. ** Returns void
  1161. **
  1162. *******************************************************************************/
  1163. void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
  1164. /*******************************************************************************
  1165. **
  1166. ** Function BTM_SecAddBleDevice
  1167. **
  1168. ** Description Add/modify device. This function will be normally called
  1169. ** during host startup to restore all required information
  1170. ** for a LE device stored in the NVRAM.
  1171. **
  1172. ** Parameters: bd_addr - BD address of the peer
  1173. ** bd_name - Name of the peer device. NULL if unknown.
  1174. ** dev_type - Remote device's device type.
  1175. ** addr_type - LE device address type.
  1176. ** auth_mode - auth mode
  1177. **
  1178. ** Returns TRUE if added OK, else FALSE
  1179. **
  1180. *******************************************************************************/
  1181. //extern
  1182. BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
  1183. tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type, UINT32 auth_mode);
  1184. /*******************************************************************************
  1185. **
  1186. ** Function BTM_SecAddBleKey
  1187. **
  1188. ** Description Add/modify LE device information. This function will be
  1189. ** normally called during host startup to restore all required
  1190. ** information stored in the NVRAM.
  1191. **
  1192. ** Parameters: bd_addr - BD address of the peer
  1193. ** p_le_key - LE key values.
  1194. ** key_type - LE SMP key type.
  1195. *
  1196. ** Returns TRUE if added OK, else FALSE
  1197. **
  1198. *******************************************************************************/
  1199. //extern
  1200. BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
  1201. tBTM_LE_KEY_TYPE key_type);
  1202. /*******************************************************************************
  1203. **
  1204. ** Function BTM_BleSetAdvParams
  1205. **
  1206. ** Description This function is called to set advertising parameters.
  1207. **
  1208. ** Parameters: None.
  1209. **
  1210. ** Returns void
  1211. **
  1212. *******************************************************************************/
  1213. //extern
  1214. tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
  1215. tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
  1216. /*******************************************************************************
  1217. **
  1218. ** Function BTM_BleSetAdvParamsAll
  1219. **
  1220. ** Description This function is called to set all of the advertising parameters.
  1221. **
  1222. ** Parameters: None.
  1223. **
  1224. ** Returns void
  1225. **
  1226. *******************************************************************************/
  1227. tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
  1228. tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
  1229. tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb);
  1230. /*******************************************************************************
  1231. **
  1232. ** Function BTM_BleStartAdv
  1233. **
  1234. ** Description This function is called to start adv.
  1235. **
  1236. ** Parameters: None.
  1237. **
  1238. ** Returns status
  1239. **
  1240. *******************************************************************************/
  1241. tBTM_STATUS BTM_BleStartAdv(void);
  1242. /*******************************************************************************
  1243. **
  1244. ** Function BTM_BleWriteAdvData
  1245. **
  1246. ** Description This function is called to write advertising data.
  1247. **
  1248. ** Parameters: None.
  1249. **
  1250. ** Returns void
  1251. **
  1252. *******************************************************************************/
  1253. //extern
  1254. tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
  1255. tBTM_BLE_ADV_DATA *p_data);
  1256. /*******************************************************************************
  1257. **
  1258. ** Function BTM_BleWriteLongAdvData
  1259. **
  1260. ** Description This function is called to write long advertising data.
  1261. **
  1262. ** Parameters: adv_data: long advertising data
  1263. ** adv_data_len: the length of long advertising data
  1264. **
  1265. ** Returns void
  1266. **
  1267. *******************************************************************************/
  1268. tBTM_STATUS BTM_BleWriteLongAdvData(uint8_t *adv_data, uint8_t adv_data_len);
  1269. /*******************************************************************************
  1270. **
  1271. ** Function BTM_BleWriteAdvDataRaw
  1272. **
  1273. ** Description This function is called to write raw advertising data.
  1274. **
  1275. ** Parameters: p_raw_adv : point to raw advertising data
  1276. ** raw_adv_len : raw advertising data
  1277. **
  1278. ** Returns BTM_SUCCESS means success.
  1279. **
  1280. *******************************************************************************/
  1281. //extern
  1282. tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
  1283. tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr);
  1284. void BTM_BleClearRandAddress(void);
  1285. /*******************************************************************************
  1286. **
  1287. ** Function BTM_BleSetAdvParams
  1288. **
  1289. ** Description This function is called to set advertising parameters.
  1290. **
  1291. ** Parameters adv_int_min: minimum advertising interval
  1292. ** adv_int_max: maximum advertising interval
  1293. ** p_dir_bda: connectable direct initiator's LE device address
  1294. ** chnl_map: advertising channel map.
  1295. **
  1296. ** Returns void
  1297. **
  1298. *******************************************************************************/
  1299. //extern
  1300. void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max,
  1301. tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map);
  1302. /*******************************************************************************
  1303. **
  1304. ** Function BTM_BleObtainVendorCapabilities
  1305. **
  1306. ** Description This function is called to obtain vendor capabilities
  1307. **
  1308. ** Parameters p_cmn_vsc_cb - Returns the vendor capabilities
  1309. **
  1310. ** Returns void
  1311. **
  1312. *******************************************************************************/
  1313. //extern
  1314. void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
  1315. /*******************************************************************************
  1316. **
  1317. ** Function BTM_BleSetScanParams
  1318. **
  1319. ** Description This function is called to set Scan parameters.
  1320. **
  1321. ** Parameters client_if - Client IF value
  1322. ** scan_interval - Scan interval
  1323. ** scan_window - Scan window
  1324. ** scan_type - Scan type
  1325. ** scan_setup_status_cback - Scan setup status callback
  1326. **
  1327. ** Returns void
  1328. **
  1329. *******************************************************************************/
  1330. //extern
  1331. void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval,
  1332. UINT32 scan_window, tBLE_SCAN_MODE scan_type,
  1333. tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
  1334. /*******************************************************************************
  1335. **
  1336. ** Function BTM_BleSetScanFilterParams
  1337. **
  1338. ** Description This function is called to set Scan Filter & parameters.
  1339. **
  1340. ** Parameters client_if - Client IF value
  1341. ** scan_interval - Scan interval
  1342. ** scan_window - Scan window
  1343. ** scan_type - Scan type
  1344. ** addr_type_own - owner address type
  1345. ** scan_duplicate_filter - scan duplicate filter
  1346. ** scan_filter_policy - scan filter policy
  1347. ** scan_setup_status_cback - Scan setup status callback
  1348. **
  1349. ** Returns void
  1350. **
  1351. *******************************************************************************/
  1352. tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
  1353. tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy,
  1354. tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
  1355. /*******************************************************************************
  1356. **
  1357. ** Function BTM_BleGetVendorCapabilities
  1358. **
  1359. ** Description This function reads local LE features
  1360. **
  1361. ** Parameters p_cmn_vsc_cb : Locala LE capability structure
  1362. **
  1363. ** Returns void
  1364. **
  1365. *******************************************************************************/
  1366. //extern
  1367. void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
  1368. /*******************************************************************************
  1369. **
  1370. ** Function BTM_BleSetStorageConfig
  1371. **
  1372. ** Description This function is called to setup storage configuration and setup callbacks.
  1373. **
  1374. ** Parameters UINT8 batch_scan_full_max -Batch scan full maximum
  1375. UINT8 batch_scan_trunc_max - Batch scan truncated value maximum
  1376. UINT8 batch_scan_notify_threshold - Threshold value
  1377. tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback
  1378. tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback
  1379. void *p_ref - Reference value
  1380. **
  1381. ** Returns tBTM_STATUS
  1382. **
  1383. *******************************************************************************/
  1384. //extern
  1385. tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max,
  1386. UINT8 batch_scan_trunc_max,
  1387. UINT8 batch_scan_notify_threshold,
  1388. tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback,
  1389. tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
  1390. tBTM_BLE_SCAN_REP_CBACK *p_cback,
  1391. tBTM_BLE_REF_VALUE ref_value);
  1392. /*******************************************************************************
  1393. **
  1394. ** Function BTM_BleEnableBatchScan
  1395. **
  1396. ** Description This function is called to enable batch scan
  1397. **
  1398. ** Parameters tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode
  1399. UINT32 scan_interval -Scan interval
  1400. UINT32 scan_window - Scan window value
  1401. tBLE_ADDR_TYPE addr_type - Address type
  1402. tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules
  1403. **
  1404. ** Returns tBTM_STATUS
  1405. **
  1406. *******************************************************************************/
  1407. //extern
  1408. tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
  1409. UINT32 scan_interval, UINT32 scan_window,
  1410. tBTM_BLE_DISCARD_RULE discard_rule,
  1411. tBLE_ADDR_TYPE addr_type,
  1412. tBTM_BLE_REF_VALUE ref_value);
  1413. /*******************************************************************************
  1414. **
  1415. ** Function BTM_BleDisableBatchScan
  1416. **
  1417. ** Description This function is called to disable batch scanning
  1418. **
  1419. ** Parameters void
  1420. **
  1421. ** Returns void
  1422. **
  1423. *******************************************************************************/
  1424. //extern
  1425. tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value);
  1426. /*******************************************************************************
  1427. **
  1428. ** Function BTM_BleReadScanReports
  1429. **
  1430. ** Description This function is called to read batch scan reports
  1431. **
  1432. ** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out
  1433. tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback
  1434. **
  1435. ** Returns tBTM_STATUS
  1436. **
  1437. *******************************************************************************/
  1438. //extern
  1439. tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
  1440. tBTM_BLE_REF_VALUE ref_value);
  1441. /*******************************************************************************
  1442. **
  1443. ** Function BTM_BleTrackAdvertiser
  1444. **
  1445. ** Description This function is called to read batch scan reports
  1446. **
  1447. ** Parameters p_track_cback - Tracking callback
  1448. ** ref_value - Reference value
  1449. **
  1450. ** Returns tBTM_STATUS
  1451. **
  1452. *******************************************************************************/
  1453. //extern
  1454. tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
  1455. tBTM_BLE_REF_VALUE ref_value);
  1456. /*******************************************************************************
  1457. **
  1458. ** Function BTM_BleWriteScanRsp
  1459. **
  1460. ** Description This function is called to write LE scan response.
  1461. **
  1462. ** Parameters: p_scan_rsp: scan response.
  1463. **
  1464. ** Returns status
  1465. **
  1466. *******************************************************************************/
  1467. //extern
  1468. tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
  1469. tBTM_BLE_ADV_DATA *p_data);
  1470. /*******************************************************************************
  1471. **
  1472. ** Function BTM_BleWriteScanRspRaw
  1473. **
  1474. ** Description This function is called to write raw scan response data
  1475. **
  1476. ** Parameters: None.
  1477. **
  1478. ** Returns void
  1479. **
  1480. *******************************************************************************/
  1481. //extern
  1482. tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
  1483. /*******************************************************************************
  1484. **
  1485. ** Function BTM_BleObserve
  1486. **
  1487. ** Description This procedure keep the device listening for advertising
  1488. ** events from a broadcast device.
  1489. **
  1490. ** Parameters start: start or stop observe.
  1491. **
  1492. ** Returns void
  1493. **
  1494. *******************************************************************************/
  1495. //extern
  1496. tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
  1497. tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
  1498. /*******************************************************************************
  1499. **
  1500. ** Function BTM_BleScan
  1501. **
  1502. ** Description This procedure keep the device listening for advertising
  1503. ** events from a broadcast device.
  1504. **
  1505. ** Parameters start: start or stop scan.
  1506. **
  1507. ** Returns void
  1508. **
  1509. *******************************************************************************/
  1510. //extern
  1511. tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
  1512. tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb);
  1513. /*******************************************************************************
  1514. **
  1515. ** Function BTM_GetDeviceIDRoot
  1516. **
  1517. ** Description This function is called to read the local device identity
  1518. ** root.
  1519. **
  1520. ** Returns void
  1521. ** the local device ER is copied into er
  1522. **
  1523. *******************************************************************************/
  1524. //extern
  1525. void BTM_GetDeviceIDRoot (BT_OCTET16 ir);
  1526. /*******************************************************************************
  1527. **
  1528. ** Function BTM_GetDeviceEncRoot
  1529. **
  1530. ** Description This function is called to read the local device encryption
  1531. ** root.
  1532. **
  1533. ** Returns void
  1534. ** the local device ER is copied into er
  1535. **
  1536. *******************************************************************************/
  1537. //extern
  1538. void BTM_GetDeviceEncRoot (BT_OCTET16 er);
  1539. /*******************************************************************************
  1540. **
  1541. ** Function BTM_GetDeviceDHK
  1542. **
  1543. ** Description This function is called to read the local device DHK.
  1544. **
  1545. ** Returns void
  1546. ** the local device DHK is copied into dhk
  1547. **
  1548. *******************************************************************************/
  1549. //extern
  1550. void BTM_GetDeviceDHK (BT_OCTET16 dhk);
  1551. /*******************************************************************************
  1552. **
  1553. ** Function BTM_SecurityGrant
  1554. **
  1555. ** Description This function is called to grant security process.
  1556. **
  1557. ** Parameters bd_addr - peer device bd address.
  1558. ** res - result of the operation BTM_SUCCESS if success.
  1559. ** Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts.
  1560. **
  1561. ** Returns None
  1562. **
  1563. *******************************************************************************/
  1564. //extern
  1565. void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
  1566. /*******************************************************************************
  1567. **
  1568. ** Function BTM_BlePasskeyReply
  1569. **
  1570. ** Description This function is called after Security Manager submitted
  1571. ** passkey request to the application.
  1572. **
  1573. ** Parameters: bd_addr - Address of the device for which passkey was requested
  1574. ** res - result of the operation SMP_SUCCESS if success
  1575. ** passkey - numeric value in the range of
  1576. ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
  1577. **
  1578. *******************************************************************************/
  1579. //extern
  1580. void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
  1581. /*******************************************************************************
  1582. **
  1583. ** Function BTM_BleSetStaticPasskey
  1584. **
  1585. ** Description This function is called to set static passkey
  1586. **
  1587. **
  1588. ** Parameters: add - set static passkey when add is TRUE
  1589. ** clear static passkey when add is FALSE
  1590. ** passkey - static passkey
  1591. **
  1592. **
  1593. *******************************************************************************/
  1594. void BTM_BleSetStaticPasskey(BOOLEAN add, UINT32 passkey);
  1595. /*******************************************************************************
  1596. **
  1597. ** Function BTM_BleConfirmReply
  1598. **
  1599. ** Description This function is called after Security Manager submitted
  1600. ** numeric comparison request to the application.
  1601. **
  1602. ** Parameters: bd_addr - Address of the device with which numeric
  1603. ** comparison was requested
  1604. ** res - comparison result BTM_SUCCESS if success
  1605. **
  1606. *******************************************************************************/
  1607. //extern
  1608. void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res);
  1609. /*******************************************************************************
  1610. **
  1611. ** Function BTM_LeOobDataReply
  1612. **
  1613. ** Description This function is called to provide the OOB data for
  1614. ** SMP in response to BTM_LE_OOB_REQ_EVT
  1615. **
  1616. ** Parameters: bd_addr - Address of the peer device
  1617. ** res - result of the operation SMP_SUCCESS if success
  1618. ** p_data - simple pairing Randomizer C.
  1619. **
  1620. *******************************************************************************/
  1621. //extern
  1622. void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
  1623. /*******************************************************************************
  1624. **
  1625. ** Function BTM_BleSecureConnectionOobDataReply
  1626. **
  1627. ** Description This function is called to provide the OOB data for
  1628. ** SMP in response to BTM_LE_SC_OOB_REQ_EVT when secure connection
  1629. **
  1630. ** Parameters: bd_addr - Address of the peer device
  1631. ** p_c - pointer to Confirmation
  1632. ** p_r - pointer to Randomizer
  1633. **
  1634. *******************************************************************************/
  1635. void BTM_BleSecureConnectionOobDataReply(BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r);
  1636. /*******************************************************************************
  1637. **
  1638. ** Function BTM_BleSecureConnectionCreateOobData
  1639. **
  1640. ** Description This function is called to create the OOB data for
  1641. ** SMP when secure connection
  1642. **
  1643. *******************************************************************************/
  1644. void BTM_BleSecureConnectionCreateOobData(void);
  1645. /*******************************************************************************
  1646. **
  1647. ** Function BTM_BleDataSignature
  1648. **
  1649. ** Description This function is called to sign the data using AES128 CMAC
  1650. ** algorith.
  1651. **
  1652. ** Parameter bd_addr: target device the data to be signed for.
  1653. ** p_text: singing data
  1654. ** len: length of the signing data
  1655. ** signature: output parameter where data signature is going to
  1656. ** be stored.
  1657. **
  1658. ** Returns TRUE if signing sucessul, otherwise FALSE.
  1659. **
  1660. *******************************************************************************/
  1661. //extern
  1662. BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
  1663. BLE_SIGNATURE signature);
  1664. /*******************************************************************************
  1665. **
  1666. ** Function BTM_BleVerifySignature
  1667. **
  1668. ** Description This function is called to verify the data signature
  1669. **
  1670. ** Parameter bd_addr: target device the data to be signed for.
  1671. ** p_orig: original data before signature.
  1672. ** len: length of the signing data
  1673. ** counter: counter used when doing data signing
  1674. ** p_comp: signature to be compared against.
  1675. ** Returns TRUE if signature verified correctly; otherwise FALSE.
  1676. **
  1677. *******************************************************************************/
  1678. //extern
  1679. BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig,
  1680. UINT16 len, UINT32 counter,
  1681. UINT8 *p_comp);
  1682. /*******************************************************************************
  1683. **
  1684. ** Function BTM_ReadConnectionAddr
  1685. **
  1686. ** Description This function is called to set the local device random address
  1687. ** .
  1688. **
  1689. ** Returns void
  1690. **
  1691. *******************************************************************************/
  1692. //extern
  1693. void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr,
  1694. tBLE_ADDR_TYPE *p_addr_type);
  1695. /*******************************************************************************
  1696. **
  1697. ** Function BTM_ReadRemoteConnectionAddr
  1698. **
  1699. ** Description This function is read the remote device address currently used
  1700. ** .
  1701. **
  1702. ** Returns void
  1703. **
  1704. *******************************************************************************/
  1705. //extern
  1706. BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr,
  1707. BD_ADDR conn_addr,
  1708. tBLE_ADDR_TYPE *p_addr_type);
  1709. /*******************************************************************************
  1710. **
  1711. ** Function BTM_BleLoadLocalKeys
  1712. **
  1713. ** Description Local local identity key, encryption root or sign counter.
  1714. **
  1715. ** Parameters: key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER
  1716. ** or BTM_BLE_KEY_TYPE_COUNTER.
  1717. ** p_key: pointer to the key.
  1718. *
  1719. ** Returns non2.
  1720. **
  1721. *******************************************************************************/
  1722. //extern
  1723. void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
  1724. /*******************************************************************************
  1725. **
  1726. ** Function BTM_BleSetBgConnType
  1727. **
  1728. ** Description This function is called to set BLE background connection
  1729. ** procedure type. It can be auto connection, or selective connection.
  1730. **
  1731. ** Parameters conn_type: it can be auto connection, or selective connection.
  1732. ** p_select_cback: callback function when selective connection procedure
  1733. ** is being used.
  1734. **
  1735. ** Returns void
  1736. **
  1737. *******************************************************************************/
  1738. //extern
  1739. BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type,
  1740. tBTM_BLE_SEL_CBACK *p_select_cback);
  1741. /*******************************************************************************
  1742. **
  1743. ** Function BTM_BleUpdateBgConnDev
  1744. **
  1745. ** Description This function is called to add or remove a device into/from
  1746. ** background connection procedure. The background connection
  1747. * procedure is decided by the background connection type, it can be
  1748. * auto connection, or selective connection.
  1749. **
  1750. ** Parameters add_remove: TRUE to add; FALSE to remove.
  1751. ** remote_bda: device address to add/remove.
  1752. **
  1753. ** Returns void
  1754. **
  1755. *******************************************************************************/
  1756. //extern
  1757. BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda);
  1758. /*******************************************************************************
  1759. **
  1760. ** Function BTM_BleClearBgConnDev
  1761. **
  1762. ** Description This function is called to clear the whitelist,
  1763. ** end any pending whitelist connections,
  1764. * and reset the local bg device list.
  1765. **
  1766. ** Parameters void
  1767. **
  1768. ** Returns void
  1769. **
  1770. *******************************************************************************/
  1771. //extern
  1772. void BTM_BleClearBgConnDev(void);
  1773. /********************************************************
  1774. **
  1775. ** Function BTM_BleSetPrefConnParams
  1776. **
  1777. ** Description Set a peripheral's preferred connection parameters. When
  1778. ** any of the value does not want to be updated while others
  1779. ** do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
  1780. ** leave untouched.
  1781. **
  1782. ** Parameters: bd_addr - BD address of the peripheral
  1783. ** min_conn_int - minimum preferred connection interval
  1784. ** max_conn_int - maximum preferred connection interval
  1785. ** slave_latency - preferred slave latency
  1786. ** supervision_tout - preferred supervision timeout
  1787. **
  1788. ** Returns void
  1789. **
  1790. *******************************************************************************/
  1791. //extern
  1792. void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
  1793. UINT16 min_conn_int, UINT16 max_conn_int,
  1794. UINT16 slave_latency, UINT16 supervision_tout);
  1795. /******************************************************************************
  1796. **
  1797. ** Function BTM_BleSetConnScanParams
  1798. **
  1799. ** Description Set scan parameters used in BLE connection request
  1800. **
  1801. ** Parameters: scan_interval - scan interval
  1802. ** scan_window - scan window
  1803. **
  1804. ** Returns void
  1805. **
  1806. *******************************************************************************/
  1807. //extern
  1808. void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window);
  1809. /******************************************************************************
  1810. **
  1811. ** Function BTM_BleReadControllerFeatures
  1812. **
  1813. ** Description Reads BLE specific controller features
  1814. **
  1815. ** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
  1816. **
  1817. ** Returns void
  1818. **
  1819. *******************************************************************************/
  1820. //extern
  1821. void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
  1822. /*******************************************************************************
  1823. **
  1824. ** Function BTM_CheckAdvData
  1825. **
  1826. ** Description This function is called to get ADV data for a specific type.
  1827. **
  1828. ** Parameters p_adv - pointer of ADV data
  1829. ** type - finding ADV data type
  1830. ** p_length - return the length of ADV data not including type
  1831. **
  1832. ** Returns pointer of ADV data
  1833. **
  1834. *******************************************************************************/
  1835. //extern
  1836. UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
  1837. /*******************************************************************************
  1838. **
  1839. ** Function BTM_BleGetCurrentAddress
  1840. **
  1841. ** Description This function is called to get local used BLE address.
  1842. **
  1843. ** Parameters: None.
  1844. **
  1845. ** Returns success or fail
  1846. **
  1847. *******************************************************************************/
  1848. BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type);
  1849. /*******************************************************************************
  1850. **
  1851. ** Function BTM__BLEReadDiscoverability
  1852. **
  1853. ** Description This function is called to read the current LE discoverability
  1854. ** mode of the device.
  1855. **
  1856. ** Returns BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
  1857. ** BTM_BLE_GENRAL_DISCOVERABLE
  1858. **
  1859. *******************************************************************************/
  1860. UINT16 BTM_BleReadDiscoverability(void);
  1861. /*******************************************************************************
  1862. **
  1863. ** Function BTM__BLEReadConnectability
  1864. **
  1865. ** Description This function is called to read the current LE connectibility
  1866. ** mode of the device.
  1867. **
  1868. ** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
  1869. **
  1870. *******************************************************************************/
  1871. //extern
  1872. UINT16 BTM_BleReadConnectability (void);
  1873. void BTM_Recovery_Pre_State(void);
  1874. /*******************************************************************************
  1875. **
  1876. ** Function BTM_ReadDevInfo
  1877. **
  1878. ** Description This function is called to read the device/address type
  1879. ** of BD address.
  1880. **
  1881. ** Parameter remote_bda: remote device address
  1882. ** p_dev_type: output parameter to read the device type.
  1883. ** p_addr_type: output parameter to read the address type.
  1884. **
  1885. *******************************************************************************/
  1886. //extern
  1887. void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type,
  1888. tBLE_ADDR_TYPE *p_addr_type);
  1889. /*******************************************************************************
  1890. **
  1891. ** Function BTM_ReadConnectedTransportAddress
  1892. **
  1893. ** Description This function is called to read the paired device/address type of other device paired
  1894. ** corresponding to the BD_address
  1895. **
  1896. ** Parameter remote_bda: remote device address, carry out the transport address
  1897. ** transport: active transport
  1898. **
  1899. ** Return TRUE if an active link is identified; FALSE otherwise
  1900. **
  1901. *******************************************************************************/
  1902. //extern
  1903. BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
  1904. tBT_TRANSPORT transport);
  1905. /*******************************************************************************
  1906. **
  1907. ** Function BTM_BleBroadcast
  1908. **
  1909. ** Description This function is to start or stop broadcasting.
  1910. **
  1911. ** Parameters start: start or stop broadcasting.
  1912. **
  1913. ** Returns status.
  1914. **
  1915. *******************************************************************************/
  1916. //extern
  1917. tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback);
  1918. /*******************************************************************************
  1919. **
  1920. ** Function BTM_BleConfigPrivacy
  1921. **
  1922. ** Description This function is called to enable or disable the privacy in
  1923. ** the local device.
  1924. **
  1925. ** Parameters enable: TRUE to enable it; FALSE to disable it.
  1926. **
  1927. ** Returns BOOLEAN privacy mode set success; otherwise failed.
  1928. **
  1929. *******************************************************************************/
  1930. //extern
  1931. BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
  1932. /*******************************************************************************
  1933. **
  1934. ** Function BTM_BleConfigLocalIcon
  1935. **
  1936. ** Description This function is called to set local icon
  1937. **
  1938. ** Parameters icon: appearance value.
  1939. **
  1940. **
  1941. *******************************************************************************/
  1942. void BTM_BleConfigLocalIcon(uint16_t icon);
  1943. /*******************************************************************************
  1944. **
  1945. ** Function BTM_BleConfigConnParams
  1946. **
  1947. ** Description This function is called to set the connection parameters
  1948. **
  1949. ** Parameters int_min: minimum connection interval
  1950. ** int_max: maximum connection interval
  1951. ** latency: slave latency
  1952. ** timeout: supervision timeout
  1953. **
  1954. *******************************************************************************/
  1955. void BTM_BleConfigConnParams(uint16_t int_min, uint16_t int_max, uint16_t latency, uint16_t timeout);
  1956. /*******************************************************************************
  1957. **
  1958. ** Function BTM_BleLocalPrivacyEnabled
  1959. **
  1960. ** Description Checks if local device supports private address
  1961. **
  1962. ** Returns Return TRUE if local privacy is enabled else FALSE
  1963. **
  1964. *******************************************************************************/
  1965. //extern
  1966. BOOLEAN BTM_BleLocalPrivacyEnabled(void);
  1967. /*******************************************************************************
  1968. **
  1969. ** Function BTM_BleEnableMixedPrivacyMode
  1970. **
  1971. ** Description This function is called to enabled Mixed mode if privacy 1.2
  1972. ** is applicable in controller.
  1973. **
  1974. ** Parameters mixed_on: mixed mode to be used or not.
  1975. **
  1976. ** Returns void
  1977. **
  1978. *******************************************************************************/
  1979. //extern
  1980. void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on);
  1981. /*******************************************************************************
  1982. **
  1983. ** Function BTM_BleMaxMultiAdvInstanceCount
  1984. **
  1985. ** Description Returns max number of multi adv instances supported by controller
  1986. **
  1987. ** Returns Max multi adv instance count
  1988. **
  1989. *******************************************************************************/
  1990. //extern
  1991. UINT8 BTM_BleMaxMultiAdvInstanceCount(void);
  1992. /*******************************************************************************
  1993. **
  1994. ** Function BTM_BleSetConnectableMode
  1995. **
  1996. ** Description This function is called to set BLE connectable mode for a
  1997. ** peripheral device.
  1998. **
  1999. ** Parameters connectable_mode: directed connectable mode, or non-directed.It can
  2000. ** be BTM_BLE_CONNECT_EVT, BTM_BLE_CONNECT_DIR_EVT or
  2001. ** BTM_BLE_CONNECT_LO_DUTY_DIR_EVT
  2002. **
  2003. ** Returns BTM_ILLEGAL_VALUE if controller does not support BLE.
  2004. ** BTM_SUCCESS is status set successfully; otherwise failure.
  2005. **
  2006. *******************************************************************************/
  2007. //extern
  2008. tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode);
  2009. /*******************************************************************************
  2010. **
  2011. ** Function BTM_BleTurnOnPrivacyOnRemote
  2012. **
  2013. ** Description This function is called to enable or disable the privacy on the
  2014. ** remote device.
  2015. **
  2016. ** Parameters bd_addr: remote device address.
  2017. ** privacy_on: TRUE to enable it; FALSE to disable it.
  2018. **
  2019. ** Returns void
  2020. **
  2021. *******************************************************************************/
  2022. //extern
  2023. void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
  2024. BOOLEAN privacy_on);
  2025. /*******************************************************************************
  2026. **
  2027. ** Function BTM_BleUpdateAdvWhitelist
  2028. **
  2029. ** Description Add or remove device from advertising white list
  2030. **
  2031. ** Returns void
  2032. **
  2033. *******************************************************************************/
  2034. //extern
  2035. BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
  2036. /*******************************************************************************
  2037. **
  2038. ** Function BTM_BleClearWhitelist
  2039. **
  2040. ** Description Clear all white list
  2041. **
  2042. ** Returns void
  2043. **
  2044. *******************************************************************************/
  2045. void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
  2046. /*******************************************************************************
  2047. **
  2048. ** Function BTM_BleUpdateAdvFilterPolicy
  2049. **
  2050. ** Description This function update the filter policy of advertiser.
  2051. **
  2052. ** Parameter adv_policy: advertising filter policy
  2053. **
  2054. ** Return void
  2055. *******************************************************************************/
  2056. //extern
  2057. void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
  2058. /*******************************************************************************
  2059. **
  2060. ** Function BTM_BleReceiverTest
  2061. **
  2062. ** Description This function is called to start the LE Receiver test
  2063. **
  2064. ** Parameter rx_freq - Frequency Range
  2065. ** p_cmd_cmpl_cback - Command Complete callback
  2066. **
  2067. *******************************************************************************/
  2068. void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback);
  2069. /*******************************************************************************
  2070. **
  2071. ** Function BTM_BleTransmitterTest
  2072. **
  2073. ** Description This function is called to start the LE Transmitter test
  2074. **
  2075. ** Parameter tx_freq - Frequency Range
  2076. ** test_data_len - Length in bytes of payload data in each packet
  2077. ** packet_payload - Pattern to use in the payload
  2078. ** p_cmd_cmpl_cback - Command Complete callback
  2079. **
  2080. *******************************************************************************/
  2081. void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len,
  2082. UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback);
  2083. /*******************************************************************************
  2084. **
  2085. ** Function BTM_BleTestEnd
  2086. **
  2087. ** Description This function is called to stop the in-progress TX or RX test
  2088. **
  2089. ** Parameter p_cmd_cmpl_cback - Command complete callback
  2090. **
  2091. *******************************************************************************/
  2092. void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback);
  2093. /*******************************************************************************
  2094. **
  2095. ** Function BTM_UseLeLink
  2096. **
  2097. ** Description This function is to select the underneath physical link to use.
  2098. **
  2099. ** Returns TRUE to use LE, FALSE use BR/EDR.
  2100. **
  2101. *******************************************************************************/
  2102. //extern
  2103. BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr);
  2104. /*******************************************************************************
  2105. **
  2106. ** Function BTM_BleStackEnable
  2107. **
  2108. ** Description Enable/Disable BLE functionality on stack regarless controller
  2109. ** capability.
  2110. **
  2111. ** Parameters: enable: TRUE to enable, FALSE to disable.
  2112. **
  2113. ** Returns TRUE if added OK, else FALSE
  2114. **
  2115. *******************************************************************************/
  2116. //extern
  2117. tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable);
  2118. /*******************************************************************************
  2119. **
  2120. ** Function BTM_GetLeSecurityState
  2121. **
  2122. ** Description This function is called to get security mode 1 flags and
  2123. ** encryption key size for LE peer.
  2124. **
  2125. ** Returns BOOLEAN TRUE if LE device is found, FALSE otherwise.
  2126. **
  2127. *******************************************************************************/
  2128. //extern
  2129. BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr,
  2130. UINT8 *p_le_dev_sec_flags,
  2131. UINT8 *p_le_key_size);
  2132. /*******************************************************************************
  2133. **
  2134. ** Function BTM_BleSecurityProcedureIsRunning
  2135. **
  2136. ** Description This function indicates if LE security procedure is
  2137. ** currently running with the peer.
  2138. **
  2139. ** Returns BOOLEAN TRUE if security procedure is running, FALSE otherwise.
  2140. **
  2141. *******************************************************************************/
  2142. //extern
  2143. BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr);
  2144. /*******************************************************************************
  2145. **
  2146. ** Function BTM_BleGetSupportedKeySize
  2147. **
  2148. ** Description This function gets the maximum encryption key size in bytes
  2149. ** the local device can suport.
  2150. ** record.
  2151. **
  2152. ** Returns the key size or 0 if the size can't be retrieved.
  2153. **
  2154. *******************************************************************************/
  2155. //extern
  2156. UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr);
  2157. /*******************************************************************************/
  2158. /* Multi ADV API */
  2159. /*******************************************************************************
  2160. **
  2161. ** Function BTM_BleEnableAdvInstance
  2162. **
  2163. ** Description This function enable a Multi-ADV instance with the specified
  2164. ** adv parameters
  2165. **
  2166. ** Parameters p_params: pointer to the adv parameter structure, set as default
  2167. ** adv parameter when the instance is enabled.
  2168. ** p_cback: callback function for the adv instance.
  2169. ** p_ref: reference data attach to the adv instance to be enabled.
  2170. **
  2171. ** Returns status
  2172. **
  2173. *******************************************************************************/
  2174. //extern
  2175. tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
  2176. tBTM_BLE_MULTI_ADV_CBACK *p_cback,
  2177. void *p_ref);
  2178. /*******************************************************************************
  2179. **
  2180. ** Function BTM_BleUpdateAdvInstParam
  2181. **
  2182. ** Description This function update a Multi-ADV instance with the specififed
  2183. ** adv parameters.
  2184. **
  2185. ** Parameters inst_id: adv instance ID
  2186. ** p_params: pointer to the adv parameter structure.
  2187. **
  2188. ** Returns status
  2189. **
  2190. *******************************************************************************/
  2191. //extern
  2192. tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params);
  2193. /*******************************************************************************
  2194. **
  2195. ** Function BTM_BleCfgAdvInstData
  2196. **
  2197. ** Description This function configure a Multi-ADV instance with the specified
  2198. ** adv data or scan response data.
  2199. **
  2200. ** Parameters inst_id: adv instance ID
  2201. ** is_scan_rsp: is this scacn response, if no set as adv data.
  2202. ** data_mask: adv data mask.
  2203. ** p_data: pointer to the adv data structure.
  2204. **
  2205. ** Returns status
  2206. **
  2207. *******************************************************************************/
  2208. //extern
  2209. tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
  2210. tBTM_BLE_AD_MASK data_mask,
  2211. tBTM_BLE_ADV_DATA *p_data);
  2212. /*******************************************************************************
  2213. **
  2214. ** Function BTM_BleDisableAdvInstance
  2215. **
  2216. ** Description This function disable a Multi-ADV instance.
  2217. **
  2218. ** Parameters inst_id: adv instance ID
  2219. **
  2220. ** Returns status
  2221. **
  2222. *******************************************************************************/
  2223. //extern
  2224. tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id);
  2225. /*******************************************************************************
  2226. **
  2227. ** Function BTM_BleAdvFilterParamSetup
  2228. **
  2229. ** Description This function is called to setup the adv data payload filter
  2230. ** condition.
  2231. **
  2232. ** Parameters p_target: enabble the filter condition on a target device; if NULL
  2233. ** enable the generic scan condition.
  2234. ** enable: enable or disable the filter condition
  2235. **
  2236. ** Returns void
  2237. **
  2238. *******************************************************************************/
  2239. //extern
  2240. tBTM_STATUS BTM_BleAdvFilterParamSetup(int action,
  2241. tBTM_BLE_PF_FILT_INDEX filt_index,
  2242. tBTM_BLE_PF_FILT_PARAMS *p_filt_params,
  2243. tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
  2244. tBTM_BLE_REF_VALUE ref_value);
  2245. /*******************************************************************************
  2246. **
  2247. ** Function BTM_BleCfgFilterCondition
  2248. **
  2249. ** Description This function is called to configure the adv data payload filter
  2250. ** condition.
  2251. **
  2252. ** Parameters action: to read/write/clear
  2253. ** cond_type: filter condition type.
  2254. ** p_cond: filter condition paramter
  2255. **
  2256. ** Returns tBTM_STATUS
  2257. **
  2258. *******************************************************************************/
  2259. //extern
  2260. tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action,
  2261. tBTM_BLE_PF_COND_TYPE cond_type,
  2262. tBTM_BLE_PF_FILT_INDEX filt_index,
  2263. tBTM_BLE_PF_COND_PARAM *p_cond,
  2264. tBTM_BLE_PF_CFG_CBACK *p_cmpl_cback,
  2265. tBTM_BLE_REF_VALUE ref_value);
  2266. /*******************************************************************************
  2267. **
  2268. ** Function BTM_BleEnableDisableFilterFeature
  2269. **
  2270. ** Description This function is called to enable or disable the APCF feature
  2271. **
  2272. ** Parameters enable - TRUE - enables the APCF, FALSE - disables the APCF
  2273. ** ref_value - Ref value
  2274. **
  2275. ** Returns tBTM_STATUS
  2276. **
  2277. *******************************************************************************/
  2278. //extern
  2279. tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable,
  2280. tBTM_BLE_PF_STATUS_CBACK *p_stat_cback,
  2281. tBTM_BLE_REF_VALUE ref_value);
  2282. /*******************************************************************************
  2283. **
  2284. ** Function BTM_BleGetEnergyInfo
  2285. **
  2286. ** Description This function obtains the energy info
  2287. **
  2288. ** Parameters p_ener_cback - Callback pointer
  2289. **
  2290. ** Returns status
  2291. **
  2292. *******************************************************************************/
  2293. //extern
  2294. tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback);
  2295. /*******************************************************************************
  2296. **
  2297. ** Function BTM_SetBleDataLength
  2298. **
  2299. ** Description This function is called to set maximum BLE transmission packet size
  2300. **
  2301. ** Returns BTM_SUCCESS if success; otherwise failed.
  2302. **
  2303. *******************************************************************************/
  2304. //extern
  2305. tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length);
  2306. /*******************************************************************************
  2307. **
  2308. ** Function BTM_UpdateBleDuplicateExceptionalList
  2309. **
  2310. ** Description This function is called to update duplicate scan exceptional list.
  2311. **
  2312. ** Parameters: subcode: add, remove or clean duplicate scan exceptional list.
  2313. ** type: device info type
  2314. ** device_info: device information
  2315. ** update_exceptional_list_cmp_cb: complete callback
  2316. **
  2317. ** Returns status
  2318. **
  2319. *******************************************************************************/
  2320. tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb);
  2321. /*******************************************************************************
  2322. **
  2323. ** Function BTM_GetCurrentConnParams
  2324. **
  2325. ** Description This function is called to read the current connection parameters
  2326. ** of the device
  2327. **
  2328. ** Returns TRUE or FALSE
  2329. **
  2330. *******************************************************************************/
  2331. BOOLEAN BTM_GetCurrentConnParams(BD_ADDR bda, uint16_t *interval, uint16_t *latency, uint16_t *timeout);
  2332. /*******************************************************************************
  2333. **
  2334. ** Function BTM_Ble_Authorization
  2335. **
  2336. ** Description This function is used to authorize a specified device
  2337. **
  2338. ** Returns TRUE or FALSE
  2339. **
  2340. *******************************************************************************/
  2341. BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize);
  2342. /*
  2343. #ifdef __cplusplus
  2344. }
  2345. #endif
  2346. */
  2347. #if (BLE_50_FEATURE_SUPPORT == TRUE)
  2348. void BTM_BleGapRegisterCallback(tBTM_BLE_5_HCI_CBACK cb);
  2349. tBTM_STATUS BTM_BleReadPhy(BD_ADDR bd_addr, UINT8 *tx_phy, UINT8 *rx_phy);
  2350. tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask);
  2351. tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_mask,
  2352. UINT8 rx_phy_mask, UINT16 phy_options);
  2353. tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr);
  2354. tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PARAMS *params);
  2355. tBTM_STATUS BTM_BleConfigExtendedAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 len, UINT8 *data);
  2356. tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_adv);
  2357. tBTM_STATUS BTM_BleExtAdvSetRemove(UINT8 instance);
  2358. tBTM_STATUS BTM_BleExtAdvSetClear(void);
  2359. tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params);
  2360. tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data);
  2361. tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, BOOLEAN enable);
  2362. tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params);
  2363. tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void);
  2364. tBTM_STATUS BTM_BlePeriodicAdvSyncTerm(UINT16 sync_handle);
  2365. tBTM_STATUS BTM_BlePeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
  2366. tBTM_STATUS BTM_BlePeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
  2367. tBTM_STATUS BTM_BlePeriodicAdvClearDev(void);
  2368. tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params);
  2369. tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period);
  2370. void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params);
  2371. #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
  2372. #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  2373. void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable);
  2374. void BTM_BlePeriodicAdvSyncTrans(BD_ADDR bd_addr, UINT16 service_data, UINT16 sync_handle);
  2375. void BTM_BlePeriodicAdvSetInfoTrans(BD_ADDR bd_addr, UINT16 service_data, UINT8 adv_handle);
  2376. void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
  2377. #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
  2378. #endif