btm_ble_api.h 74 KB

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