hcimsgs.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /******************************************************************************
  2. *
  3. * Copyright 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. #ifndef HCIMSGS_H
  19. #define HCIMSGS_H
  20. #include "bt_target.h"
  21. #include "bt_types.h"
  22. #include "device/include/esco_parameters.h"
  23. #include "hcidefs.h"
  24. #include <base/callback_forward.h>
  25. void bte_main_hci_send(BT_HDR* p_msg, uint16_t event);
  26. /* Message by message.... */
  27. extern void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration,
  28. uint8_t response_cnt);
  29. #define HCIC_PARAM_SIZE_INQUIRY 5
  30. #define HCIC_INQ_INQ_LAP_OFF 0
  31. #define HCIC_INQ_DUR_OFF 3
  32. #define HCIC_INQ_RSP_CNT_OFF 4
  33. /* Inquiry */
  34. /* Inquiry Cancel */
  35. extern void btsnd_hcic_inq_cancel(void);
  36. #define HCIC_PARAM_SIZE_INQ_CANCEL 0
  37. /* Periodic Inquiry Mode */
  38. extern void btsnd_hcic_per_inq_mode(uint16_t max_period, uint16_t min_period,
  39. const LAP inq_lap, uint8_t duration,
  40. uint8_t response_cnt);
  41. #define HCIC_PARAM_SIZE_PER_INQ_MODE 9
  42. #define HCI_PER_INQ_MAX_INTRVL_OFF 0
  43. #define HCI_PER_INQ_MIN_INTRVL_OFF 2
  44. #define HCI_PER_INQ_INQ_LAP_OFF 4
  45. #define HCI_PER_INQ_DURATION_OFF 7
  46. #define HCI_PER_INQ_RSP_CNT_OFF 8
  47. /* Periodic Inquiry Mode */
  48. /* Exit Periodic Inquiry Mode */
  49. extern void btsnd_hcic_exit_per_inq(void);
  50. #define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
  51. /* Create Connection */
  52. extern void btsnd_hcic_create_conn(const RawAddress& dest,
  53. uint16_t packet_types,
  54. uint8_t page_scan_rep_mode,
  55. uint8_t page_scan_mode,
  56. uint16_t clock_offset, uint8_t allow_switch);
  57. #define HCIC_PARAM_SIZE_CREATE_CONN 13
  58. #define HCIC_CR_CONN_BD_ADDR_OFF 0
  59. #define HCIC_CR_CONN_PKT_TYPES_OFF 6
  60. #define HCIC_CR_CONN_REP_MODE_OFF 8
  61. #define HCIC_CR_CONN_PAGE_SCAN_MODE_OFF 9
  62. #define HCIC_CR_CONN_CLK_OFF_OFF 10
  63. #define HCIC_CR_CONN_ALLOW_SWITCH_OFF 12
  64. /* Create Connection */
  65. /* Disconnect */
  66. extern void btsnd_hcic_disconnect(uint16_t handle, uint8_t reason);
  67. #define HCIC_PARAM_SIZE_DISCONNECT 3
  68. #define HCI_DISC_HANDLE_OFF 0
  69. #define HCI_DISC_REASON_OFF 2
  70. /* Disconnect */
  71. /* Add SCO Connection */
  72. extern void btsnd_hcic_add_SCO_conn(uint16_t handle, uint16_t packet_types);
  73. #define HCIC_PARAM_SIZE_ADD_SCO_CONN 4
  74. #define HCI_ADD_SCO_HANDLE_OFF 0
  75. #define HCI_ADD_SCO_PACKET_TYPES_OFF 2
  76. /* Add SCO Connection */
  77. /* Create Connection Cancel */
  78. extern void btsnd_hcic_create_conn_cancel(const RawAddress& dest);
  79. #define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6
  80. #define HCIC_CR_CONN_CANCEL_BD_ADDR_OFF 0
  81. /* Create Connection Cancel */
  82. /* Accept Connection Request */
  83. extern void btsnd_hcic_accept_conn(const RawAddress& bd_addr, uint8_t role);
  84. #define HCIC_PARAM_SIZE_ACCEPT_CONN 7
  85. #define HCI_ACC_CONN_BD_ADDR_OFF 0
  86. #define HCI_ACC_CONN_ROLE_OFF 6
  87. /* Accept Connection Request */
  88. /* Reject Connection Request */
  89. extern void btsnd_hcic_reject_conn(const RawAddress& bd_addr, uint8_t reason);
  90. #define HCIC_PARAM_SIZE_REJECT_CONN 7
  91. #define HCI_REJ_CONN_BD_ADDR_OFF 0
  92. #define HCI_REJ_CONN_REASON_OFF 6
  93. /* Reject Connection Request */
  94. /* Link Key Request Reply */
  95. extern void btsnd_hcic_link_key_req_reply(const RawAddress& bd_addr,
  96. const LinkKey& link_key);
  97. #define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22
  98. #define HCI_LINK_KEY_REPLY_BD_ADDR_OFF 0
  99. #define HCI_LINK_KEY_REPLY_LINK_KEY_OFF 6
  100. /* Link Key Request Reply */
  101. /* Link Key Request Neg Reply */
  102. extern void btsnd_hcic_link_key_neg_reply(const RawAddress& bd_addr);
  103. #define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6
  104. #define HCI_LINK_KEY_NEG_REP_BD_ADR_OFF 0
  105. /* Link Key Request Neg Reply */
  106. /* PIN Code Request Reply */
  107. extern void btsnd_hcic_pin_code_req_reply(const RawAddress& bd_addr,
  108. uint8_t pin_code_len,
  109. PIN_CODE pin_code);
  110. #define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23
  111. #define HCI_PIN_CODE_REPLY_BD_ADDR_OFF 0
  112. #define HCI_PIN_CODE_REPLY_PIN_LEN_OFF 6
  113. #define HCI_PIN_CODE_REPLY_PIN_CODE_OFF 7
  114. /* PIN Code Request Reply */
  115. /* Link Key Request Neg Reply */
  116. extern void btsnd_hcic_pin_code_neg_reply(const RawAddress& bd_addr);
  117. #define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6
  118. #define HCI_PIN_CODE_NEG_REP_BD_ADR_OFF 0
  119. /* Link Key Request Neg Reply */
  120. /* Change Connection Type */
  121. extern void btsnd_hcic_change_conn_type(uint16_t handle, uint16_t packet_types);
  122. #define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4
  123. #define HCI_CHNG_PKT_TYPE_HANDLE_OFF 0
  124. #define HCI_CHNG_PKT_TYPE_PKT_TYPE_OFF 2
  125. /* Change Connection Type */
  126. #define HCIC_PARAM_SIZE_CMD_HANDLE 2
  127. #define HCI_CMD_HANDLE_HANDLE_OFF 0
  128. extern void btsnd_hcic_auth_request(
  129. uint16_t handle); /* Authentication Request */
  130. /* Set Connection Encryption */
  131. extern void btsnd_hcic_set_conn_encrypt(uint16_t handle, bool enable);
  132. #define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3
  133. #define HCI_SET_ENCRYPT_HANDLE_OFF 0
  134. #define HCI_SET_ENCRYPT_ENABLE_OFF 2
  135. /* Set Connection Encryption */
  136. /* Remote Name Request */
  137. extern void btsnd_hcic_rmt_name_req(const RawAddress& bd_addr,
  138. uint8_t page_scan_rep_mode,
  139. uint8_t page_scan_mode,
  140. uint16_t clock_offset);
  141. #define HCIC_PARAM_SIZE_RMT_NAME_REQ 10
  142. #define HCI_RMT_NAME_BD_ADDR_OFF 0
  143. #define HCI_RMT_NAME_REP_MODE_OFF 6
  144. #define HCI_RMT_NAME_PAGE_SCAN_MODE_OFF 7
  145. #define HCI_RMT_NAME_CLK_OFF_OFF 8
  146. /* Remote Name Request */
  147. /* Remote Name Request Cancel */
  148. extern void btsnd_hcic_rmt_name_req_cancel(const RawAddress& bd_addr);
  149. #define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6
  150. #define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0
  151. /* Remote Name Request Cancel */
  152. extern void btsnd_hcic_rmt_features_req(
  153. uint16_t handle); /* Remote Features Request */
  154. /* Remote Extended Features */
  155. extern void btsnd_hcic_rmt_ext_features(uint16_t handle, uint8_t page_num);
  156. #define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3
  157. #define HCI_RMT_EXT_FEATURES_HANDLE_OFF 0
  158. #define HCI_RMT_EXT_FEATURES_PAGE_NUM_OFF 2
  159. /* Remote Extended Features */
  160. extern void btsnd_hcic_rmt_ver_req(
  161. uint16_t handle); /* Remote Version Info Request */
  162. extern void btsnd_hcic_read_rmt_clk_offset(
  163. uint16_t handle); /* Remote Clock Offset */
  164. extern void btsnd_hcic_read_lmp_handle(uint16_t handle); /* Remote LMP Handle */
  165. extern void btsnd_hcic_setup_esco_conn(uint16_t handle,
  166. uint32_t transmit_bandwidth,
  167. uint32_t receive_bandwidth,
  168. uint16_t max_latency, uint16_t voice,
  169. uint8_t retrans_effort,
  170. uint16_t packet_types);
  171. #define HCIC_PARAM_SIZE_SETUP_ESCO 17
  172. #define HCI_SETUP_ESCO_HANDLE_OFF 0
  173. #define HCI_SETUP_ESCO_TX_BW_OFF 2
  174. #define HCI_SETUP_ESCO_RX_BW_OFF 6
  175. #define HCI_SETUP_ESCO_MAX_LAT_OFF 10
  176. #define HCI_SETUP_ESCO_VOICE_OFF 12
  177. #define HCI_SETUP_ESCO_RETRAN_EFF_OFF 14
  178. #define HCI_SETUP_ESCO_PKT_TYPES_OFF 15
  179. extern void btsnd_hcic_accept_esco_conn(
  180. const RawAddress& bd_addr, uint32_t transmit_bandwidth,
  181. uint32_t receive_bandwidth, uint16_t max_latency, uint16_t content_fmt,
  182. uint8_t retrans_effort, uint16_t packet_types);
  183. #define HCIC_PARAM_SIZE_ACCEPT_ESCO 21
  184. #define HCI_ACCEPT_ESCO_BDADDR_OFF 0
  185. #define HCI_ACCEPT_ESCO_TX_BW_OFF 6
  186. #define HCI_ACCEPT_ESCO_RX_BW_OFF 10
  187. #define HCI_ACCEPT_ESCO_MAX_LAT_OFF 14
  188. #define HCI_ACCEPT_ESCO_VOICE_OFF 16
  189. #define HCI_ACCEPT_ESCO_RETRAN_EFF_OFF 18
  190. #define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19
  191. extern void btsnd_hcic_reject_esco_conn(const RawAddress& bd_addr,
  192. uint8_t reason);
  193. #define HCIC_PARAM_SIZE_REJECT_ESCO 7
  194. #define HCI_REJECT_ESCO_BDADDR_OFF 0
  195. #define HCI_REJECT_ESCO_REASON_OFF 6
  196. /* Hold Mode */
  197. extern void btsnd_hcic_hold_mode(uint16_t handle, uint16_t max_hold_period,
  198. uint16_t min_hold_period);
  199. #define HCIC_PARAM_SIZE_HOLD_MODE 6
  200. #define HCI_HOLD_MODE_HANDLE_OFF 0
  201. #define HCI_HOLD_MODE_MAX_PER_OFF 2
  202. #define HCI_HOLD_MODE_MIN_PER_OFF 4
  203. /* Hold Mode */
  204. /* Sniff Mode */
  205. extern void btsnd_hcic_sniff_mode(uint16_t handle, uint16_t max_sniff_period,
  206. uint16_t min_sniff_period,
  207. uint16_t sniff_attempt,
  208. uint16_t sniff_timeout);
  209. #define HCIC_PARAM_SIZE_SNIFF_MODE 10
  210. #define HCI_SNIFF_MODE_HANDLE_OFF 0
  211. #define HCI_SNIFF_MODE_MAX_PER_OFF 2
  212. #define HCI_SNIFF_MODE_MIN_PER_OFF 4
  213. #define HCI_SNIFF_MODE_ATTEMPT_OFF 6
  214. #define HCI_SNIFF_MODE_TIMEOUT_OFF 8
  215. /* Sniff Mode */
  216. extern void btsnd_hcic_exit_sniff_mode(uint16_t handle); /* Exit Sniff Mode */
  217. /* Park Mode */
  218. extern void btsnd_hcic_park_mode(uint16_t handle, uint16_t beacon_max_interval,
  219. uint16_t beacon_min_interval);
  220. #define HCIC_PARAM_SIZE_PARK_MODE 6
  221. #define HCI_PARK_MODE_HANDLE_OFF 0
  222. #define HCI_PARK_MODE_MAX_PER_OFF 2
  223. #define HCI_PARK_MODE_MIN_PER_OFF 4
  224. /* Park Mode */
  225. extern void btsnd_hcic_exit_park_mode(uint16_t handle); /* Exit Park Mode */
  226. /* QoS Setup */
  227. extern void btsnd_hcic_qos_setup(uint16_t handle, uint8_t flags,
  228. uint8_t service_type, uint32_t token_rate,
  229. uint32_t peak, uint32_t latency,
  230. uint32_t delay_var);
  231. #define HCIC_PARAM_SIZE_QOS_SETUP 20
  232. #define HCI_QOS_HANDLE_OFF 0
  233. #define HCI_QOS_FLAGS_OFF 2
  234. #define HCI_QOS_SERVICE_TYPE_OFF 3
  235. #define HCI_QOS_TOKEN_RATE_OFF 4
  236. #define HCI_QOS_PEAK_BANDWIDTH_OFF 8
  237. #define HCI_QOS_LATENCY_OFF 12
  238. #define HCI_QOS_DELAY_VAR_OFF 16
  239. /* QoS Setup */
  240. /* Switch Role Request */
  241. extern void btsnd_hcic_switch_role(const RawAddress& bd_addr, uint8_t role);
  242. #define HCIC_PARAM_SIZE_SWITCH_ROLE 7
  243. #define HCI_SWITCH_BD_ADDR_OFF 0
  244. #define HCI_SWITCH_ROLE_OFF 6
  245. /* Switch Role Request */
  246. /* Write Policy Settings */
  247. extern void btsnd_hcic_write_policy_set(uint16_t handle, uint16_t settings);
  248. #define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4
  249. #define HCI_WRITE_POLICY_HANDLE_OFF 0
  250. #define HCI_WRITE_POLICY_SETTINGS_OFF 2
  251. /* Write Policy Settings */
  252. /* Write Default Policy Settings */
  253. extern void btsnd_hcic_write_def_policy_set(uint16_t settings);
  254. #define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2
  255. #define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0
  256. /* Write Default Policy Settings */
  257. /******************************************
  258. * Lisbon Features
  259. ******************************************/
  260. #if (BTM_SSR_INCLUDED == TRUE)
  261. /* Sniff Subrating */
  262. extern void btsnd_hcic_sniff_sub_rate(uint16_t handle, uint16_t max_lat,
  263. uint16_t min_remote_lat,
  264. uint16_t min_local_lat);
  265. #define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8
  266. #define HCI_SNIFF_SUB_RATE_HANDLE_OFF 0
  267. #define HCI_SNIFF_SUB_RATE_MAX_LAT_OFF 2
  268. #define HCI_SNIFF_SUB_RATE_MIN_REM_LAT_OFF 4
  269. #define HCI_SNIFF_SUB_RATE_MIN_LOC_LAT_OFF 6
  270. /* Sniff Subrating */
  271. #else /* BTM_SSR_INCLUDED == FALSE */
  272. #define btsnd_hcic_sniff_sub_rate(handle, max_lat, min_remote_lat, \
  273. min_local_lat) \
  274. false
  275. #endif /* BTM_SSR_INCLUDED */
  276. /* Extended Inquiry Response */
  277. extern void btsnd_hcic_write_ext_inquiry_response(void* buffer,
  278. uint8_t fec_req);
  279. #define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
  280. #define HCIC_EXT_INQ_RESP_FEC_OFF 0
  281. #define HCIC_EXT_INQ_RESP_RESPONSE 1
  282. /* IO Capabilities Response */
  283. extern void btsnd_hcic_io_cap_req_reply(const RawAddress& bd_addr,
  284. uint8_t capability, uint8_t oob_present,
  285. uint8_t auth_req);
  286. #define HCIC_PARAM_SIZE_IO_CAP_RESP 9
  287. #define HCI_IO_CAP_BD_ADDR_OFF 0
  288. #define HCI_IO_CAPABILITY_OFF 6
  289. #define HCI_IO_CAP_OOB_DATA_OFF 7
  290. #define HCI_IO_CAP_AUTH_REQ_OFF 8
  291. /* IO Capabilities Req Neg Reply */
  292. extern void btsnd_hcic_io_cap_req_neg_reply(const RawAddress& bd_addr,
  293. uint8_t err_code);
  294. #define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7
  295. #define HCI_IO_CAP_NR_BD_ADDR_OFF 0
  296. #define HCI_IO_CAP_NR_ERR_CODE 6
  297. /* Read Local OOB Data */
  298. extern void btsnd_hcic_read_local_oob_data(void);
  299. #define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
  300. extern void btsnd_hcic_user_conf_reply(const RawAddress& bd_addr, bool is_yes);
  301. #define HCIC_PARAM_SIZE_UCONF_REPLY 6
  302. #define HCI_USER_CONF_BD_ADDR_OFF 0
  303. extern void btsnd_hcic_user_passkey_reply(const RawAddress& bd_addr,
  304. uint32_t value);
  305. #define HCIC_PARAM_SIZE_U_PKEY_REPLY 10
  306. #define HCI_USER_PASSKEY_BD_ADDR_OFF 0
  307. #define HCI_USER_PASSKEY_VALUE_OFF 6
  308. extern void btsnd_hcic_user_passkey_neg_reply(const RawAddress& bd_addr);
  309. #define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6
  310. #define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0
  311. /* Remote OOB Data Request Reply */
  312. extern void btsnd_hcic_rem_oob_reply(const RawAddress& bd_addr,
  313. const Octet16& c, const Octet16& r);
  314. #define HCIC_PARAM_SIZE_REM_OOB_REPLY 38
  315. #define HCI_REM_OOB_DATA_BD_ADDR_OFF 0
  316. #define HCI_REM_OOB_DATA_C_OFF 6
  317. #define HCI_REM_OOB_DATA_R_OFF 22
  318. /* Remote OOB Data Request Negative Reply */
  319. extern void btsnd_hcic_rem_oob_neg_reply(const RawAddress& bd_addr);
  320. #define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6
  321. #define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0
  322. /* Read Tx Power Level */
  323. extern void btsnd_hcic_read_inq_tx_power(void);
  324. #define HCIC_PARAM_SIZE_R_TX_POWER 0
  325. /* Read Default Erroneous Data Reporting */
  326. extern void btsnd_hcic_read_default_erroneous_data_rpt(void);
  327. #define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
  328. #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
  329. extern void btsnd_hcic_enhanced_flush(uint16_t handle, uint8_t packet_type);
  330. #define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
  331. #endif
  332. extern void btsnd_hcic_send_keypress_notif(const RawAddress& bd_addr,
  333. uint8_t notif);
  334. #define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7
  335. #define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0
  336. #define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6
  337. /**** end of Simple Pairing Commands ****/
  338. /* Store Current Settings */
  339. #define MAX_FILT_COND (sizeof(BD_ADDR) + 1)
  340. extern void btsnd_hcic_set_event_filter(uint8_t filt_type,
  341. uint8_t filt_cond_type,
  342. uint8_t* filt_cond,
  343. uint8_t filt_cond_len);
  344. #define HCIC_PARAM_SIZE_SET_EVT_FILTER 9
  345. #define HCI_FILT_COND_FILT_TYPE_OFF 0
  346. #define HCI_FILT_COND_COND_TYPE_OFF 1
  347. #define HCI_FILT_COND_FILT_OFF 2
  348. /* Set Event Filter */
  349. /* Delete Stored Key */
  350. extern void btsnd_hcic_delete_stored_key(const RawAddress& bd_addr,
  351. bool delete_all_flag);
  352. #define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7
  353. #define HCI_DELETE_KEY_BD_ADDR_OFF 0
  354. #define HCI_DELETE_KEY_ALL_FLAG_OFF 6
  355. /* Delete Stored Key */
  356. /* Change Local Name */
  357. extern void btsnd_hcic_change_name(BD_NAME name);
  358. #define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN
  359. #define HCI_CHANGE_NAME_NAME_OFF 0
  360. /* Change Local Name */
  361. #define HCIC_PARAM_SIZE_READ_CMD 0
  362. #define HCIC_PARAM_SIZE_WRITE_PARAM1 1
  363. #define HCIC_WRITE_PARAM1_PARAM_OFF 0
  364. #define HCIC_PARAM_SIZE_WRITE_PARAM2 2
  365. #define HCIC_WRITE_PARAM2_PARAM_OFF 0
  366. #define HCIC_PARAM_SIZE_WRITE_PARAM3 3
  367. #define HCIC_WRITE_PARAM3_PARAM_OFF 0
  368. #define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
  369. extern void btsnd_hcic_write_pin_type(uint8_t type); /* Write PIN Type */
  370. extern void btsnd_hcic_write_auto_accept(uint8_t flag); /* Write Auto Accept */
  371. extern void btsnd_hcic_read_name(void); /* Read Local Name */
  372. extern void btsnd_hcic_write_page_tout(
  373. uint16_t timeout); /* Write Page Timout */
  374. extern void btsnd_hcic_write_scan_enable(uint8_t flag); /* Write Scan Enable */
  375. extern void btsnd_hcic_write_pagescan_cfg(
  376. uint16_t interval, uint16_t window); /* Write Page Scan Activity */
  377. #define HCIC_PARAM_SIZE_ENH_SET_ESCO_CONN 59
  378. #define HCIC_PARAM_SIZE_ENH_ACC_ESCO_CONN 63
  379. #define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4
  380. #define HCI_SCAN_CFG_INTERVAL_OFF 0
  381. #define HCI_SCAN_CFG_WINDOW_OFF 2
  382. /* Write Page Scan Activity */
  383. /* Write Inquiry Scan Activity */
  384. extern void btsnd_hcic_write_inqscan_cfg(uint16_t interval, uint16_t window);
  385. #define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4
  386. #define HCI_SCAN_CFG_INTERVAL_OFF 0
  387. #define HCI_SCAN_CFG_WINDOW_OFF 2
  388. /* Write Inquiry Scan Activity */
  389. extern void btsnd_hcic_write_auth_enable(
  390. uint8_t flag); /* Write Authentication Enable */
  391. extern void btsnd_hcic_write_dev_class(
  392. DEV_CLASS dev); /* Write Class of Device */
  393. extern void btsnd_hcic_write_voice_settings(
  394. uint16_t flags); /* Write Voice Settings */
  395. /* Host Controller to Host flow control */
  396. #define HCI_HOST_FLOW_CTRL_OFF 0
  397. #define HCI_HOST_FLOW_CTRL_ACL_ON 1
  398. #define HCI_HOST_FLOW_CTRL_SCO_ON 2
  399. #define HCI_HOST_FLOW_CTRL_BOTH_ON 3
  400. extern void btsnd_hcic_write_auto_flush_tout(
  401. uint16_t handle, uint16_t timeout); /* Write Retransmit Timout */
  402. #define HCIC_PARAM_SIZE_WRITE_AUTOMATIC_FLUSH_TIMEOUT 4
  403. #define HCI_FLUSH_TOUT_HANDLE_OFF 0
  404. #define HCI_FLUSH_TOUT_TOUT_OFF 2
  405. extern void btsnd_hcic_read_tx_power(uint16_t handle,
  406. uint8_t type); /* Read Tx Power */
  407. #define HCIC_PARAM_SIZE_READ_TX_POWER 3
  408. #define HCI_READ_TX_POWER_HANDLE_OFF 0
  409. #define HCI_READ_TX_POWER_TYPE_OFF 2
  410. /* Read transmit power level parameter */
  411. #define HCI_READ_CURRENT 0x00
  412. #define HCI_READ_MAXIMUM 0x01
  413. extern void btsnd_hcic_host_num_xmitted_pkts(
  414. uint8_t num_handles, uint16_t* handle,
  415. uint16_t* num_pkts); /* Set Host Buffer Size */
  416. #define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t)
  417. #define MAX_DATA_HANDLES 10
  418. #define HCI_PKTS_DONE_NUM_HANDLES_OFF 0
  419. #define HCI_PKTS_DONE_HANDLE_OFF 1
  420. #define HCI_PKTS_DONE_NUM_PKTS_OFF 3
  421. /* Write Link Supervision Timeout */
  422. extern void btsnd_hcic_write_link_super_tout(uint8_t local_controller_id,
  423. uint16_t handle, uint16_t timeout);
  424. #define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4
  425. #define HCI_LINK_SUPER_TOUT_HANDLE_OFF 0
  426. #define HCI_LINK_SUPER_TOUT_TOUT_OFF 2
  427. /* Write Link Supervision Timeout */
  428. extern void btsnd_hcic_write_cur_iac_lap(
  429. uint8_t num_cur_iac, LAP* const iac_lap); /* Write Current IAC LAP */
  430. #define MAX_IAC_LAPS 0x40
  431. #define HCI_WRITE_IAC_LAP_NUM_OFF 0
  432. #define HCI_WRITE_IAC_LAP_LAP_OFF 1
  433. /* Write Current IAC LAP */
  434. extern void btsnd_hcic_get_link_quality(uint16_t handle); /* Get Link Quality */
  435. extern void btsnd_hcic_read_rssi(uint16_t handle); /* Read RSSI */
  436. using ReadEncKeySizeCb = base::OnceCallback<void(uint8_t, uint16_t, uint8_t)>;
  437. extern void btsnd_hcic_read_encryption_key_size(uint16_t handle, ReadEncKeySizeCb cb);
  438. extern void btsnd_hcic_read_failed_contact_counter(uint16_t handle);
  439. extern void btsnd_hcic_read_automatic_flush_timeout(uint16_t handle);
  440. extern void btsnd_hcic_enable_test_mode(
  441. void); /* Enable Device Under Test Mode */
  442. extern void btsnd_hcic_write_pagescan_type(
  443. uint8_t type); /* Write Page Scan Type */
  444. extern void btsnd_hcic_write_inqscan_type(
  445. uint8_t type); /* Write Inquiry Scan Type */
  446. extern void btsnd_hcic_write_inquiry_mode(
  447. uint8_t type); /* Write Inquiry Mode */
  448. /* Enhanced setup SCO connection (CSA2) */
  449. extern void btsnd_hcic_enhanced_set_up_synchronous_connection(
  450. uint16_t conn_handle, enh_esco_params_t* p_parms);
  451. /* Enhanced accept SCO connection request (CSA2) */
  452. extern void btsnd_hcic_enhanced_accept_synchronous_connection(
  453. const RawAddress& bd_addr, enh_esco_params_t* p_parms);
  454. #define HCI_DATA_HANDLE_MASK 0x0FFF
  455. #define HCID_GET_HANDLE_EVENT(p) \
  456. (uint16_t)((*((uint8_t*)((p) + 1) + (p)->offset) + \
  457. (*((uint8_t*)((p) + 1) + (p)->offset + 1) << 8)))
  458. #define HCID_GET_HANDLE(u16) (uint16_t)((u16)&HCI_DATA_HANDLE_MASK)
  459. #define HCI_DATA_EVENT_MASK 3
  460. #define HCI_DATA_EVENT_OFFSET 12
  461. #define HCID_GET_EVENT(u16) \
  462. (uint8_t)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK)
  463. #define HCI_DATA_BCAST_MASK 3
  464. #define HCI_DATA_BCAST_OFFSET 10
  465. #define HCID_GET_BCAST(u16) \
  466. (uint8_t)(((u16) >> HCI_DATA_BCAST_OFFSET) & HCI_DATA_BCAST_MASK)
  467. #define HCID_GET_ACL_LEN(p) \
  468. (uint16_t)((*((uint8_t*)((p) + 1) + (p)->offset + 2) + \
  469. (*((uint8_t*)((p) + 1) + (p)->offset + 3) << 8)))
  470. #define HCID_HEADER_SIZE 4
  471. #define HCID_GET_SCO_LEN(p) (*((uint8_t*)((p) + 1) + (p)->offset + 2))
  472. extern void btsnd_hcic_vendor_spec_cmd(void* buffer, uint16_t opcode,
  473. uint8_t len, uint8_t* p_data,
  474. void* p_cmd_cplt_cback);
  475. /*******************************************************************************
  476. * BLE Commands
  477. * Note: "local_controller_id" is for transport, not counted in HCI
  478. * message size
  479. ******************************************************************************/
  480. #define HCIC_BLE_RAND_DI_SIZE 8
  481. #define HCIC_BLE_IRK_SIZE 16
  482. #define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
  483. #define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
  484. #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
  485. #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
  486. #define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
  487. #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
  488. #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
  489. #define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
  490. #define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
  491. #define HCIC_PARAM_SIZE_CLEAR_WHITE_LIST 0
  492. #define HCIC_PARAM_SIZE_ADD_WHITE_LIST 7
  493. #define HCIC_PARAM_SIZE_REMOVE_WHITE_LIST 7
  494. #define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
  495. #define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
  496. #define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
  497. #define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
  498. #define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
  499. #define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
  500. #define HCIC_BLE_RAND_DI_SIZE 8
  501. #define HCIC_BLE_ENCRYT_KEY_SIZE 16
  502. #define HCIC_PARAM_SIZE_BLE_START_ENC \
  503. (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYT_KEY_SIZE)
  504. #define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYT_KEY_SIZE)
  505. #define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
  506. #define HCIC_BLE_CHNL_MAP_SIZE 5
  507. #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
  508. #define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
  509. #define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
  510. #define HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE 8
  511. #define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
  512. #define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
  513. #define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
  514. #define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL 7
  515. #define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1
  516. #define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
  517. #define HCIC_PARAM_SIZE_BLE_READ_PHY 2
  518. #define HCIC_PARAM_SIZE_BLE_SET_DEFAULT_PHY 3
  519. #define HCIC_PARAM_SIZE_BLE_SET_PHY 7
  520. #define HCIC_PARAM_SIZE_BLE_ENH_RX_TEST 3
  521. #define HCIC_PARAM_SIZE_BLE_ENH_TX_TEST 4
  522. #define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
  523. #define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
  524. /* ULP HCI command */
  525. extern void btsnd_hcic_ble_set_evt_mask(BT_EVENT_MASK event_mask);
  526. extern void btsnd_hcic_ble_read_buffer_size(void);
  527. extern void btsnd_hcic_ble_read_local_spt_feat(void);
  528. extern void btsnd_hcic_ble_set_local_used_feat(uint8_t feat_set[8]);
  529. extern void btsnd_hcic_ble_set_random_addr(const RawAddress& random_addr);
  530. extern void btsnd_hcic_ble_write_adv_params(
  531. uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type,
  532. uint8_t addr_type_own, uint8_t addr_type_dir, const RawAddress& direct_bda,
  533. uint8_t channel_map, uint8_t adv_filter_policy);
  534. extern void btsnd_hcic_ble_read_adv_chnl_tx_power(void);
  535. extern void btsnd_hcic_ble_set_adv_data(uint8_t data_len, uint8_t* p_data);
  536. extern void btsnd_hcic_ble_set_scan_rsp_data(uint8_t data_len,
  537. uint8_t* p_scan_rsp);
  538. extern void btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable);
  539. extern void btsnd_hcic_ble_set_scan_params(uint8_t scan_type, uint16_t scan_int,
  540. uint16_t scan_win, uint8_t addr_type,
  541. uint8_t scan_filter_policy);
  542. extern void btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable,
  543. uint8_t duplicate);
  544. extern void btsnd_hcic_ble_create_ll_conn(
  545. uint16_t scan_int, uint16_t scan_win, uint8_t init_filter_policy,
  546. uint8_t addr_type_peer, const RawAddress& bda_peer, uint8_t addr_type_own,
  547. uint16_t conn_int_min, uint16_t conn_int_max, uint16_t conn_latency,
  548. uint16_t conn_timeout, uint16_t min_ce_len, uint16_t max_ce_len);
  549. extern void btsnd_hcic_ble_create_conn_cancel(void);
  550. extern void btsnd_hcic_ble_read_white_list_size(void);
  551. extern void btsnd_hcic_ble_clear_white_list(
  552. base::OnceCallback<void(uint8_t*, uint16_t)> cb);
  553. extern void btsnd_hcic_ble_add_white_list(
  554. uint8_t addr_type, const RawAddress& bda,
  555. base::OnceCallback<void(uint8_t*, uint16_t)> cb);
  556. extern void btsnd_hcic_ble_remove_from_white_list(
  557. uint8_t addr_type, const RawAddress& bda,
  558. base::OnceCallback<void(uint8_t*, uint16_t)> cb);
  559. extern void btsnd_hcic_ble_upd_ll_conn_params(
  560. uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max,
  561. uint16_t conn_latency, uint16_t conn_timeout, uint16_t min_len,
  562. uint16_t max_len);
  563. extern void btsnd_hcic_ble_set_host_chnl_class(
  564. uint8_t chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
  565. extern void btsnd_hcic_ble_read_chnl_map(uint16_t handle);
  566. extern void btsnd_hcic_ble_read_remote_feat(uint16_t handle);
  567. extern void btsnd_hcic_ble_encrypt(uint8_t* key, uint8_t key_len,
  568. uint8_t* plain_text, uint8_t pt_len,
  569. void* p_cmd_cplt_cback);
  570. extern void btsnd_hcic_ble_rand(base::Callback<void(BT_OCTET8)> cb);
  571. extern void btsnd_hcic_ble_start_enc(uint16_t handle,
  572. uint8_t rand[HCIC_BLE_RAND_DI_SIZE],
  573. uint16_t ediv, const Octet16& ltk);
  574. extern void btsnd_hcic_ble_ltk_req_reply(uint16_t handle, const Octet16& ltk);
  575. extern void btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle);
  576. extern void btsnd_hcic_ble_read_supported_states(void);
  577. extern void btsnd_hcic_ble_write_host_supported(uint8_t le_host_spt,
  578. uint8_t simul_le_host_spt);
  579. extern void btsnd_hcic_ble_read_host_supported(void);
  580. extern void btsnd_hcic_ble_receiver_test(uint8_t rx_freq);
  581. extern void btsnd_hcic_ble_transmitter_test(uint8_t tx_freq,
  582. uint8_t test_data_len,
  583. uint8_t payload);
  584. extern void btsnd_hcic_ble_test_end(void);
  585. #if (BLE_LLT_INCLUDED == TRUE)
  586. #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
  587. extern void btsnd_hcic_ble_rc_param_req_reply(
  588. uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max,
  589. uint16_t conn_latency, uint16_t conn_timeout, uint16_t min_ce_len,
  590. uint16_t max_ce_len);
  591. #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
  592. extern void btsnd_hcic_ble_rc_param_req_neg_reply(uint16_t handle,
  593. uint8_t reason);
  594. #endif /* BLE_LLT_INCLUDED */
  595. extern void btsnd_hcic_ble_set_data_length(uint16_t conn_handle,
  596. uint16_t tx_octets,
  597. uint16_t tx_time);
  598. extern void btsnd_hcic_ble_add_device_resolving_list(uint8_t addr_type_peer,
  599. const RawAddress& bda_peer,
  600. const Octet16& irk_peer,
  601. const Octet16& irk_local);
  602. struct scanning_phy_cfg {
  603. uint8_t scan_type;
  604. uint16_t scan_int;
  605. uint16_t scan_win;
  606. };
  607. extern void btsnd_hcic_ble_set_extended_scan_params(
  608. uint8_t own_address_type, uint8_t scanning_filter_policy,
  609. uint8_t scanning_phys, scanning_phy_cfg* phy_cfg);
  610. extern void btsnd_hcic_ble_set_extended_scan_enable(uint8_t enable,
  611. uint8_t filter_duplicates,
  612. uint16_t duration,
  613. uint16_t period);
  614. struct EXT_CONN_PHY_CFG {
  615. uint16_t scan_int;
  616. uint16_t scan_win;
  617. uint16_t conn_int_min;
  618. uint16_t conn_int_max;
  619. uint16_t conn_latency;
  620. uint16_t sup_timeout;
  621. uint16_t min_ce_len;
  622. uint16_t max_ce_len;
  623. };
  624. extern void btsnd_hcic_ble_ext_create_conn(uint8_t init_filter_policy,
  625. uint8_t addr_type_own,
  626. uint8_t addr_type_peer,
  627. const RawAddress& bda_peer,
  628. uint8_t initiating_phys,
  629. EXT_CONN_PHY_CFG* phy_cfg);
  630. extern void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer,
  631. const RawAddress& bda_peer);
  632. extern void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer,
  633. const RawAddress& bda_peer,
  634. uint8_t privacy_type);
  635. extern void btsnd_hcic_ble_clear_resolving_list(void);
  636. extern void btsnd_hcic_ble_read_resolvable_addr_peer(
  637. uint8_t addr_type_peer, const RawAddress& bda_peer);
  638. extern void btsnd_hcic_ble_read_resolvable_addr_local(
  639. uint8_t addr_type_peer, const RawAddress& bda_peer);
  640. extern void btsnd_hcic_ble_set_addr_resolution_enable(
  641. uint8_t addr_resolution_enable);
  642. extern void btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout);
  643. extern void btsnd_hcic_read_authenticated_payload_tout(uint16_t handle);
  644. extern void btsnd_hcic_write_authenticated_payload_tout(uint16_t handle,
  645. uint16_t timeout);
  646. #define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
  647. #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
  648. #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2
  649. #endif