btm_ble_api.h 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969
  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 "bt_defs.h"
  27. #include "btm_api.h"
  28. #include "gki.h"
  29. #include "bt_common_types.h"
  30. #define CHANNEL_MAP_LEN 5
  31. typedef UINT8 tBTM_BLE_CHNL_MAP[CHANNEL_MAP_LEN];
  32. /* 0x00-0x04 only used for set advertising parameter command */
  33. #define BTM_BLE_CONNECT_EVT 0x00 /* 0x00-0x04 only used for set advertising
  34. parameter command */
  35. #define BTM_BLE_CONNECT_DIR_EVT 0x01 /* Connectable directed advertising */
  36. #define BTM_BLE_DISCOVER_EVT 0x02 /* Scannable undirected advertising */
  37. #define BTM_BLE_NON_CONNECT_EVT 0x03 /* Non connectable undirected advertising */
  38. #define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04 /* Connectable low duty
  39. cycle directed advertising */
  40. /* 0x00 - 0x05 can be received on adv event type */
  41. #define BTM_BLE_SCAN_RSP_EVT 0x04
  42. #define BTM_BLE_SCAN_REQ_EVT 0x05
  43. #define BTM_BLE_UNKNOWN_EVT 0xff
  44. #define BTM_BLE_UNKNOWN_EVT 0xff
  45. typedef UINT8 tBTM_BLE_EVT;
  46. typedef UINT8 tBTM_BLE_CONN_MODE;
  47. typedef UINT32 tBTM_BLE_REF_VALUE;
  48. #define BTM_BLE_SCAN_MODE_PASS 0
  49. #define BTM_BLE_SCAN_MODE_ACTI 1
  50. #define BTM_BLE_SCAN_MODE_NONE 0xff
  51. typedef UINT8 tBLE_SCAN_MODE;
  52. #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0
  53. #define BTM_BLE_BATCH_SCAN_MODE_PASS 1
  54. #define BTM_BLE_BATCH_SCAN_MODE_ACTI 2
  55. #define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3
  56. typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE;
  57. /* advertising channel map */
  58. #define BTM_BLE_ADV_CHNL_37 (0x01 << 0)
  59. #define BTM_BLE_ADV_CHNL_38 (0x01 << 1)
  60. #define BTM_BLE_ADV_CHNL_39 (0x01 << 2)
  61. typedef UINT8 tBTM_BLE_ADV_CHNL_MAP;
  62. /*d efault advertising channel map */
  63. #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP
  64. #define BTM_BLE_DEFAULT_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39)
  65. #endif
  66. /* advertising filter policy */
  67. #define AP_SCAN_CONN_ALL 0x00 /* default */
  68. #define AP_SCAN_WL_CONN_ALL 0x01
  69. #define AP_SCAN_ALL_CONN_WL 0x02
  70. #define AP_SCAN_CONN_WL 0x03
  71. #define AP_SCAN_CONN_POLICY_MAX 0x04
  72. typedef UINT8 tBTM_BLE_AFP;
  73. /* default advertising filter policy */
  74. #ifndef BTM_BLE_DEFAULT_AFP
  75. #define BTM_BLE_DEFAULT_AFP AP_SCAN_CONN_ALL
  76. #endif
  77. /* scanning filter policy */
  78. #define SP_ADV_ALL 0x00 /* 0: accept adv packet from all, directed adv pkt not directed */
  79. /* to local device is ignored */
  80. #define SP_ADV_WL 0x01 /* 1: accept adv packet from device in white list, directed adv */
  81. /* packet not directed to local device is ignored */
  82. #define SP_ADV_ALL_RPA_DIR_ADV 0x02 /* 2: accept adv packet from all, directed adv pkt */
  83. /* not directed to me is ignored except direct adv with RPA */
  84. #define SP_ADV_WL_RPA_DIR_ADV 0x03 /* 3: accept adv packet from device in white list, directed */
  85. /* adv pkt not directed to me is ignored except direct adv */
  86. /* with RPA */
  87. typedef UINT8 tBTM_BLE_SFP;
  88. #ifndef BTM_BLE_DEFAULT_SFP
  89. #define BTM_BLE_DEFAULT_SFP SP_ADV_ALL
  90. #endif
  91. /* adv parameter boundary values */
  92. #define BTM_BLE_ADV_INT_MIN 0x0020
  93. #define BTM_BLE_ADV_INT_MAX 0x4000
  94. /* Full scan boundary values */
  95. #define BTM_BLE_ADV_SCAN_FULL_MIN 0x00
  96. #define BTM_BLE_ADV_SCAN_FULL_MAX 0x64
  97. /* Partial scan boundary values */
  98. #define BTM_BLE_ADV_SCAN_TRUNC_MIN BTM_BLE_ADV_SCAN_FULL_MIN
  99. #define BTM_BLE_ADV_SCAN_TRUNC_MAX BTM_BLE_ADV_SCAN_FULL_MAX
  100. /* Threshold values */
  101. #define BTM_BLE_ADV_SCAN_THR_MIN BTM_BLE_ADV_SCAN_FULL_MIN
  102. #define BTM_BLE_ADV_SCAN_THR_MAX BTM_BLE_ADV_SCAN_FULL_MAX
  103. /* connection parameter boundary values */
  104. #define BTM_BLE_SCAN_INT_MIN 0x0004
  105. #define BTM_BLE_SCAN_INT_MAX 0x4000
  106. #define BTM_BLE_SCAN_WIN_MIN 0x0004
  107. #define BTM_BLE_SCAN_WIN_MAX 0x4000
  108. #define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF
  109. #define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF
  110. #define BTM_BLE_CONN_INT_MIN 0x0006
  111. #define BTM_BLE_CONN_INT_MAX 0x0C80
  112. #define BTM_BLE_CONN_LATENCY_MAX 500
  113. #define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
  114. #define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
  115. #define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
  116. #define BTM_BLE_SCAN_PARAM_UNDEF 0xffffffff
  117. /* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
  118. /* default scan interval */
  119. #ifndef BTM_BLE_SCAN_FAST_INT
  120. #define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */
  121. #endif
  122. /* default scan window for background connection, applicable for auto connection or selective conenction */
  123. #ifndef BTM_BLE_SCAN_FAST_WIN
  124. #define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */
  125. #endif
  126. /* default scan paramter used in reduced power cycle (background scanning) */
  127. #ifndef BTM_BLE_SCAN_SLOW_INT_1
  128. #define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */
  129. #endif
  130. #ifndef BTM_BLE_SCAN_SLOW_WIN_1
  131. #define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */
  132. #endif
  133. /* default scan paramter used in reduced power cycle (background scanning) */
  134. #ifndef BTM_BLE_SCAN_SLOW_INT_2
  135. #define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */
  136. #endif
  137. #ifndef BTM_BLE_SCAN_SLOW_WIN_2
  138. #define BTM_BLE_SCAN_SLOW_WIN_2 36 /* 22.5 ms = 36 *0.625 */
  139. #endif
  140. /* default connection interval min */
  141. #ifndef BTM_BLE_CONN_INT_MIN_DEF
  142. #define BTM_BLE_CONN_INT_MIN_DEF 24 /* recommended min: 30ms = 24 * 1.25 */
  143. #endif
  144. /* default connection interval max */
  145. #ifndef BTM_BLE_CONN_INT_MAX_DEF
  146. #define BTM_BLE_CONN_INT_MAX_DEF 40 /* recommended max: 50 ms = 56 * 1.25 */
  147. #endif
  148. /* default slave latency */
  149. #ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF
  150. #define BTM_BLE_CONN_SLAVE_LATENCY_DEF 0 /* 0 */
  151. #endif
  152. /* default supervision timeout */
  153. #ifndef BTM_BLE_CONN_TIMEOUT_DEF
  154. #define BTM_BLE_CONN_TIMEOUT_DEF 2000
  155. #endif
  156. /* minimum acceptable connection interval */
  157. #ifndef BTM_BLE_CONN_INT_MIN_LIMIT
  158. #define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009
  159. #endif
  160. #define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1
  161. #define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2
  162. #ifndef BTM_BLE_DIR_CONN_FALLBACK
  163. #define BTM_BLE_DIR_CONN_FALLBACK BTM_BLE_DIR_CONN_FALLBACK_UNDIR
  164. #endif
  165. #define BTM_CMAC_TLEN_SIZE 8 /* 64 bits */
  166. #define BTM_BLE_AUTH_SIGN_LEN 12 /* BLE data signature length 8 Bytes + 4 bytes counter*/
  167. typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */
  168. #ifndef BTM_BLE_HOST_SUPPORT
  169. #define BTM_BLE_HOST_SUPPORT 0x01
  170. #endif
  171. #ifndef BTM_BLE_SIMULTANEOUS_HOST
  172. #define BTM_BLE_SIMULTANEOUS_HOST 0x01
  173. #endif
  174. /* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */
  175. #define BTM_BLE_APPEARANCE_UKNOWN 0x0000
  176. #define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040
  177. #define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080
  178. #define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0
  179. #define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1
  180. #define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100
  181. #define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140
  182. #define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180
  183. #define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0
  184. #define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200
  185. #define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240
  186. #define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280
  187. #define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
  188. #define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300
  189. #define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301
  190. #define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340
  191. #define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341
  192. #define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380
  193. #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381
  194. #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382
  195. #define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0
  196. #define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1
  197. #define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2
  198. #define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3
  199. #define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4
  200. #define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5
  201. #define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6
  202. #define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7
  203. #define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8
  204. #define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400
  205. #define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440
  206. #define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441
  207. #define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442
  208. #define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443
  209. #define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480
  210. #define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481
  211. #define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482
  212. #define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483
  213. #define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484
  214. #define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485
  215. #define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40
  216. #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
  217. #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42
  218. #define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80
  219. #define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440
  220. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441
  221. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442
  222. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443
  223. #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444
  224. /* Structure returned with Rand/Encrypt complete callback */
  225. typedef struct {
  226. UINT8 status;
  227. UINT8 param_len;
  228. UINT16 opcode;
  229. UINT8 param_buf[BT_OCTET16_LEN];
  230. } tBTM_RAND_ENC;
  231. /* General callback function for notifying an application that a synchronous
  232. ** BTM function is complete. The pointer contains the address of any returned data.
  233. */
  234. typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1);
  235. #define BTM_BLE_FILTER_TARGET_SCANNER 0x01
  236. #define BTM_BLE_FILTER_TARGET_ADVR 0x00
  237. #define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */
  238. #define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */
  239. #define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */
  240. #define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */
  241. /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
  242. #define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0)
  243. #define BTM_BLE_GEN_DISC_FLAG (0x01 << 1)
  244. #define BTM_BLE_BREDR_NOT_SPT (0x01 << 2)
  245. /* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */
  246. #define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3)
  247. #define BTM_BLE_DMT_HOST_SPT (0x01 << 4)
  248. #define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00 ) /* lowest bit unset */
  249. #define BTM_BLE_ADV_FLAG_MASK (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG)
  250. #define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG )
  251. #define BTM_BLE_AD_BIT_DEV_NAME (0x00000001 << 0)
  252. #define BTM_BLE_AD_BIT_FLAGS (0x00000001 << 1)
  253. #define BTM_BLE_AD_BIT_MANU (0x00000001 << 2)
  254. #define BTM_BLE_AD_BIT_TX_PWR (0x00000001 << 3)
  255. #define BTM_BLE_AD_BIT_INT_RANGE (0x00000001 << 5)
  256. #define BTM_BLE_AD_BIT_SERVICE (0x00000001 << 6)
  257. #define BTM_BLE_AD_BIT_SERVICE_SOL (0x00000001 << 7)
  258. #define BTM_BLE_AD_BIT_SERVICE_DATA (0x00000001 << 8)
  259. #define BTM_BLE_AD_BIT_SIGN_DATA (0x00000001 << 9)
  260. #define BTM_BLE_AD_BIT_SERVICE_128SOL (0x00000001 << 10)
  261. #define BTM_BLE_AD_BIT_APPEARANCE (0x00000001 << 11)
  262. #define BTM_BLE_AD_BIT_PUBLIC_ADDR (0x00000001 << 12)
  263. #define BTM_BLE_AD_BIT_RANDOM_ADDR (0x00000001 << 13)
  264. #define BTM_BLE_AD_BIT_SERVICE_32 (0x00000001 << 4)
  265. #define BTM_BLE_AD_BIT_SERVICE_32SOL (0x00000001 << 14)
  266. #define BTM_BLE_AD_BIT_PROPRIETARY (0x00000001 << 15)
  267. #define BTM_BLE_AD_BIT_SERVICE_128 (0x00000001 << 16) /*128-bit Service UUIDs*/
  268. typedef UINT32 tBTM_BLE_AD_MASK;
  269. #define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */
  270. #define BTM_BLE_AD_TYPE_16SRV_PART HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */
  271. #define BTM_BLE_AD_TYPE_16SRV_CMPL HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */
  272. #define BTM_BLE_AD_TYPE_32SRV_PART HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */
  273. #define BTM_BLE_AD_TYPE_32SRV_CMPL HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */
  274. #define BTM_BLE_AD_TYPE_128SRV_PART HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */
  275. #define BTM_BLE_AD_TYPE_128SRV_CMPL HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */
  276. #define BTM_BLE_AD_TYPE_NAME_SHORT HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */
  277. #define BTM_BLE_AD_TYPE_NAME_CMPL HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */
  278. #define BTM_BLE_AD_TYPE_TX_PWR HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */
  279. #define BTM_BLE_AD_TYPE_DEV_CLASS 0x0D
  280. #define BTM_BLE_AD_TYPE_SM_TK 0x10
  281. #define BTM_BLE_AD_TYPE_SM_OOB_FLAG 0x11
  282. #define BTM_BLE_AD_TYPE_INT_RANGE 0x12
  283. #define BTM_BLE_AD_TYPE_SOL_SRV_UUID 0x14
  284. #define BTM_BLE_AD_TYPE_128SOL_SRV_UUID 0x15
  285. #define BTM_BLE_AD_TYPE_SERVICE_DATA 0x16
  286. #define BTM_BLE_AD_TYPE_PUBLIC_TARGET 0x17
  287. #define BTM_BLE_AD_TYPE_RANDOM_TARGET 0x18
  288. #define BTM_BLE_AD_TYPE_APPEARANCE 0x19
  289. #define BTM_BLE_AD_TYPE_ADV_INT 0x1a
  290. #define BTM_BLE_AD_TYPE_LE_DEV_ADDR 0x1b
  291. #define BTM_BLE_AD_TYPE_LE_ROLE 0x1c
  292. #define BTM_BLE_AD_TYPE_SPAIR_C256 0x1d
  293. #define BTM_BLE_AD_TYPE_SPAIR_R256 0x1e
  294. #define BTM_BLE_AD_TYPE_32SOL_SRV_UUID 0x1f
  295. #define BTM_BLE_AD_TYPE_32SERVICE_DATA 0x20
  296. #define BTM_BLE_AD_TYPE_128SERVICE_DATA 0x21
  297. #define BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM 0x22
  298. #define BTM_BLE_AD_TYPE_LE_SECURE_RANDOM 0x23
  299. #define BTM_BLE_AD_TYPE_URI 0x24
  300. #define BTM_BLE_AD_TYPE_INDOOR_POSITION 0x25
  301. #define BTM_BLE_AD_TYPE_TRANS_DISC_DATA 0x26
  302. #define BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE 0x27
  303. #define BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE 0x28
  304. #define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */
  305. typedef UINT8 tBTM_BLE_AD_TYPE;
  306. /* Security settings used with L2CAP LE COC */
  307. #define BTM_SEC_LE_LINK_ENCRYPTED 0x01
  308. #define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02
  309. #define BTM_SEC_LE_LINK_PAIRED_WITH_MITM 0x04
  310. /* Min/max Preferred number of payload octets that the local Controller
  311. should include in a single Link Layer Data Channel PDU. */
  312. #define BTM_BLE_DATA_SIZE_MAX 0x00fb
  313. #define BTM_BLE_DATA_SIZE_MIN 0x001b
  314. /* Preferred maximum number of microseconds that the local Controller
  315. should use to transmit a single Link Layer Data Channel PDU. */
  316. #define BTM_BLE_DATA_TX_TIME_MIN 0x0148
  317. #define BTM_BLE_DATA_TX_TIME_MAX 0x0848
  318. /* adv tx power level */
  319. #define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
  320. #define BTM_BLE_ADV_TX_POWER_LOW 1 /* low tx power */
  321. #define BTM_BLE_ADV_TX_POWER_MID 2 /* middle tx power */
  322. #define BTM_BLE_ADV_TX_POWER_UPPER 3 /* upper tx power */
  323. #define BTM_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */
  324. typedef UINT8 tBTM_BLE_ADV_TX_POWER;
  325. /* adv tx power in dBm */
  326. typedef struct {
  327. UINT8 adv_inst_max; /* max adv instance supported in controller */
  328. UINT8 rpa_offloading;
  329. UINT16 tot_scan_results_strg;
  330. UINT8 max_irk_list_sz;
  331. UINT8 filter_support;
  332. UINT8 max_filter;
  333. UINT8 energy_support;
  334. BOOLEAN values_read;
  335. UINT16 version_supported;
  336. UINT16 total_trackable_advertisers;
  337. UINT8 extended_scan_support;
  338. UINT8 debug_logging_supported;
  339. } tBTM_BLE_VSC_CB;
  340. /* slave preferred connection interval range */
  341. typedef struct {
  342. UINT16 low;
  343. UINT16 hi;
  344. } tBTM_BLE_INT_RANGE;
  345. /* Service tag supported in the device */
  346. typedef struct {
  347. UINT8 num_service;
  348. BOOLEAN list_cmpl;
  349. UINT16 *p_uuid;
  350. } tBTM_BLE_SERVICE;
  351. /* 32 bits Service supported in the device */
  352. typedef struct {
  353. UINT8 num_service;
  354. BOOLEAN list_cmpl;
  355. UINT32 *p_uuid;
  356. } tBTM_BLE_32SERVICE;
  357. /* 128 bits Service supported in the device */
  358. typedef struct {
  359. BOOLEAN list_cmpl;
  360. UINT8 uuid128[MAX_UUID_SIZE];
  361. } tBTM_BLE_128SERVICE;
  362. typedef struct {
  363. UINT8 len;
  364. UINT8 *p_val;
  365. } tBTM_BLE_MANU;
  366. typedef struct {
  367. tBT_UUID service_uuid;
  368. UINT8 len;
  369. UINT8 *p_val;
  370. } tBTM_BLE_SERVICE_DATA;
  371. typedef struct {
  372. UINT8 adv_type;
  373. UINT8 len;
  374. UINT8 *p_val; /* number of len byte */
  375. } tBTM_BLE_PROP_ELEM;
  376. typedef struct {
  377. UINT8 num_elem;
  378. tBTM_BLE_PROP_ELEM *p_elem;
  379. } tBTM_BLE_PROPRIETARY;
  380. typedef struct {
  381. tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
  382. tBTM_BLE_MANU *p_manu; /* manufactuer data */
  383. tBTM_BLE_SERVICE *p_services; /* services */
  384. tBTM_BLE_128SERVICE *p_services_128b; /* 128 bits service */
  385. tBTM_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */
  386. tBTM_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */
  387. tBTM_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */
  388. tBTM_BLE_128SERVICE *p_sol_service_128b; /* List of 128 bit Service Solicitation UUIDs */
  389. tBTM_BLE_PROPRIETARY *p_proprietary;
  390. tBTM_BLE_SERVICE_DATA *p_service_data; /* service data */
  391. UINT16 appearance;
  392. UINT8 flag;
  393. UINT8 tx_power;
  394. } tBTM_BLE_ADV_DATA;
  395. #ifndef BTM_BLE_MULTI_ADV_MAX
  396. #define BTM_BLE_MULTI_ADV_MAX 16 /* controller returned adv_inst_max should be less
  397. than this number */
  398. #endif
  399. #define BTM_BLE_MULTI_ADV_INVALID 0
  400. #define BTM_BLE_MULTI_ADV_ENB_EVT 1
  401. #define BTM_BLE_MULTI_ADV_DISABLE_EVT 2
  402. #define BTM_BLE_MULTI_ADV_PARAM_EVT 3
  403. #define BTM_BLE_MULTI_ADV_DATA_EVT 4
  404. typedef UINT8 tBTM_BLE_MULTI_ADV_EVT;
  405. #define BTM_BLE_MULTI_ADV_DEFAULT_STD 0
  406. typedef struct {
  407. UINT16 adv_int_min;
  408. UINT16 adv_int_max;
  409. UINT8 adv_type;
  410. tBTM_BLE_ADV_CHNL_MAP channel_map;
  411. tBTM_BLE_AFP adv_filter_policy;
  412. tBTM_BLE_ADV_TX_POWER tx_power;
  413. } tBTM_BLE_ADV_PARAMS;
  414. typedef struct {
  415. UINT8 *p_sub_code; /* dynamic array to store sub code */
  416. UINT8 *p_inst_id; /* dynamic array to store instance id */
  417. UINT8 pending_idx;
  418. UINT8 next_idx;
  419. } tBTM_BLE_MULTI_ADV_OPQ;
  420. typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id,
  421. void *p_ref, tBTM_STATUS status);
  422. typedef struct {
  423. UINT8 inst_id;
  424. BOOLEAN in_use;
  425. UINT8 adv_evt;
  426. BD_ADDR rpa;
  427. TIMER_LIST_ENT raddr_timer_ent;
  428. tBTM_BLE_MULTI_ADV_CBACK *p_cback;
  429. void *p_ref;
  430. UINT8 index;
  431. } tBTM_BLE_MULTI_ADV_INST;
  432. typedef struct {
  433. UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX];
  434. int front;
  435. int rear;
  436. } tBTM_BLE_MULTI_ADV_INST_IDX_Q;
  437. typedef struct {
  438. tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */
  439. tBTM_BLE_MULTI_ADV_OPQ op_q;
  440. } tBTM_BLE_MULTI_ADV_CB;
  441. typedef UINT8 tGATT_IF;
  442. typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value);
  443. typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format,
  444. UINT8 num_records, UINT16 total_len,
  445. UINT8 *p_rep_data, UINT8 status);
  446. typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status);
  447. #ifndef BTM_BLE_BATCH_SCAN_MAX
  448. #define BTM_BLE_BATCH_SCAN_MAX 5
  449. #endif
  450. #ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE
  451. #define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2
  452. #endif
  453. typedef enum {
  454. BTM_BLE_SCAN_INVALID_STATE = 0,
  455. BTM_BLE_SCAN_ENABLE_CALLED = 1,
  456. BTM_BLE_SCAN_ENABLED_STATE = 2,
  457. BTM_BLE_SCAN_DISABLE_CALLED = 3,
  458. BTM_BLE_SCAN_DISABLED_STATE = 4
  459. } tBTM_BLE_BATCH_SCAN_STATE;
  460. enum {
  461. BTM_BLE_DISCARD_OLD_ITEMS,
  462. BTM_BLE_DISCARD_LOWER_RSSI_ITEMS
  463. };
  464. typedef UINT8 tBTM_BLE_DISCARD_RULE;
  465. typedef struct {
  466. UINT8 sub_code[BTM_BLE_BATCH_SCAN_MAX];
  467. tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX];
  468. tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_SCAN_MAX];
  469. UINT8 pending_idx;
  470. UINT8 next_idx;
  471. } tBTM_BLE_BATCH_SCAN_OPQ;
  472. typedef struct {
  473. UINT8 rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  474. tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  475. UINT8 num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  476. UINT16 data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  477. UINT8 *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE];
  478. UINT8 pending_idx;
  479. UINT8 next_idx;
  480. } tBTM_BLE_BATCH_SCAN_REP_Q;
  481. typedef struct {
  482. tBTM_BLE_BATCH_SCAN_STATE cur_state;
  483. tBTM_BLE_BATCH_SCAN_MODE scan_mode;
  484. UINT32 scan_interval;
  485. UINT32 scan_window;
  486. tBLE_ADDR_TYPE addr_type;
  487. tBTM_BLE_DISCARD_RULE discard_rule;
  488. tBTM_BLE_BATCH_SCAN_OPQ op_q;
  489. tBTM_BLE_BATCH_SCAN_REP_Q main_rep_q;
  490. tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback;
  491. tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback;
  492. tBTM_BLE_SCAN_REP_CBACK *p_scan_rep_cback;
  493. tBTM_BLE_REF_VALUE ref_value;
  494. } tBTM_BLE_BATCH_SCAN_CB;
  495. /* filter selection bit index */
  496. #define BTM_BLE_PF_ADDR_FILTER 0
  497. #define BTM_BLE_PF_SRVC_DATA 1
  498. #define BTM_BLE_PF_SRVC_UUID 2
  499. #define BTM_BLE_PF_SRVC_SOL_UUID 3
  500. #define BTM_BLE_PF_LOCAL_NAME 4
  501. #define BTM_BLE_PF_MANU_DATA 5
  502. #define BTM_BLE_PF_SRVC_DATA_PATTERN 6
  503. #define BTM_BLE_PF_TYPE_ALL 7 /* when passed in payload filter type all, only clear action is applicable */
  504. #define BTM_BLE_PF_TYPE_MAX 8
  505. /* max number of filter spot for different filter type */
  506. #ifndef BTM_BLE_MAX_UUID_FILTER
  507. #define BTM_BLE_MAX_UUID_FILTER 8
  508. #endif
  509. #ifndef BTM_BLE_MAX_ADDR_FILTER
  510. #define BTM_BLE_MAX_ADDR_FILTER 8
  511. #endif
  512. #ifndef BTM_BLE_PF_STR_COND_MAX
  513. #define BTM_BLE_PF_STR_COND_MAX 4 /* apply to manu data , or local name */
  514. #endif
  515. #ifndef BTM_BLE_PF_STR_LEN_MAX
  516. #define BTM_BLE_PF_STR_LEN_MAX 29 /* match for first 29 bytes */
  517. #endif
  518. typedef UINT8 tBTM_BLE_PF_COND_TYPE;
  519. #define BTM_BLE_PF_LOGIC_OR 0
  520. #define BTM_BLE_PF_LOGIC_AND 1
  521. typedef UINT8 tBTM_BLE_PF_LOGIC_TYPE;
  522. #define BTM_BLE_PF_ENABLE 1
  523. #define BTM_BLE_PF_CONFIG 2
  524. typedef UINT8 tBTM_BLE_PF_ACTION;
  525. typedef UINT8 tBTM_BLE_PF_FILT_INDEX;
  526. typedef UINT8 tBTM_BLE_PF_AVBL_SPACE;
  527. #define BTM_BLE_PF_BRDCAST_ADDR_FILT 1
  528. #define BTM_BLE_PF_SERV_DATA_CHG_FILT 2
  529. #define BTM_BLE_PF_SERV_UUID 4
  530. #define BTM_BLE_PF_SERV_SOLC_UUID 8
  531. #define BTM_BLE_PF_LOC_NAME_CHECK 16
  532. #define BTM_BLE_PF_MANUF_NAME_CHECK 32
  533. #define BTM_BLE_PF_SERV_DATA_CHECK 64
  534. typedef UINT16 tBTM_BLE_PF_FEAT_SEL;
  535. #define BTM_BLE_PF_LIST_LOGIC_OR 1
  536. #define BTM_BLE_PF_LIST_LOGIC_AND 2
  537. typedef UINT16 tBTM_BLE_PF_LIST_LOGIC_TYPE;
  538. #define BTM_BLE_PF_FILT_LOGIC_OR 0
  539. #define BTM_BLE_PF_FILT_LOGIC_AND 1
  540. typedef UINT16 tBTM_BLE_PF_FILT_LOGIC_TYPE;
  541. typedef UINT8 tBTM_BLE_PF_RSSI_THRESHOLD;
  542. typedef UINT8 tBTM_BLE_PF_DELIVERY_MODE;
  543. typedef UINT16 tBTM_BLE_PF_TIMEOUT;
  544. typedef UINT8 tBTM_BLE_PF_TIMEOUT_CNT;
  545. typedef UINT16 tBTM_BLE_PF_ADV_TRACK_ENTRIES;
  546. typedef struct {
  547. tBTM_BLE_PF_FEAT_SEL feat_seln;
  548. tBTM_BLE_PF_LIST_LOGIC_TYPE logic_type;
  549. tBTM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type;
  550. tBTM_BLE_PF_RSSI_THRESHOLD rssi_high_thres;
  551. tBTM_BLE_PF_RSSI_THRESHOLD rssi_low_thres;
  552. tBTM_BLE_PF_DELIVERY_MODE dely_mode;
  553. tBTM_BLE_PF_TIMEOUT found_timeout;
  554. tBTM_BLE_PF_TIMEOUT lost_timeout;
  555. tBTM_BLE_PF_TIMEOUT_CNT found_timeout_cnt;
  556. tBTM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries;
  557. } tBTM_BLE_PF_FILT_PARAMS;
  558. enum {
  559. BTM_BLE_SCAN_COND_ADD,
  560. BTM_BLE_SCAN_COND_DELETE,
  561. BTM_BLE_SCAN_COND_CLEAR = 2
  562. };
  563. typedef UINT8 tBTM_BLE_SCAN_COND_OP;
  564. enum {
  565. BTM_BLE_FILT_ENABLE_DISABLE = 1,
  566. BTM_BLE_FILT_CFG = 2,
  567. BTM_BLE_FILT_ADV_PARAM = 3
  568. };
  569. typedef UINT8 tBTM_BLE_FILT_CB_EVT;
  570. /* BLE adv payload filtering config complete callback */
  571. typedef void (tBTM_BLE_PF_CFG_CBACK)(tBTM_BLE_PF_ACTION action, tBTM_BLE_SCAN_COND_OP cfg_op,
  572. tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_STATUS status,
  573. tBTM_BLE_REF_VALUE ref_value);
  574. typedef void (tBTM_BLE_PF_CMPL_CBACK) (tBTM_BLE_PF_CFG_CBACK);
  575. /* BLE adv payload filtering status setup complete callback */
  576. typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status,
  577. tBTM_BLE_REF_VALUE ref_value);
  578. /* BLE adv payload filtering param setup complete callback */
  579. typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type,
  580. tBTM_BLE_PF_AVBL_SPACE avbl_space,
  581. tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status);
  582. typedef union {
  583. UINT16 uuid16_mask;
  584. UINT32 uuid32_mask;
  585. UINT8 uuid128_mask[LEN_UUID_128];
  586. } tBTM_BLE_PF_COND_MASK;
  587. typedef struct {
  588. tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */
  589. tBT_UUID uuid; /* UUID condition */
  590. tBTM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */
  591. tBTM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID mask */
  592. } tBTM_BLE_PF_UUID_COND;
  593. typedef struct {
  594. UINT8 data_len; /* <= 20 bytes */
  595. UINT8 *p_data;
  596. } tBTM_BLE_PF_LOCAL_NAME_COND;
  597. typedef struct {
  598. UINT16 company_id; /* company ID */
  599. UINT8 data_len; /* <= 20 bytes */
  600. UINT8 *p_pattern;
  601. UINT16 company_id_mask; /* UUID value mask */
  602. UINT8 *p_pattern_mask; /* Manufacturer data matching mask,
  603. same length as data pattern,
  604. set to all 0xff, match exact data */
  605. } tBTM_BLE_PF_MANU_COND;
  606. typedef struct {
  607. UINT16 uuid; /* service ID */
  608. UINT8 data_len; /* <= 20 bytes */
  609. UINT8 *p_pattern;
  610. UINT8 *p_pattern_mask; /* Service data matching mask, same length as data pattern,
  611. set to all 0xff, match exact data */
  612. } tBTM_BLE_PF_SRVC_PATTERN_COND;
  613. typedef union {
  614. tBLE_BD_ADDR target_addr;
  615. tBTM_BLE_PF_LOCAL_NAME_COND local_name; /* lcoal name filtering */
  616. tBTM_BLE_PF_MANU_COND manu_data; /* manufactuer data filtering */
  617. tBTM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */
  618. tBTM_BLE_PF_UUID_COND solicitate_uuid; /* solicitated service UUID filtering */
  619. tBTM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */
  620. } tBTM_BLE_PF_COND_PARAM;
  621. typedef struct {
  622. UINT8 action_ocf[BTM_BLE_PF_TYPE_MAX];
  623. tBTM_BLE_REF_VALUE ref_value[BTM_BLE_PF_TYPE_MAX];
  624. tBTM_BLE_PF_PARAM_CBACK *p_filt_param_cback[BTM_BLE_PF_TYPE_MAX];
  625. tBTM_BLE_PF_CFG_CBACK *p_scan_cfg_cback[BTM_BLE_PF_TYPE_MAX];
  626. UINT8 cb_evt[BTM_BLE_PF_TYPE_MAX];
  627. UINT8 pending_idx;
  628. UINT8 next_idx;
  629. } tBTM_BLE_ADV_FILTER_ADV_OPQ;
  630. #define BTM_BLE_MAX_FILTER_COUNTER (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */
  631. #ifndef BTM_CS_IRK_LIST_MAX
  632. #define BTM_CS_IRK_LIST_MAX 0x20
  633. #endif
  634. typedef struct {
  635. BOOLEAN in_use;
  636. BD_ADDR bd_addr;
  637. UINT8 pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */
  638. } tBTM_BLE_PF_COUNT;
  639. typedef struct {
  640. BOOLEAN enable;
  641. UINT8 op_type;
  642. tBTM_BLE_PF_COUNT *p_addr_filter_count; /* per BDA filter array */
  643. tBLE_BD_ADDR cur_filter_target;
  644. tBTM_BLE_PF_STATUS_CBACK *p_filt_stat_cback;
  645. tBTM_BLE_ADV_FILTER_ADV_OPQ op_q;
  646. } tBTM_BLE_ADV_FILTER_CB;
  647. /* Sub codes */
  648. #define BTM_BLE_META_PF_ENABLE 0x00
  649. #define BTM_BLE_META_PF_FEAT_SEL 0x01
  650. #define BTM_BLE_META_PF_ADDR 0x02
  651. #define BTM_BLE_META_PF_UUID 0x03
  652. #define BTM_BLE_META_PF_SOL_UUID 0x04
  653. #define BTM_BLE_META_PF_LOCAL_NAME 0x05
  654. #define BTM_BLE_META_PF_MANU_DATA 0x06
  655. #define BTM_BLE_META_PF_SRVC_DATA 0x07
  656. #define BTM_BLE_META_PF_ALL 0x08
  657. typedef UINT8 BTM_BLE_ADV_STATE;
  658. typedef UINT8 BTM_BLE_ADV_INFO_PRESENT;
  659. typedef UINT8 BTM_BLE_RSSI_VALUE;
  660. typedef UINT16 BTM_BLE_ADV_INFO_TIMESTAMP;
  661. /* These are the fields returned in each device adv packet. It
  662. ** is returned in the results callback if registered.
  663. */
  664. typedef struct {
  665. UINT8 conn_mode;
  666. tBTM_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */
  667. UINT8 flag;
  668. UINT8 tx_power_level;
  669. UINT8 remote_name_len;
  670. UINT8 *p_remote_name;
  671. tBTM_BLE_SERVICE service;
  672. } tBTM_BLE_INQ_DATA;
  673. enum {
  674. BTM_BLE_CONN_NONE,
  675. BTM_BLE_CONN_AUTO,
  676. BTM_BLE_CONN_SELECTIVE
  677. };
  678. typedef UINT8 tBTM_BLE_CONN_TYPE;
  679. #define ADV_INFO_PRESENT 0x00
  680. #define NO_ADV_INFO_PRESENT 0x01
  681. typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA;
  682. typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data);
  683. typedef UINT8 tBTM_BLE_TRACK_ADV_EVT;
  684. typedef struct {
  685. tBTM_BLE_REF_VALUE ref_value;
  686. tBTM_BLE_TRACK_ADV_CBACK *p_track_cback;
  687. } tBTM_BLE_ADV_TRACK_CB;
  688. enum {
  689. BTM_BLE_TRACK_ADV_ADD,
  690. BTM_BLE_TRACK_ADV_REMOVE
  691. };
  692. typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION;
  693. #define BTM_BLE_MULTI_ADV_INVALID 0
  694. #define BTM_BLE_BATCH_SCAN_ENABLE_EVT 1
  695. #define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT 2
  696. #define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3
  697. #define BTM_BLE_BATCH_SCAN_THR_EVT 4
  698. #define BTM_BLE_BATCH_SCAN_PARAM_EVT 5
  699. #define BTM_BLE_BATCH_SCAN_DISABLE_EVT 6
  700. typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT;
  701. typedef UINT32 tBTM_BLE_TX_TIME_MS;
  702. typedef UINT32 tBTM_BLE_RX_TIME_MS;
  703. typedef UINT32 tBTM_BLE_IDLE_TIME_MS;
  704. typedef UINT32 tBTM_BLE_ENERGY_USED;
  705. typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time,
  706. tBTM_BLE_IDLE_TIME_MS idle_time,
  707. tBTM_BLE_ENERGY_USED energy_used,
  708. tBTM_STATUS status);
  709. typedef struct {
  710. tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback;
  711. } tBTM_BLE_ENERGY_INFO_CB;
  712. typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
  713. typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status);
  714. /* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */
  715. typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data);
  716. typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match);
  717. /* random address set complete callback */
  718. typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
  719. typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
  720. typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status);
  721. tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
  722. /*****************************************************************************
  723. ** EXTERNAL FUNCTION DECLARATIONS
  724. *****************************************************************************/
  725. /*
  726. #ifdef __cplusplus
  727. extern "C" {
  728. #endif
  729. */
  730. /*******************************************************************************
  731. **
  732. ** Function BTM_SecAddBleDevice
  733. **
  734. ** Description Add/modify device. This function will be normally called
  735. ** during host startup to restore all required information
  736. ** for a LE device stored in the NVRAM.
  737. **
  738. ** Parameters: bd_addr - BD address of the peer
  739. ** bd_name - Name of the peer device. NULL if unknown.
  740. ** dev_type - Remote device's device type.
  741. ** addr_type - LE device address type.
  742. **
  743. ** Returns TRUE if added OK, else FALSE
  744. **
  745. *******************************************************************************/
  746. //extern
  747. BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
  748. tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type);
  749. /*******************************************************************************
  750. **
  751. ** Function BTM_SecAddBleKey
  752. **
  753. ** Description Add/modify LE device information. This function will be
  754. ** normally called during host startup to restore all required
  755. ** information stored in the NVRAM.
  756. **
  757. ** Parameters: bd_addr - BD address of the peer
  758. ** p_le_key - LE key values.
  759. ** key_type - LE SMP key type.
  760. *
  761. ** Returns TRUE if added OK, else FALSE
  762. **
  763. *******************************************************************************/
  764. //extern
  765. BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
  766. tBTM_LE_KEY_TYPE key_type);
  767. /*******************************************************************************
  768. **
  769. ** Function BTM_BleSetAdvParams
  770. **
  771. ** Description This function is called to set advertising parameters.
  772. **
  773. ** Parameters: None.
  774. **
  775. ** Returns void
  776. **
  777. *******************************************************************************/
  778. //extern
  779. tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
  780. tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
  781. /*******************************************************************************
  782. **
  783. ** Function BTM_BleSetAdvParamsStartAdv
  784. **
  785. ** Description This function is called to set all of the advertising parameters.
  786. **
  787. ** Parameters: None.
  788. **
  789. ** Returns void
  790. **
  791. *******************************************************************************/
  792. tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
  793. tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
  794. tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp);
  795. /*******************************************************************************
  796. **
  797. ** Function BTM_BleWriteAdvData
  798. **
  799. ** Description This function is called to write advertising data.
  800. **
  801. ** Parameters: None.
  802. **
  803. ** Returns void
  804. **
  805. *******************************************************************************/
  806. //extern
  807. tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
  808. tBTM_BLE_ADV_DATA *p_data);
  809. /*******************************************************************************
  810. **
  811. ** Function BTM_BleWriteAdvDataRaw
  812. **
  813. ** Description This function is called to write raw advertising data.
  814. **
  815. ** Parameters: p_raw_adv : point to raw advertising data
  816. ** raw_adv_len : raw advertising data
  817. **
  818. ** Returns BTM_SUCCESS means success.
  819. **
  820. *******************************************************************************/
  821. //extern
  822. tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
  823. BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr);
  824. /*******************************************************************************
  825. **
  826. ** Function BTM_BleSetAdvParams
  827. **
  828. ** Description This function is called to set advertising parameters.
  829. **
  830. ** Parameters adv_int_min: minimum advertising interval
  831. ** adv_int_max: maximum advertising interval
  832. ** p_dir_bda: connectable direct initiator's LE device address
  833. ** chnl_map: advertising channel map.
  834. **
  835. ** Returns void
  836. **
  837. *******************************************************************************/
  838. //extern
  839. void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max,
  840. tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map);
  841. /*******************************************************************************
  842. **
  843. ** Function BTM_BleObtainVendorCapabilities
  844. **
  845. ** Description This function is called to obatin vendor capabilties
  846. **
  847. ** Parameters p_cmn_vsc_cb - Returns the vednor capabilities
  848. **
  849. ** Returns void
  850. **
  851. *******************************************************************************/
  852. //extern
  853. void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
  854. /*******************************************************************************
  855. **
  856. ** Function BTM_BleSetScanParams
  857. **
  858. ** Description This function is called to set Scan parameters.
  859. **
  860. ** Parameters client_if - Client IF value
  861. ** scan_interval - Scan interval
  862. ** scan_window - Scan window
  863. ** scan_type - Scan type
  864. ** scan_setup_status_cback - Scan setup status callback
  865. **
  866. ** Returns void
  867. **
  868. *******************************************************************************/
  869. //extern
  870. void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval,
  871. UINT32 scan_window, tBLE_SCAN_MODE scan_type,
  872. tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
  873. /*******************************************************************************
  874. **
  875. ** Function BTM_BleSetScanFilterParams
  876. **
  877. ** Description This function is called to set Scan Filter & parameters.
  878. **
  879. ** Parameters client_if - Client IF value
  880. ** scan_interval - Scan interval
  881. ** scan_window - Scan window
  882. ** scan_type - Scan type
  883. ** addr_type_own - owner address type
  884. ** scan_filter_policy - scan filter policy
  885. ** scan_setup_status_cback - Scan setup status callback
  886. **
  887. ** Returns void
  888. **
  889. *******************************************************************************/
  890. void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
  891. tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, tBTM_BLE_SFP scan_filter_policy,
  892. tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
  893. /*******************************************************************************
  894. **
  895. ** Function BTM_BleGetVendorCapabilities
  896. **
  897. ** Description This function reads local LE features
  898. **
  899. ** Parameters p_cmn_vsc_cb : Locala LE capability structure
  900. **
  901. ** Returns void
  902. **
  903. *******************************************************************************/
  904. //extern
  905. void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb);
  906. /*******************************************************************************
  907. **
  908. ** Function BTM_BleSetStorageConfig
  909. **
  910. ** Description This function is called to setup storage configuration and setup callbacks.
  911. **
  912. ** Parameters UINT8 batch_scan_full_max -Batch scan full maximum
  913. UINT8 batch_scan_trunc_max - Batch scan truncated value maximum
  914. UINT8 batch_scan_notify_threshold - Threshold value
  915. tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback
  916. tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback
  917. void *p_ref - Reference value
  918. **
  919. ** Returns tBTM_STATUS
  920. **
  921. *******************************************************************************/
  922. //extern
  923. tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max,
  924. UINT8 batch_scan_trunc_max,
  925. UINT8 batch_scan_notify_threshold,
  926. tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback,
  927. tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
  928. tBTM_BLE_SCAN_REP_CBACK *p_cback,
  929. tBTM_BLE_REF_VALUE ref_value);
  930. /*******************************************************************************
  931. **
  932. ** Function BTM_BleEnableBatchScan
  933. **
  934. ** Description This function is called to enable batch scan
  935. **
  936. ** Parameters tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode
  937. UINT32 scan_interval -Scan interval
  938. UINT32 scan_window - Scan window value
  939. tBLE_ADDR_TYPE addr_type - Address type
  940. tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules
  941. **
  942. ** Returns tBTM_STATUS
  943. **
  944. *******************************************************************************/
  945. //extern
  946. tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
  947. UINT32 scan_interval, UINT32 scan_window,
  948. tBTM_BLE_DISCARD_RULE discard_rule,
  949. tBLE_ADDR_TYPE addr_type,
  950. tBTM_BLE_REF_VALUE ref_value);
  951. /*******************************************************************************
  952. **
  953. ** Function BTM_BleDisableBatchScan
  954. **
  955. ** Description This function is called to disable batch scanning
  956. **
  957. ** Parameters void
  958. **
  959. ** Returns void
  960. **
  961. *******************************************************************************/
  962. //extern
  963. tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value);
  964. /*******************************************************************************
  965. **
  966. ** Function BTM_BleReadScanReports
  967. **
  968. ** Description This function is called to read batch scan reports
  969. **
  970. ** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out
  971. tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback
  972. **
  973. ** Returns tBTM_STATUS
  974. **
  975. *******************************************************************************/
  976. //extern
  977. tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
  978. tBTM_BLE_REF_VALUE ref_value);
  979. /*******************************************************************************
  980. **
  981. ** Function BTM_BleTrackAdvertiser
  982. **
  983. ** Description This function is called to read batch scan reports
  984. **
  985. ** Parameters p_track_cback - Tracking callback
  986. ** ref_value - Reference value
  987. **
  988. ** Returns tBTM_STATUS
  989. **
  990. *******************************************************************************/
  991. //extern
  992. tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback,
  993. tBTM_BLE_REF_VALUE ref_value);
  994. /*******************************************************************************
  995. **
  996. ** Function BTM_BleWriteScanRsp
  997. **
  998. ** Description This function is called to write LE scan response.
  999. **
  1000. ** Parameters: p_scan_rsp: scan response.
  1001. **
  1002. ** Returns status
  1003. **
  1004. *******************************************************************************/
  1005. //extern
  1006. tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
  1007. tBTM_BLE_ADV_DATA *p_data);
  1008. /*******************************************************************************
  1009. **
  1010. ** Function BTM_BleWriteScanRspRaw
  1011. **
  1012. ** Description This function is called to write raw scan response data
  1013. **
  1014. ** Parameters: None.
  1015. **
  1016. ** Returns void
  1017. **
  1018. *******************************************************************************/
  1019. //extern
  1020. tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
  1021. /*******************************************************************************
  1022. **
  1023. ** Function BTM_BleObserve
  1024. **
  1025. ** Description This procedure keep the device listening for advertising
  1026. ** events from a broadcast device.
  1027. **
  1028. ** Parameters start: start or stop observe.
  1029. **
  1030. ** Returns void
  1031. **
  1032. *******************************************************************************/
  1033. //extern
  1034. tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration,
  1035. tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
  1036. /*******************************************************************************
  1037. **
  1038. ** Function BTM_GetDeviceIDRoot
  1039. **
  1040. ** Description This function is called to read the local device identity
  1041. ** root.
  1042. **
  1043. ** Returns void
  1044. ** the local device ER is copied into er
  1045. **
  1046. *******************************************************************************/
  1047. //extern
  1048. void BTM_GetDeviceIDRoot (BT_OCTET16 ir);
  1049. /*******************************************************************************
  1050. **
  1051. ** Function BTM_GetDeviceEncRoot
  1052. **
  1053. ** Description This function is called to read the local device encryption
  1054. ** root.
  1055. **
  1056. ** Returns void
  1057. ** the local device ER is copied into er
  1058. **
  1059. *******************************************************************************/
  1060. //extern
  1061. void BTM_GetDeviceEncRoot (BT_OCTET16 er);
  1062. /*******************************************************************************
  1063. **
  1064. ** Function BTM_GetDeviceDHK
  1065. **
  1066. ** Description This function is called to read the local device DHK.
  1067. **
  1068. ** Returns void
  1069. ** the local device DHK is copied into dhk
  1070. **
  1071. *******************************************************************************/
  1072. //extern
  1073. void BTM_GetDeviceDHK (BT_OCTET16 dhk);
  1074. /*******************************************************************************
  1075. **
  1076. ** Function BTM_SecurityGrant
  1077. **
  1078. ** Description This function is called to grant security process.
  1079. **
  1080. ** Parameters bd_addr - peer device bd address.
  1081. ** res - result of the operation BTM_SUCCESS if success.
  1082. ** Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts.
  1083. **
  1084. ** Returns None
  1085. **
  1086. *******************************************************************************/
  1087. //extern
  1088. void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res);
  1089. /*******************************************************************************
  1090. **
  1091. ** Function BTM_BlePasskeyReply
  1092. **
  1093. ** Description This function is called after Security Manager submitted
  1094. ** passkey request to the application.
  1095. **
  1096. ** Parameters: bd_addr - Address of the device for which passkey was requested
  1097. ** res - result of the operation SMP_SUCCESS if success
  1098. ** passkey - numeric value in the range of
  1099. ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
  1100. **
  1101. *******************************************************************************/
  1102. //extern
  1103. void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey);
  1104. /*******************************************************************************
  1105. **
  1106. ** Function BTM_BleConfirmReply
  1107. **
  1108. ** Description This function is called after Security Manager submitted
  1109. ** numeric comparison request to the application.
  1110. **
  1111. ** Parameters: bd_addr - Address of the device with which numeric
  1112. ** comparison was requested
  1113. ** res - comparison result BTM_SUCCESS if success
  1114. **
  1115. *******************************************************************************/
  1116. //extern
  1117. void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res);
  1118. /*******************************************************************************
  1119. **
  1120. ** Function BTM_LeOobDataReply
  1121. **
  1122. ** Description This function is called to provide the OOB data for
  1123. ** SMP in response to BTM_LE_OOB_REQ_EVT
  1124. **
  1125. ** Parameters: bd_addr - Address of the peer device
  1126. ** res - result of the operation SMP_SUCCESS if success
  1127. ** p_data - simple pairing Randomizer C.
  1128. **
  1129. *******************************************************************************/
  1130. //extern
  1131. void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data);
  1132. /*******************************************************************************
  1133. **
  1134. ** Function BTM_BleDataSignature
  1135. **
  1136. ** Description This function is called to sign the data using AES128 CMAC
  1137. ** algorith.
  1138. **
  1139. ** Parameter bd_addr: target device the data to be signed for.
  1140. ** p_text: singing data
  1141. ** len: length of the signing data
  1142. ** signature: output parameter where data signature is going to
  1143. ** be stored.
  1144. **
  1145. ** Returns TRUE if signing sucessul, otherwise FALSE.
  1146. **
  1147. *******************************************************************************/
  1148. //extern
  1149. BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
  1150. BLE_SIGNATURE signature);
  1151. /*******************************************************************************
  1152. **
  1153. ** Function BTM_BleVerifySignature
  1154. **
  1155. ** Description This function is called to verify the data signature
  1156. **
  1157. ** Parameter bd_addr: target device the data to be signed for.
  1158. ** p_orig: original data before signature.
  1159. ** len: length of the signing data
  1160. ** counter: counter used when doing data signing
  1161. ** p_comp: signature to be compared against.
  1162. ** Returns TRUE if signature verified correctly; otherwise FALSE.
  1163. **
  1164. *******************************************************************************/
  1165. //extern
  1166. BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig,
  1167. UINT16 len, UINT32 counter,
  1168. UINT8 *p_comp);
  1169. /*******************************************************************************
  1170. **
  1171. ** Function BTM_ReadConnectionAddr
  1172. **
  1173. ** Description This function is called to set the local device random address
  1174. ** .
  1175. **
  1176. ** Returns void
  1177. **
  1178. *******************************************************************************/
  1179. //extern
  1180. void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr,
  1181. tBLE_ADDR_TYPE *p_addr_type);
  1182. /*******************************************************************************
  1183. **
  1184. ** Function BTM_ReadRemoteConnectionAddr
  1185. **
  1186. ** Description This function is read the remote device address currently used
  1187. ** .
  1188. **
  1189. ** Returns void
  1190. **
  1191. *******************************************************************************/
  1192. //extern
  1193. BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr,
  1194. BD_ADDR conn_addr,
  1195. tBLE_ADDR_TYPE *p_addr_type);
  1196. /*******************************************************************************
  1197. **
  1198. ** Function BTM_BleLoadLocalKeys
  1199. **
  1200. ** Description Local local identity key, encryption root or sign counter.
  1201. **
  1202. ** Parameters: key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER
  1203. ** or BTM_BLE_KEY_TYPE_COUNTER.
  1204. ** p_key: pointer to the key.
  1205. *
  1206. ** Returns non2.
  1207. **
  1208. *******************************************************************************/
  1209. //extern
  1210. void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
  1211. /*******************************************************************************
  1212. **
  1213. ** Function BTM_BleSetBgConnType
  1214. **
  1215. ** Description This function is called to set BLE background connection
  1216. ** procedure type. It can be auto connection, or selective connection.
  1217. **
  1218. ** Parameters conn_type: it can be auto connection, or selective connection.
  1219. ** p_select_cback: callback function when selective connection procedure
  1220. ** is being used.
  1221. **
  1222. ** Returns void
  1223. **
  1224. *******************************************************************************/
  1225. //extern
  1226. BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type,
  1227. tBTM_BLE_SEL_CBACK *p_select_cback);
  1228. /*******************************************************************************
  1229. **
  1230. ** Function BTM_BleUpdateBgConnDev
  1231. **
  1232. ** Description This function is called to add or remove a device into/from
  1233. ** background connection procedure. The background connection
  1234. * procedure is decided by the background connection type, it can be
  1235. * auto connection, or selective connection.
  1236. **
  1237. ** Parameters add_remove: TRUE to add; FALSE to remove.
  1238. ** remote_bda: device address to add/remove.
  1239. **
  1240. ** Returns void
  1241. **
  1242. *******************************************************************************/
  1243. //extern
  1244. BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda);
  1245. /*******************************************************************************
  1246. **
  1247. ** Function BTM_BleClearBgConnDev
  1248. **
  1249. ** Description This function is called to clear the whitelist,
  1250. ** end any pending whitelist connections,
  1251. * and reset the local bg device list.
  1252. **
  1253. ** Parameters void
  1254. **
  1255. ** Returns void
  1256. **
  1257. *******************************************************************************/
  1258. //extern
  1259. void BTM_BleClearBgConnDev(void);
  1260. /********************************************************
  1261. **
  1262. ** Function BTM_BleSetPrefConnParams
  1263. **
  1264. ** Description Set a peripheral's preferred connection parameters. When
  1265. ** any of the value does not want to be updated while others
  1266. ** do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
  1267. ** leave untouched.
  1268. **
  1269. ** Parameters: bd_addr - BD address of the peripheral
  1270. ** min_conn_int - minimum preferred connection interval
  1271. ** max_conn_int - maximum preferred connection interval
  1272. ** slave_latency - preferred slave latency
  1273. ** supervision_tout - preferred supervision timeout
  1274. **
  1275. ** Returns void
  1276. **
  1277. *******************************************************************************/
  1278. //extern
  1279. void BTM_BleSetPrefConnParams (BD_ADDR bd_addr,
  1280. UINT16 min_conn_int, UINT16 max_conn_int,
  1281. UINT16 slave_latency, UINT16 supervision_tout);
  1282. /******************************************************************************
  1283. **
  1284. ** Function BTM_BleSetConnScanParams
  1285. **
  1286. ** Description Set scan parameters used in BLE connection request
  1287. **
  1288. ** Parameters: scan_interval - scan interval
  1289. ** scan_window - scan window
  1290. **
  1291. ** Returns void
  1292. **
  1293. *******************************************************************************/
  1294. //extern
  1295. void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window);
  1296. /******************************************************************************
  1297. **
  1298. ** Function BTM_BleReadControllerFeatures
  1299. **
  1300. ** Description Reads BLE specific controller features
  1301. **
  1302. ** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read
  1303. **
  1304. ** Returns void
  1305. **
  1306. *******************************************************************************/
  1307. //extern
  1308. void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
  1309. /*******************************************************************************
  1310. **
  1311. ** Function BTM_CheckAdvData
  1312. **
  1313. ** Description This function is called to get ADV data for a specific type.
  1314. **
  1315. ** Parameters p_adv - pointer of ADV data
  1316. ** type - finding ADV data type
  1317. ** p_length - return the length of ADV data not including type
  1318. **
  1319. ** Returns pointer of ADV data
  1320. **
  1321. *******************************************************************************/
  1322. //extern
  1323. UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
  1324. /*******************************************************************************
  1325. **
  1326. ** Function BTM__BLEReadDiscoverability
  1327. **
  1328. ** Description This function is called to read the current LE discoverability
  1329. ** mode of the device.
  1330. **
  1331. ** Returns BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
  1332. ** BTM_BLE_GENRAL_DISCOVERABLE
  1333. **
  1334. *******************************************************************************/
  1335. UINT16 BTM_BleReadDiscoverability();
  1336. /*******************************************************************************
  1337. **
  1338. ** Function BTM__BLEReadConnectability
  1339. **
  1340. ** Description This function is called to read the current LE connectibility
  1341. ** mode of the device.
  1342. **
  1343. ** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
  1344. **
  1345. *******************************************************************************/
  1346. //extern
  1347. UINT16 BTM_BleReadConnectability ();
  1348. /*******************************************************************************
  1349. **
  1350. ** Function BTM_ReadDevInfo
  1351. **
  1352. ** Description This function is called to read the device/address type
  1353. ** of BD address.
  1354. **
  1355. ** Parameter remote_bda: remote device address
  1356. ** p_dev_type: output parameter to read the device type.
  1357. ** p_addr_type: output parameter to read the address type.
  1358. **
  1359. *******************************************************************************/
  1360. //extern
  1361. void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type,
  1362. tBLE_ADDR_TYPE *p_addr_type);
  1363. /*******************************************************************************
  1364. **
  1365. ** Function BTM_ReadConnectedTransportAddress
  1366. **
  1367. ** Description This function is called to read the paired device/address type of other device paired
  1368. ** corresponding to the BD_address
  1369. **
  1370. ** Parameter remote_bda: remote device address, carry out the transport address
  1371. ** transport: active transport
  1372. **
  1373. ** Return TRUE if an active link is identified; FALSE otherwise
  1374. **
  1375. *******************************************************************************/
  1376. //extern
  1377. BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
  1378. tBT_TRANSPORT transport);
  1379. /*******************************************************************************
  1380. **
  1381. ** Function BTM_BleBroadcast
  1382. **
  1383. ** Description This function is to start or stop broadcasting.
  1384. **
  1385. ** Parameters start: start or stop broadcasting.
  1386. **
  1387. ** Returns status.
  1388. **
  1389. *******************************************************************************/
  1390. //extern
  1391. tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
  1392. /*******************************************************************************
  1393. **
  1394. ** Function BTM_BleConfigPrivacy
  1395. **
  1396. ** Description This function is called to enable or disable the privacy in
  1397. ** the local device.
  1398. **
  1399. ** Parameters enable: TRUE to enable it; FALSE to disable it.
  1400. **
  1401. ** Returns BOOLEAN privacy mode set success; otherwise failed.
  1402. **
  1403. *******************************************************************************/
  1404. //extern
  1405. BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable);
  1406. /*******************************************************************************
  1407. **
  1408. ** Function BTM_BleLocalPrivacyEnabled
  1409. **
  1410. ** Description Checks if local device supports private address
  1411. **
  1412. ** Returns Return TRUE if local privacy is enabled else FALSE
  1413. **
  1414. *******************************************************************************/
  1415. //extern
  1416. BOOLEAN BTM_BleLocalPrivacyEnabled(void);
  1417. /*******************************************************************************
  1418. **
  1419. ** Function BTM_BleEnableMixedPrivacyMode
  1420. **
  1421. ** Description This function is called to enabled Mixed mode if privacy 1.2
  1422. ** is applicable in controller.
  1423. **
  1424. ** Parameters mixed_on: mixed mode to be used or not.
  1425. **
  1426. ** Returns void
  1427. **
  1428. *******************************************************************************/
  1429. //extern
  1430. void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on);
  1431. /*******************************************************************************
  1432. **
  1433. ** Function BTM_BleMaxMultiAdvInstanceCount
  1434. **
  1435. ** Description Returns max number of multi adv instances supported by controller
  1436. **
  1437. ** Returns Max multi adv instance count
  1438. **
  1439. *******************************************************************************/
  1440. //extern
  1441. UINT8 BTM_BleMaxMultiAdvInstanceCount();
  1442. /*******************************************************************************
  1443. **
  1444. ** Function BTM_BleSetConnectableMode
  1445. **
  1446. ** Description This function is called to set BLE connectable mode for a
  1447. ** peripheral device.
  1448. **
  1449. ** Parameters connectable_mode: directed connectable mode, or non-directed.It can
  1450. ** be BTM_BLE_CONNECT_EVT, BTM_BLE_CONNECT_DIR_EVT or
  1451. ** BTM_BLE_CONNECT_LO_DUTY_DIR_EVT
  1452. **
  1453. ** Returns BTM_ILLEGAL_VALUE if controller does not support BLE.
  1454. ** BTM_SUCCESS is status set successfully; otherwise failure.
  1455. **
  1456. *******************************************************************************/
  1457. //extern
  1458. tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode);
  1459. /*******************************************************************************
  1460. **
  1461. ** Function BTM_BleTurnOnPrivacyOnRemote
  1462. **
  1463. ** Description This function is called to enable or disable the privacy on the
  1464. ** remote device.
  1465. **
  1466. ** Parameters bd_addr: remote device address.
  1467. ** privacy_on: TRUE to enable it; FALSE to disable it.
  1468. **
  1469. ** Returns void
  1470. **
  1471. *******************************************************************************/
  1472. //extern
  1473. void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
  1474. BOOLEAN privacy_on);
  1475. /*******************************************************************************
  1476. **
  1477. ** Function BTM_BleUpdateAdvWhitelist
  1478. **
  1479. ** Description Add or remove device from advertising white list
  1480. **
  1481. ** Returns void
  1482. **
  1483. *******************************************************************************/
  1484. //extern
  1485. BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda);
  1486. /*******************************************************************************
  1487. **
  1488. ** Function BTM_BleUpdateAdvFilterPolicy
  1489. **
  1490. ** Description This function update the filter policy of advertiser.
  1491. **
  1492. ** Parameter adv_policy: advertising filter policy
  1493. **
  1494. ** Return void
  1495. *******************************************************************************/
  1496. //extern
  1497. void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
  1498. /*******************************************************************************
  1499. **
  1500. ** Function BTM_BleReceiverTest
  1501. **
  1502. ** Description This function is called to start the LE Receiver test
  1503. **
  1504. ** Parameter rx_freq - Frequency Range
  1505. ** p_cmd_cmpl_cback - Command Complete callback
  1506. **
  1507. *******************************************************************************/
  1508. void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback);
  1509. /*******************************************************************************
  1510. **
  1511. ** Function BTM_BleTransmitterTest
  1512. **
  1513. ** Description This function is called to start the LE Transmitter test
  1514. **
  1515. ** Parameter tx_freq - Frequency Range
  1516. ** test_data_len - Length in bytes of payload data in each packet
  1517. ** packet_payload - Pattern to use in the payload
  1518. ** p_cmd_cmpl_cback - Command Complete callback
  1519. **
  1520. *******************************************************************************/
  1521. void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len,
  1522. UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback);
  1523. /*******************************************************************************
  1524. **
  1525. ** Function BTM_BleTestEnd
  1526. **
  1527. ** Description This function is called to stop the in-progress TX or RX test
  1528. **
  1529. ** Parameter p_cmd_cmpl_cback - Command complete callback
  1530. **
  1531. *******************************************************************************/
  1532. void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback);
  1533. /*******************************************************************************
  1534. **
  1535. ** Function BTM_UseLeLink
  1536. **
  1537. ** Description This function is to select the underneath physical link to use.
  1538. **
  1539. ** Returns TRUE to use LE, FALSE use BR/EDR.
  1540. **
  1541. *******************************************************************************/
  1542. //extern
  1543. BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr);
  1544. /*******************************************************************************
  1545. **
  1546. ** Function BTM_BleStackEnable
  1547. **
  1548. ** Description Enable/Disable BLE functionality on stack regarless controller
  1549. ** capability.
  1550. **
  1551. ** Parameters: enable: TRUE to enable, FALSE to disable.
  1552. **
  1553. ** Returns TRUE if added OK, else FALSE
  1554. **
  1555. *******************************************************************************/
  1556. //extern
  1557. tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable);
  1558. /*******************************************************************************
  1559. **
  1560. ** Function BTM_GetLeSecurityState
  1561. **
  1562. ** Description This function is called to get security mode 1 flags and
  1563. ** encryption key size for LE peer.
  1564. **
  1565. ** Returns BOOLEAN TRUE if LE device is found, FALSE otherwise.
  1566. **
  1567. *******************************************************************************/
  1568. //extern
  1569. BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr,
  1570. UINT8 *p_le_dev_sec_flags,
  1571. UINT8 *p_le_key_size);
  1572. /*******************************************************************************
  1573. **
  1574. ** Function BTM_BleSecurityProcedureIsRunning
  1575. **
  1576. ** Description This function indicates if LE security procedure is
  1577. ** currently running with the peer.
  1578. **
  1579. ** Returns BOOLEAN TRUE if security procedure is running, FALSE otherwise.
  1580. **
  1581. *******************************************************************************/
  1582. //extern
  1583. BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr);
  1584. /*******************************************************************************
  1585. **
  1586. ** Function BTM_BleGetSupportedKeySize
  1587. **
  1588. ** Description This function gets the maximum encryption key size in bytes
  1589. ** the local device can suport.
  1590. ** record.
  1591. **
  1592. ** Returns the key size or 0 if the size can't be retrieved.
  1593. **
  1594. *******************************************************************************/
  1595. //extern
  1596. UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr);
  1597. /*******************************************************************************/
  1598. /* Multi ADV API */
  1599. /*******************************************************************************
  1600. **
  1601. ** Function BTM_BleEnableAdvInstance
  1602. **
  1603. ** Description This function enable a Multi-ADV instance with the specified
  1604. ** adv parameters
  1605. **
  1606. ** Parameters p_params: pointer to the adv parameter structure, set as default
  1607. ** adv parameter when the instance is enabled.
  1608. ** p_cback: callback function for the adv instance.
  1609. ** p_ref: reference data attach to the adv instance to be enabled.
  1610. **
  1611. ** Returns status
  1612. **
  1613. *******************************************************************************/
  1614. //extern
  1615. tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params,
  1616. tBTM_BLE_MULTI_ADV_CBACK *p_cback,
  1617. void *p_ref);
  1618. /*******************************************************************************
  1619. **
  1620. ** Function BTM_BleUpdateAdvInstParam
  1621. **
  1622. ** Description This function update a Multi-ADV instance with the specififed
  1623. ** adv parameters.
  1624. **
  1625. ** Parameters inst_id: adv instance ID
  1626. ** p_params: pointer to the adv parameter structure.
  1627. **
  1628. ** Returns status
  1629. **
  1630. *******************************************************************************/
  1631. //extern
  1632. tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params);
  1633. /*******************************************************************************
  1634. **
  1635. ** Function BTM_BleCfgAdvInstData
  1636. **
  1637. ** Description This function configure a Multi-ADV instance with the specified
  1638. ** adv data or scan response data.
  1639. **
  1640. ** Parameters inst_id: adv instance ID
  1641. ** is_scan_rsp: is this scacn response, if no set as adv data.
  1642. ** data_mask: adv data mask.
  1643. ** p_data: pointer to the adv data structure.
  1644. **
  1645. ** Returns status
  1646. **
  1647. *******************************************************************************/
  1648. //extern
  1649. tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
  1650. tBTM_BLE_AD_MASK data_mask,
  1651. tBTM_BLE_ADV_DATA *p_data);
  1652. /*******************************************************************************
  1653. **
  1654. ** Function BTM_BleDisableAdvInstance
  1655. **
  1656. ** Description This function disable a Multi-ADV instance.
  1657. **
  1658. ** Parameters inst_id: adv instance ID
  1659. **
  1660. ** Returns status
  1661. **
  1662. *******************************************************************************/
  1663. //extern
  1664. tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id);
  1665. /*******************************************************************************
  1666. **
  1667. ** Function BTM_BleAdvFilterParamSetup
  1668. **
  1669. ** Description This function is called to setup the adv data payload filter
  1670. ** condition.
  1671. **
  1672. ** Parameters p_target: enabble the filter condition on a target device; if NULL
  1673. ** enable the generic scan condition.
  1674. ** enable: enable or disable the filter condition
  1675. **
  1676. ** Returns void
  1677. **
  1678. *******************************************************************************/
  1679. //extern
  1680. tBTM_STATUS BTM_BleAdvFilterParamSetup(int action,
  1681. tBTM_BLE_PF_FILT_INDEX filt_index,
  1682. tBTM_BLE_PF_FILT_PARAMS *p_filt_params,
  1683. tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
  1684. tBTM_BLE_REF_VALUE ref_value);
  1685. /*******************************************************************************
  1686. **
  1687. ** Function BTM_BleCfgFilterCondition
  1688. **
  1689. ** Description This function is called to configure the adv data payload filter
  1690. ** condition.
  1691. **
  1692. ** Parameters action: to read/write/clear
  1693. ** cond_type: filter condition type.
  1694. ** p_cond: filter condition paramter
  1695. **
  1696. ** Returns tBTM_STATUS
  1697. **
  1698. *******************************************************************************/
  1699. //extern
  1700. tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action,
  1701. tBTM_BLE_PF_COND_TYPE cond_type,
  1702. tBTM_BLE_PF_FILT_INDEX filt_index,
  1703. tBTM_BLE_PF_COND_PARAM *p_cond,
  1704. tBTM_BLE_PF_CFG_CBACK *p_cmpl_cback,
  1705. tBTM_BLE_REF_VALUE ref_value);
  1706. /*******************************************************************************
  1707. **
  1708. ** Function BTM_BleEnableDisableFilterFeature
  1709. **
  1710. ** Description This function is called to enable or disable the APCF feature
  1711. **
  1712. ** Parameters enable - TRUE - enables the APCF, FALSE - disables the APCF
  1713. ** ref_value - Ref value
  1714. **
  1715. ** Returns tBTM_STATUS
  1716. **
  1717. *******************************************************************************/
  1718. //extern
  1719. tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable,
  1720. tBTM_BLE_PF_STATUS_CBACK *p_stat_cback,
  1721. tBTM_BLE_REF_VALUE ref_value);
  1722. /*******************************************************************************
  1723. **
  1724. ** Function BTM_BleGetEnergyInfo
  1725. **
  1726. ** Description This function obtains the energy info
  1727. **
  1728. ** Parameters p_ener_cback - Callback pointer
  1729. **
  1730. ** Returns status
  1731. **
  1732. *******************************************************************************/
  1733. //extern
  1734. tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback);
  1735. /*******************************************************************************
  1736. **
  1737. ** Function BTM_SetBleDataLength
  1738. **
  1739. ** Description This function is called to set maximum BLE transmission packet size
  1740. **
  1741. ** Returns BTM_SUCCESS if success; otherwise failed.
  1742. **
  1743. *******************************************************************************/
  1744. //extern
  1745. tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length);
  1746. /*
  1747. #ifdef __cplusplus
  1748. }
  1749. #endif
  1750. */
  1751. #endif