1 /* hci.h - Bluetooth Host Control Interface definitions */ 2 3 /* 4 * Copyright (c) 2015-2016 Intel Corporation 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_ 9 #define ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_ 10 11 #include <ble_types/types.h> 12 #include <stdbool.h> 13 #include <string.h> 14 #include <misc/util.h> 15 #include <net/buf.h> 16 #include <bluetooth/addr.h> 17 #include <bluetooth/hci_err.h> 18 #include <bluetooth/conn.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* Special own address types for LL privacy (used in adv & scan parameters) */ 25 #define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC 0x02 26 #define BT_HCI_OWN_ADDR_RPA_OR_RANDOM 0x03 27 #define BT_HCI_OWN_ADDR_RPA_MASK 0x02 28 29 #define BT_HCI_PEER_ADDR_RPA_UNRESOLVED 0xfe 30 #define BT_HCI_PEER_ADDR_ANONYMOUS 0xff 31 32 #define BT_ENC_KEY_SIZE_MIN 0x07 33 #define BT_ENC_KEY_SIZE_MAX 0x10 34 35 struct bt_hci_evt_hdr { 36 u8_t evt; 37 u8_t len; 38 } __packed; 39 #define BT_HCI_EVT_HDR_SIZE 2 40 41 #define BT_ACL_START_NO_FLUSH 0x00 42 #define BT_ACL_CONT 0x01 43 #define BT_ACL_START 0x02 44 #define BT_ACL_COMPLETE 0x03 45 46 #define BT_ACL_POINT_TO_POINT 0x00 47 #define BT_ACL_BROADCAST 0x01 48 49 #define bt_acl_handle(h) ((h) & BIT_MASK(12)) 50 #define bt_acl_flags(h) ((h) >> 12) 51 #define bt_acl_flags_pb(f) ((f) & BIT_MASK(2)) 52 #define bt_acl_flags_bc(f) ((f) >> 2) 53 #define bt_acl_handle_pack(h, f) ((h) | ((f) << 12)) 54 55 struct bt_hci_acl_hdr { 56 u16_t handle; 57 u16_t len; 58 } __packed; 59 #define BT_HCI_ACL_HDR_SIZE 4 60 61 struct bt_hci_cmd_hdr { 62 u16_t opcode; 63 u8_t param_len; 64 } __packed; 65 #define BT_HCI_CMD_HDR_SIZE 3 66 67 /* Supported Commands */ 68 #define BT_CMD_TEST(cmd, octet, bit) (cmd[octet] & BIT(bit)) 69 #define BT_CMD_LE_STATES(cmd) BT_CMD_TEST(cmd, 28, 3) 70 71 #define BT_FEAT_TEST(feat, page, octet, bit) (feat[page][octet] & BIT(bit)) 72 73 #define BT_FEAT_BREDR(feat) !BT_FEAT_TEST(feat, 0, 4, 5) 74 #define BT_FEAT_LE(feat) BT_FEAT_TEST(feat, 0, 4, 6) 75 #define BT_FEAT_EXT_FEATURES(feat) BT_FEAT_TEST(feat, 0, 7, 7) 76 #define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0) 77 #define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0) 78 79 #define BT_FEAT_LMP_ESCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 3, 7) 80 #define BT_FEAT_HV2_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 4) 81 #define BT_FEAT_HV3_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 5) 82 #define BT_FEAT_EV4_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 0) 83 #define BT_FEAT_EV5_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 1) 84 #define BT_FEAT_2EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 5) 85 #define BT_FEAT_3EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 6) 86 #define BT_FEAT_3SLOT_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 7) 87 88 /* LE features */ 89 #define BT_LE_FEAT_BIT_ENC 0 90 #define BT_LE_FEAT_BIT_CONN_PARAM_REQ 1 91 #define BT_LE_FEAT_BIT_EXT_REJ_IND 2 92 #define BT_LE_FEAT_BIT_SLAVE_FEAT_REQ 3 93 #define BT_LE_FEAT_BIT_PING 4 94 #define BT_LE_FEAT_BIT_DLE 5 95 #define BT_LE_FEAT_BIT_PRIVACY 6 96 #define BT_LE_FEAT_BIT_EXT_SCAN 7 97 #define BT_LE_FEAT_BIT_PHY_2M 8 98 #define BT_LE_FEAT_BIT_SMI_TX 9 99 #define BT_LE_FEAT_BIT_SMI_RX 10 100 #define BT_LE_FEAT_BIT_PHY_CODED 11 101 #define BT_LE_FEAT_BIT_EXT_ADV 12 102 #define BT_LE_FEAT_BIT_PER_ADV 13 103 #define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14 104 #define BT_LE_FEAT_BIT_PWR_CLASS_1 15 105 #define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16 106 #define BT_LE_FEAT_BIT_CONN_CTE_REQ 17 107 #define BT_LE_FEAT_BIT_CONN_CTE_RESP 18 108 #define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX 19 109 #define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX 20 110 #define BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD 21 111 #define BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA 22 112 #define BT_LE_FEAT_BIT_RX_CTE 23 113 #define BT_LE_FEAT_BIT_PERIODIC_SYNC_XFER_SEND 24 114 #define BT_LE_FEAT_BIT_PERIODIC_SYNC_XFER_RECV 25 115 #define BT_LE_FEAT_BIT_SCA_UPDATE 26 116 #define BT_LE_FEAT_BIT_REMOTE_PUB_KEY_VALIDATE 27 117 #define BT_LE_FEAT_BIT_CIS_MASTER 28 118 #define BT_LE_FEAT_BIT_CIS_SLAVE 29 119 #define BT_LE_FEAT_BIT_ISO_BROADCASTER 30 120 #define BT_LE_FEAT_BIT_SYNC_RECEIVER 31 121 #define BT_LE_FEAT_BIT_ISO_CHANNELS 32 122 #define BT_LE_FEAT_BIT_PWR_CTRL_REQ 33 123 #define BT_LE_FEAT_BIT_PWR_CHG_IND 34 124 #define BT_LE_FEAT_BIT_PATH_LOSS_MONITOR 35 125 126 #define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \ 127 BIT((n) & 7)) 128 129 #define BT_FEAT_LE_ENCR(feat) BT_LE_FEAT_TEST(feat, \ 130 BT_LE_FEAT_BIT_ENC) 131 #define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_LE_FEAT_TEST(feat, \ 132 BT_LE_FEAT_BIT_CONN_PARAM_REQ) 133 #define BT_FEAT_LE_SLAVE_FEATURE_XCHG(feat) BT_LE_FEAT_TEST(feat, \ 134 BT_LE_FEAT_BIT_SLAVE_FEAT_REQ) 135 #define BT_FEAT_LE_DLE(feat) BT_LE_FEAT_TEST(feat, \ 136 BT_LE_FEAT_BIT_DLE) 137 #define BT_FEAT_LE_PHY_2M(feat) BT_LE_FEAT_TEST(feat, \ 138 BT_LE_FEAT_BIT_PHY_2M) 139 #define BT_FEAT_LE_PHY_CODED(feat) BT_LE_FEAT_TEST(feat, \ 140 BT_LE_FEAT_BIT_PHY_CODED) 141 #define BT_FEAT_LE_PRIVACY(feat) BT_LE_FEAT_TEST(feat, \ 142 BT_LE_FEAT_BIT_PRIVACY) 143 #define BT_FEAT_LE_EXT_ADV(feat) BT_LE_FEAT_TEST(feat, \ 144 BT_LE_FEAT_BIT_EXT_ADV) 145 146 /* LE States */ 147 #define BT_LE_STATES_SLAVE_CONN_ADV(states) (states & 0x0000004000000000) 148 149 /* Bonding/authentication types */ 150 #define BT_HCI_NO_BONDING 0x00 151 #define BT_HCI_NO_BONDING_MITM 0x01 152 #define BT_HCI_DEDICATED_BONDING 0x02 153 #define BT_HCI_DEDICATED_BONDING_MITM 0x03 154 #define BT_HCI_GENERAL_BONDING 0x04 155 #define BT_HCI_GENERAL_BONDING_MITM 0x05 156 157 /* 158 * MITM protection is enabled in SSP authentication requirements octet when 159 * LSB bit is set. 160 */ 161 #define BT_MITM 0x01 162 163 /* I/O capabilities */ 164 #define BT_IO_DISPLAY_ONLY 0x00 165 #define BT_IO_DISPLAY_YESNO 0x01 166 #define BT_IO_KEYBOARD_ONLY 0x02 167 #define BT_IO_NO_INPUT_OUTPUT 0x03 168 169 /* SCO packet types */ 170 #define HCI_PKT_TYPE_HV1 0x0020 171 #define HCI_PKT_TYPE_HV2 0x0040 172 #define HCI_PKT_TYPE_HV3 0x0080 173 174 /* eSCO packet types */ 175 #define HCI_PKT_TYPE_ESCO_HV1 0x0001 176 #define HCI_PKT_TYPE_ESCO_HV2 0x0002 177 #define HCI_PKT_TYPE_ESCO_HV3 0x0004 178 #define HCI_PKT_TYPE_ESCO_EV3 0x0008 179 #define HCI_PKT_TYPE_ESCO_EV4 0x0010 180 #define HCI_PKT_TYPE_ESCO_EV5 0x0020 181 #define HCI_PKT_TYPE_ESCO_2EV3 0x0040 182 #define HCI_PKT_TYPE_ESCO_3EV3 0x0080 183 #define HCI_PKT_TYPE_ESCO_2EV5 0x0100 184 #define HCI_PKT_TYPE_ESCO_3EV5 0x0200 185 186 187 #define ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_HV1 | \ 188 HCI_PKT_TYPE_ESCO_HV2 | \ 189 HCI_PKT_TYPE_ESCO_HV3) 190 #define SCO_PKT_MASK (HCI_PKT_TYPE_HV1 | \ 191 HCI_PKT_TYPE_HV2 | \ 192 HCI_PKT_TYPE_HV3) 193 #define EDR_ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_2EV3 | \ 194 HCI_PKT_TYPE_ESCO_3EV3 | \ 195 HCI_PKT_TYPE_ESCO_2EV5 | \ 196 HCI_PKT_TYPE_ESCO_3EV5) 197 198 /* HCI BR/EDR link types */ 199 #define BT_HCI_SCO 0x00 200 #define BT_HCI_ACL 0x01 201 #define BT_HCI_ESCO 0x02 202 203 /* OpCode Group Fields */ 204 #define BT_OGF_LINK_CTRL 0x01 205 #define BT_OGF_BASEBAND 0x03 206 #define BT_OGF_INFO 0x04 207 #define BT_OGF_STATUS 0x05 208 #define BT_OGF_LE 0x08 209 #define BT_OGF_VS 0x3f 210 211 /* Construct OpCode from OGF and OCF */ 212 #define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10)) 213 214 /* Invalid opcode */ 215 #define BT_OP_NOP 0x0000 216 217 /* Obtain OGF from OpCode */ 218 #define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6)) 219 /* Obtain OCF from OpCode */ 220 #define BT_OCF(opcode) ((opcode) & BIT_MASK(10)) 221 222 #define BT_HCI_OP_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0001) 223 struct bt_hci_op_inquiry { 224 u8_t lap[3]; 225 u8_t length; 226 u8_t num_rsp; 227 } __packed; 228 229 #define BT_HCI_OP_INQUIRY_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0002) 230 231 #define BT_HCI_OP_CONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0005) 232 struct bt_hci_cp_connect { 233 bt_addr_t bdaddr; 234 u16_t packet_type; 235 u8_t pscan_rep_mode; 236 u8_t reserved; 237 u16_t clock_offset; 238 u8_t allow_role_switch; 239 } __packed; 240 241 #define BT_HCI_OP_DISCONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0006) 242 struct bt_hci_cp_disconnect { 243 u16_t handle; 244 u8_t reason; 245 } __packed; 246 247 #define BT_HCI_OP_CONNECT_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0008) 248 struct bt_hci_cp_connect_cancel { 249 bt_addr_t bdaddr; 250 } __packed; 251 struct bt_hci_rp_connect_cancel { 252 u8_t status; 253 bt_addr_t bdaddr; 254 } __packed; 255 256 #define BT_HCI_OP_ACCEPT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0009) 257 struct bt_hci_cp_accept_conn_req { 258 bt_addr_t bdaddr; 259 u8_t role; 260 } __packed; 261 262 #define BT_HCI_OP_SETUP_SYNC_CONN BT_OP(BT_OGF_LINK_CTRL, 0x0028) 263 struct bt_hci_cp_setup_sync_conn { 264 u16_t handle; 265 bt_u32_t tx_bandwidth; 266 bt_u32_t rx_bandwidth; 267 u16_t max_latency; 268 u16_t content_format; 269 u8_t retrans_effort; 270 u16_t pkt_type; 271 } __packed; 272 273 #define BT_HCI_OP_ACCEPT_SYNC_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0029) 274 struct bt_hci_cp_accept_sync_conn_req { 275 bt_addr_t bdaddr; 276 bt_u32_t tx_bandwidth; 277 bt_u32_t rx_bandwidth; 278 u16_t max_latency; 279 u16_t content_format; 280 u8_t retrans_effort; 281 u16_t pkt_type; 282 } __packed; 283 284 #define BT_HCI_OP_REJECT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x000a) 285 struct bt_hci_cp_reject_conn_req { 286 bt_addr_t bdaddr; 287 u8_t reason; 288 } __packed; 289 290 #define BT_HCI_OP_LINK_KEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000b) 291 struct bt_hci_cp_link_key_reply { 292 bt_addr_t bdaddr; 293 u8_t link_key[16]; 294 } __packed; 295 296 #define BT_HCI_OP_LINK_KEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000c) 297 struct bt_hci_cp_link_key_neg_reply { 298 bt_addr_t bdaddr; 299 } __packed; 300 301 #define BT_HCI_OP_PIN_CODE_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000d) 302 struct bt_hci_cp_pin_code_reply { 303 bt_addr_t bdaddr; 304 u8_t pin_len; 305 u8_t pin_code[16]; 306 } __packed; 307 struct bt_hci_rp_pin_code_reply { 308 u8_t status; 309 bt_addr_t bdaddr; 310 } __packed; 311 312 #define BT_HCI_OP_PIN_CODE_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000e) 313 struct bt_hci_cp_pin_code_neg_reply { 314 bt_addr_t bdaddr; 315 } __packed; 316 struct bt_hci_rp_pin_code_neg_reply { 317 u8_t status; 318 bt_addr_t bdaddr; 319 } __packed; 320 321 #define BT_HCI_OP_AUTH_REQUESTED BT_OP(BT_OGF_LINK_CTRL, 0x0011) 322 struct bt_hci_cp_auth_requested { 323 u16_t handle; 324 } __packed; 325 326 #define BT_HCI_OP_SET_CONN_ENCRYPT BT_OP(BT_OGF_LINK_CTRL, 0x0013) 327 struct bt_hci_cp_set_conn_encrypt { 328 u16_t handle; 329 u8_t encrypt; 330 } __packed; 331 332 #define BT_HCI_OP_REMOTE_NAME_REQUEST BT_OP(BT_OGF_LINK_CTRL, 0x0019) 333 struct bt_hci_cp_remote_name_request { 334 bt_addr_t bdaddr; 335 u8_t pscan_rep_mode; 336 u8_t reserved; 337 u16_t clock_offset; 338 } __packed; 339 340 #define BT_HCI_OP_REMOTE_NAME_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x001a) 341 struct bt_hci_cp_remote_name_cancel { 342 bt_addr_t bdaddr; 343 } __packed; 344 struct bt_hci_rp_remote_name_cancel { 345 u8_t status; 346 bt_addr_t bdaddr; 347 } __packed; 348 349 #define BT_HCI_OP_READ_REMOTE_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001b) 350 struct bt_hci_cp_read_remote_features { 351 u16_t handle; 352 } __packed; 353 354 #define BT_HCI_OP_READ_REMOTE_EXT_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001c) 355 struct bt_hci_cp_read_remote_ext_features { 356 u16_t handle; 357 u8_t page; 358 } __packed; 359 360 #define BT_HCI_OP_READ_REMOTE_VERSION_INFO BT_OP(BT_OGF_LINK_CTRL, 0x001d) 361 struct bt_hci_cp_read_remote_version_info { 362 u16_t handle; 363 } __packed; 364 365 #define BT_HCI_OP_IO_CAPABILITY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002b) 366 struct bt_hci_cp_io_capability_reply { 367 bt_addr_t bdaddr; 368 u8_t capability; 369 u8_t oob_data; 370 u8_t authentication; 371 } __packed; 372 373 #define BT_HCI_OP_USER_CONFIRM_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002c) 374 #define BT_HCI_OP_USER_CONFIRM_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002d) 375 struct bt_hci_cp_user_confirm_reply { 376 bt_addr_t bdaddr; 377 } __packed; 378 struct bt_hci_rp_user_confirm_reply { 379 u8_t status; 380 bt_addr_t bdaddr; 381 } __packed; 382 383 #define BT_HCI_OP_USER_PASSKEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002e) 384 struct bt_hci_cp_user_passkey_reply { 385 bt_addr_t bdaddr; 386 bt_u32_t passkey; 387 } __packed; 388 389 #define BT_HCI_OP_USER_PASSKEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002f) 390 struct bt_hci_cp_user_passkey_neg_reply { 391 bt_addr_t bdaddr; 392 } __packed; 393 394 #define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034) 395 struct bt_hci_cp_io_capability_neg_reply { 396 bt_addr_t bdaddr; 397 u8_t reason; 398 } __packed; 399 400 #define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001) 401 struct bt_hci_cp_set_event_mask { 402 u8_t events[8]; 403 } __packed; 404 405 #define BT_HCI_OP_RESET BT_OP(BT_OGF_BASEBAND, 0x0003) 406 407 #define BT_HCI_OP_WRITE_LOCAL_NAME BT_OP(BT_OGF_BASEBAND, 0x0013) 408 struct bt_hci_write_local_name { 409 u8_t local_name[248]; 410 } __packed; 411 412 #define BT_HCI_OP_WRITE_PAGE_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0018) 413 414 #define BT_HCI_OP_WRITE_SCAN_ENABLE BT_OP(BT_OGF_BASEBAND, 0x001a) 415 #define BT_BREDR_SCAN_DISABLED 0x00 416 #define BT_BREDR_SCAN_INQUIRY 0x01 417 #define BT_BREDR_SCAN_PAGE 0x02 418 419 #define BT_TX_POWER_LEVEL_CURRENT 0x00 420 #define BT_TX_POWER_LEVEL_MAX 0x01 421 #define BT_HCI_OP_READ_TX_POWER_LEVEL BT_OP(BT_OGF_BASEBAND, 0x002d) 422 struct bt_hci_cp_read_tx_power_level { 423 u16_t handle; 424 u8_t type; 425 } __packed; 426 427 struct bt_hci_rp_read_tx_power_level { 428 u8_t status; 429 u16_t handle; 430 s8_t tx_power_level; 431 } __packed; 432 433 #define BT_HCI_CTL_TO_HOST_FLOW_DISABLE 0x00 434 #define BT_HCI_CTL_TO_HOST_FLOW_ENABLE 0x01 435 #define BT_HCI_OP_SET_CTL_TO_HOST_FLOW BT_OP(BT_OGF_BASEBAND, 0x0031) 436 struct bt_hci_cp_set_ctl_to_host_flow { 437 u8_t flow_enable; 438 } __packed; 439 440 #define BT_HCI_OP_HOST_BUFFER_SIZE BT_OP(BT_OGF_BASEBAND, 0x0033) 441 struct bt_hci_cp_host_buffer_size { 442 u16_t acl_mtu; 443 u8_t sco_mtu; 444 u16_t acl_pkts; 445 u16_t sco_pkts; 446 } __packed; 447 448 struct bt_hci_handle_count { 449 u16_t handle; 450 u16_t count; 451 } __packed; 452 453 #define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS BT_OP(BT_OGF_BASEBAND, 0x0035) 454 struct bt_hci_cp_host_num_completed_packets { 455 u8_t num_handles; 456 struct bt_hci_handle_count h[0]; 457 } __packed; 458 459 #define BT_HCI_OP_WRITE_INQUIRY_MODE BT_OP(BT_OGF_BASEBAND, 0x0045) 460 struct bt_hci_cp_write_inquiry_mode { 461 u8_t mode; 462 } __packed; 463 464 #define BT_HCI_OP_WRITE_SSP_MODE BT_OP(BT_OGF_BASEBAND, 0x0056) 465 struct bt_hci_cp_write_ssp_mode { 466 u8_t mode; 467 } __packed; 468 469 #define BT_HCI_OP_SET_EVENT_MASK_PAGE_2 BT_OP(BT_OGF_BASEBAND, 0x0063) 470 struct bt_hci_cp_set_event_mask_page_2 { 471 u8_t events_page_2[8]; 472 } __packed; 473 474 #define BT_HCI_OP_LE_WRITE_LE_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x006d) 475 struct bt_hci_cp_write_le_host_supp { 476 u8_t le; 477 u8_t simul; 478 } __packed; 479 480 #define BT_HCI_OP_WRITE_SC_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x007a) 481 struct bt_hci_cp_write_sc_host_supp { 482 u8_t sc_support; 483 } __packed; 484 485 #define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007b) 486 struct bt_hci_cp_read_auth_payload_timeout { 487 u16_t handle; 488 } __packed; 489 490 struct bt_hci_rp_read_auth_payload_timeout { 491 u8_t status; 492 u16_t handle; 493 u16_t auth_payload_timeout; 494 } __packed; 495 496 #define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007c) 497 struct bt_hci_cp_write_auth_payload_timeout { 498 u16_t handle; 499 u16_t auth_payload_timeout; 500 } __packed; 501 502 struct bt_hci_rp_write_auth_payload_timeout { 503 u8_t status; 504 u16_t handle; 505 } __packed; 506 507 /* HCI version from Assigned Numbers */ 508 #define BT_HCI_VERSION_1_0B 0 509 #define BT_HCI_VERSION_1_1 1 510 #define BT_HCI_VERSION_1_2 2 511 #define BT_HCI_VERSION_2_0 3 512 #define BT_HCI_VERSION_2_1 4 513 #define BT_HCI_VERSION_3_0 5 514 #define BT_HCI_VERSION_4_0 6 515 #define BT_HCI_VERSION_4_1 7 516 #define BT_HCI_VERSION_4_2 8 517 #define BT_HCI_VERSION_5_0 9 518 #define BT_HCI_VERSION_5_1 10 519 #define BT_HCI_VERSION_5_2 11 520 521 #define BT_HCI_OP_READ_LOCAL_VERSION_INFO BT_OP(BT_OGF_INFO, 0x0001) 522 struct bt_hci_rp_read_local_version_info { 523 u8_t status; 524 u8_t hci_version; 525 u16_t hci_revision; 526 u8_t lmp_version; 527 u16_t manufacturer; 528 u16_t lmp_subversion; 529 } __packed; 530 531 #define BT_HCI_OP_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_INFO, 0x0002) 532 struct bt_hci_rp_read_supported_commands { 533 u8_t status; 534 u8_t commands[64]; 535 } __packed; 536 537 #define BT_HCI_OP_READ_LOCAL_EXT_FEATURES BT_OP(BT_OGF_INFO, 0x0004) 538 struct bt_hci_cp_read_local_ext_features { 539 u8_t page; 540 }; 541 struct bt_hci_rp_read_local_ext_features { 542 u8_t status; 543 u8_t page; 544 u8_t max_page; 545 u8_t ext_features[8]; 546 } __packed; 547 548 #define BT_HCI_OP_READ_LOCAL_FEATURES BT_OP(BT_OGF_INFO, 0x0003) 549 struct bt_hci_rp_read_local_features { 550 u8_t status; 551 u8_t features[8]; 552 } __packed; 553 554 #define BT_HCI_OP_READ_BUFFER_SIZE BT_OP(BT_OGF_INFO, 0x0005) 555 struct bt_hci_rp_read_buffer_size { 556 u8_t status; 557 u16_t acl_max_len; 558 u8_t sco_max_len; 559 u16_t acl_max_num; 560 u16_t sco_max_num; 561 } __packed; 562 563 #define BT_HCI_OP_READ_BD_ADDR BT_OP(BT_OGF_INFO, 0x0009) 564 struct bt_hci_rp_read_bd_addr { 565 u8_t status; 566 bt_addr_t bdaddr; 567 } __packed; 568 569 #define BT_HCI_OP_READ_RSSI BT_OP(BT_OGF_STATUS, 0x0005) 570 struct bt_hci_cp_read_rssi { 571 u16_t handle; 572 } __packed; 573 struct bt_hci_rp_read_rssi { 574 u8_t status; 575 u16_t handle; 576 s8_t rssi; 577 } __packed; 578 579 #define BT_HCI_ENCRYPTION_KEY_SIZE_MIN 7 580 #define BT_HCI_ENCRYPTION_KEY_SIZE_MAX 16 581 582 #define BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE BT_OP(BT_OGF_STATUS, 0x0008) 583 struct bt_hci_cp_read_encryption_key_size { 584 u16_t handle; 585 } __packed; 586 struct bt_hci_rp_read_encryption_key_size { 587 u8_t status; 588 u16_t handle; 589 u8_t key_size; 590 } __packed; 591 592 /* BLE */ 593 594 #define BT_HCI_OP_LE_SET_EVENT_MASK BT_OP(BT_OGF_LE, 0x0001) 595 struct bt_hci_cp_le_set_event_mask { 596 u8_t events[8]; 597 } __packed; 598 599 #define BT_HCI_OP_LE_READ_BUFFER_SIZE BT_OP(BT_OGF_LE, 0x0002) 600 struct bt_hci_rp_le_read_buffer_size { 601 u8_t status; 602 u16_t le_max_len; 603 u8_t le_max_num; 604 } __packed; 605 606 #define BT_HCI_OP_LE_READ_LOCAL_FEATURES BT_OP(BT_OGF_LE, 0x0003) 607 struct bt_hci_rp_le_read_local_features { 608 u8_t status; 609 u8_t features[8]; 610 } __packed; 611 612 #define BT_HCI_OP_LE_SET_RANDOM_ADDRESS BT_OP(BT_OGF_LE, 0x0005) 613 struct bt_hci_cp_le_set_random_address { 614 bt_addr_t bdaddr; 615 } __packed; 616 617 /* LE Advertising Types (LE Advertising Parameters Set)*/ 618 #define BT_LE_ADV_IND (__DEPRECATED_MACRO 0x00) 619 #define BT_LE_ADV_DIRECT_IND (__DEPRECATED_MACRO 0x01) 620 #define BT_LE_ADV_SCAN_IND (__DEPRECATED_MACRO 0x02) 621 #define BT_LE_ADV_NONCONN_IND (__DEPRECATED_MACRO 0x03) 622 #define BT_LE_ADV_DIRECT_IND_LOW_DUTY (__DEPRECATED_MACRO 0x04) 623 /* LE Advertising PDU Types. */ 624 #define BT_LE_ADV_SCAN_RSP (__DEPRECATED_MACRO 0x04) 625 626 #define BT_HCI_ADV_IND 0x00 627 #define BT_HCI_ADV_DIRECT_IND 0x01 628 #define BT_HCI_ADV_SCAN_IND 0x02 629 #define BT_HCI_ADV_NONCONN_IND 0x03 630 #define BT_HCI_ADV_DIRECT_IND_LOW_DUTY 0x04 631 #define BT_HCI_ADV_SCAN_RSP 0x04 632 633 #define BT_LE_ADV_FP_NO_WHITELIST 0x00 634 #define BT_LE_ADV_FP_WHITELIST_SCAN_REQ 0x01 635 #define BT_LE_ADV_FP_WHITELIST_CONN_IND 0x02 636 #define BT_LE_ADV_FP_WHITELIST_BOTH 0x03 637 638 #define BT_HCI_OP_LE_SET_ADV_PARAM BT_OP(BT_OGF_LE, 0x0006) 639 struct bt_hci_cp_le_set_adv_param { 640 u16_t min_interval; 641 u16_t max_interval; 642 u8_t type; 643 u8_t own_addr_type; 644 bt_addr_le_t direct_addr; 645 u8_t channel_map; 646 u8_t filter_policy; 647 } __packed; 648 649 #define BT_HCI_OP_LE_READ_ADV_CHAN_TX_POWER BT_OP(BT_OGF_LE, 0x0007) 650 struct bt_hci_rp_le_read_chan_tx_power { 651 u8_t status; 652 s8_t tx_power_level; 653 } __packed; 654 655 #define BT_HCI_OP_LE_SET_ADV_DATA BT_OP(BT_OGF_LE, 0x0008) 656 struct bt_hci_cp_le_set_adv_data { 657 u8_t len; 658 u8_t data[31]; 659 } __packed; 660 661 #define BT_HCI_OP_LE_SET_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0009) 662 struct bt_hci_cp_le_set_scan_rsp_data { 663 u8_t len; 664 u8_t data[31]; 665 } __packed; 666 667 #define BT_HCI_LE_ADV_DISABLE 0x00 668 #define BT_HCI_LE_ADV_ENABLE 0x01 669 670 #define BT_HCI_OP_LE_SET_ADV_ENABLE BT_OP(BT_OGF_LE, 0x000a) 671 struct bt_hci_cp_le_set_adv_enable { 672 u8_t enable; 673 } __packed; 674 675 /* Scan types */ 676 #define BT_HCI_OP_LE_SET_SCAN_PARAM BT_OP(BT_OGF_LE, 0x000b) 677 #define BT_HCI_LE_SCAN_PASSIVE 0x00 678 #define BT_HCI_LE_SCAN_ACTIVE 0x01 679 680 #define BT_HCI_LE_SCAN_FP_NO_WHITELIST 0x00 681 #define BT_HCI_LE_SCAN_FP_USE_WHITELIST 0x01 682 683 struct bt_hci_cp_le_set_scan_param { 684 u8_t scan_type; 685 u16_t interval; 686 u16_t window; 687 u8_t addr_type; 688 u8_t filter_policy; 689 } __packed; 690 691 #define BT_HCI_OP_LE_SET_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x000c) 692 693 #define BT_HCI_LE_SCAN_DISABLE 0x00 694 #define BT_HCI_LE_SCAN_ENABLE 0x01 695 696 #define BT_HCI_LE_SCAN_FILTER_DUP_DISABLE 0x00 697 #define BT_HCI_LE_SCAN_FILTER_DUP_ENABLE 0x01 698 699 struct bt_hci_cp_le_set_scan_enable { 700 u8_t enable; 701 u8_t filter_dup; 702 } __packed; 703 704 #define BT_HCI_OP_LE_CREATE_CONN BT_OP(BT_OGF_LE, 0x000d) 705 706 #define BT_HCI_LE_CREATE_CONN_FP_DIRECT 0x00 707 #define BT_HCI_LE_CREATE_CONN_FP_WHITELIST 0x01 708 709 struct bt_hci_cp_le_create_conn { 710 u16_t scan_interval; 711 u16_t scan_window; 712 u8_t filter_policy; 713 bt_addr_le_t peer_addr; 714 u8_t own_addr_type; 715 u16_t conn_interval_min; 716 u16_t conn_interval_max; 717 u16_t conn_latency; 718 u16_t supervision_timeout; 719 u16_t min_ce_len; 720 u16_t max_ce_len; 721 } __packed; 722 723 #define BT_HCI_OP_LE_CREATE_CONN_CANCEL BT_OP(BT_OGF_LE, 0x000e) 724 725 #define BT_HCI_OP_LE_READ_WL_SIZE BT_OP(BT_OGF_LE, 0x000f) 726 struct bt_hci_rp_le_read_wl_size { 727 u8_t status; 728 u8_t wl_size; 729 } __packed; 730 731 #define BT_HCI_OP_LE_CLEAR_WL BT_OP(BT_OGF_LE, 0x0010) 732 733 #define BT_HCI_OP_LE_ADD_DEV_TO_WL BT_OP(BT_OGF_LE, 0x0011) 734 struct bt_hci_cp_le_add_dev_to_wl { 735 bt_addr_le_t addr; 736 } __packed; 737 738 #define BT_HCI_OP_LE_REM_DEV_FROM_WL BT_OP(BT_OGF_LE, 0x0012) 739 struct bt_hci_cp_le_rem_dev_from_wl { 740 bt_addr_le_t addr; 741 } __packed; 742 743 #define BT_HCI_OP_LE_CONN_UPDATE BT_OP(BT_OGF_LE, 0x0013) 744 struct hci_cp_le_conn_update { 745 u16_t handle; 746 u16_t conn_interval_min; 747 u16_t conn_interval_max; 748 u16_t conn_latency; 749 u16_t supervision_timeout; 750 u16_t min_ce_len; 751 u16_t max_ce_len; 752 } __packed; 753 754 #define BT_HCI_OP_LE_SET_HOST_CHAN_CLASSIF BT_OP(BT_OGF_LE, 0x0014) 755 struct bt_hci_cp_le_set_host_chan_classif { 756 u8_t ch_map[5]; 757 } __packed; 758 759 #define BT_HCI_OP_LE_READ_CHAN_MAP BT_OP(BT_OGF_LE, 0x0015) 760 struct bt_hci_cp_le_read_chan_map { 761 u16_t handle; 762 } __packed; 763 struct bt_hci_rp_le_read_chan_map { 764 u8_t status; 765 u16_t handle; 766 u8_t ch_map[5]; 767 } __packed; 768 769 #define BT_HCI_OP_LE_READ_REMOTE_FEATURES BT_OP(BT_OGF_LE, 0x0016) 770 struct bt_hci_cp_le_read_remote_features { 771 u16_t handle; 772 } __packed; 773 774 #define BT_HCI_OP_LE_ENCRYPT BT_OP(BT_OGF_LE, 0x0017) 775 struct bt_hci_cp_le_encrypt { 776 u8_t key[16]; 777 u8_t plaintext[16]; 778 } __packed; 779 struct bt_hci_rp_le_encrypt { 780 u8_t status; 781 u8_t enc_data[16]; 782 } __packed; 783 784 #define BT_HCI_OP_LE_RAND BT_OP(BT_OGF_LE, 0x0018) 785 struct bt_hci_rp_le_rand { 786 u8_t status; 787 u8_t rand[8]; 788 } __packed; 789 790 #define BT_HCI_OP_LE_START_ENCRYPTION BT_OP(BT_OGF_LE, 0x0019) 791 struct bt_hci_cp_le_start_encryption { 792 u16_t handle; 793 u64_t rand; 794 u16_t ediv; 795 u8_t ltk[16]; 796 } __packed; 797 798 #define BT_HCI_OP_LE_LTK_REQ_REPLY BT_OP(BT_OGF_LE, 0x001a) 799 struct bt_hci_cp_le_ltk_req_reply { 800 u16_t handle; 801 u8_t ltk[16]; 802 } __packed; 803 struct bt_hci_rp_le_ltk_req_reply { 804 u8_t status; 805 u16_t handle; 806 } __packed; 807 808 #define BT_HCI_OP_LE_LTK_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x001b) 809 struct bt_hci_cp_le_ltk_req_neg_reply { 810 u16_t handle; 811 } __packed; 812 struct bt_hci_rp_le_ltk_req_neg_reply { 813 u8_t status; 814 u16_t handle; 815 } __packed; 816 817 #define BT_HCI_OP_LE_READ_SUPP_STATES BT_OP(BT_OGF_LE, 0x001c) 818 struct bt_hci_rp_le_read_supp_states { 819 u8_t status; 820 u8_t le_states[8]; 821 } __packed; 822 823 #define BT_HCI_OP_LE_RX_TEST BT_OP(BT_OGF_LE, 0x001d) 824 struct bt_hci_cp_le_rx_test { 825 u8_t rx_ch; 826 } __packed; 827 828 #define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e) 829 struct bt_hci_cp_le_tx_test { 830 u8_t tx_ch; 831 u8_t test_data_len; 832 u8_t pkt_payload; 833 } __packed; 834 835 #define BT_HCI_OP_LE_TEST_END BT_OP(BT_OGF_LE, 0x001f) 836 struct bt_hci_rp_le_test_end { 837 u8_t status; 838 u16_t rx_pkt_count; 839 } __packed; 840 841 #define BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY BT_OP(BT_OGF_LE, 0x0020) 842 struct bt_hci_cp_le_conn_param_req_reply { 843 u16_t handle; 844 u16_t interval_min; 845 u16_t interval_max; 846 u16_t latency; 847 u16_t timeout; 848 u16_t min_ce_len; 849 u16_t max_ce_len; 850 } __packed; 851 struct bt_hci_rp_le_conn_param_req_reply { 852 u8_t status; 853 u16_t handle; 854 } __packed; 855 856 #define BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x0021) 857 struct bt_hci_cp_le_conn_param_req_neg_reply { 858 u16_t handle; 859 u8_t reason; 860 } __packed; 861 struct bt_hci_rp_le_conn_param_req_neg_reply { 862 u8_t status; 863 u16_t handle; 864 } __packed; 865 866 #define BT_HCI_OP_LE_SET_DATA_LEN BT_OP(BT_OGF_LE, 0x0022) 867 struct bt_hci_cp_le_set_data_len { 868 u16_t handle; 869 u16_t tx_octets; 870 u16_t tx_time; 871 } __packed; 872 struct bt_hci_rp_le_set_data_len { 873 u8_t status; 874 u16_t handle; 875 } __packed; 876 877 #define BT_HCI_OP_LE_READ_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0023) 878 struct bt_hci_rp_le_read_default_data_len { 879 u8_t status; 880 u16_t max_tx_octets; 881 u16_t max_tx_time; 882 } __packed; 883 884 #define BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0024) 885 struct bt_hci_cp_le_write_default_data_len { 886 u16_t max_tx_octets; 887 u16_t max_tx_time; 888 } __packed; 889 890 #define BT_HCI_OP_LE_P256_PUBLIC_KEY BT_OP(BT_OGF_LE, 0x0025) 891 892 #define BT_HCI_OP_LE_GENERATE_DHKEY BT_OP(BT_OGF_LE, 0x0026) 893 struct bt_hci_cp_le_generate_dhkey { 894 u8_t key[64]; 895 } __packed; 896 897 #define BT_HCI_OP_LE_ADD_DEV_TO_RL BT_OP(BT_OGF_LE, 0x0027) 898 struct bt_hci_cp_le_add_dev_to_rl { 899 bt_addr_le_t peer_id_addr; 900 u8_t peer_irk[16]; 901 u8_t local_irk[16]; 902 } __packed; 903 904 #define BT_HCI_OP_LE_REM_DEV_FROM_RL BT_OP(BT_OGF_LE, 0x0028) 905 struct bt_hci_cp_le_rem_dev_from_rl { 906 bt_addr_le_t peer_id_addr; 907 } __packed; 908 909 #define BT_HCI_OP_LE_CLEAR_RL BT_OP(BT_OGF_LE, 0x0029) 910 911 #define BT_HCI_OP_LE_READ_RL_SIZE BT_OP(BT_OGF_LE, 0x002a) 912 struct bt_hci_rp_le_read_rl_size { 913 u8_t status; 914 u8_t rl_size; 915 } __packed; 916 917 #define BT_HCI_OP_LE_READ_PEER_RPA BT_OP(BT_OGF_LE, 0x002b) 918 struct bt_hci_cp_le_read_peer_rpa { 919 bt_addr_le_t peer_id_addr; 920 } __packed; 921 struct bt_hci_rp_le_read_peer_rpa { 922 u8_t status; 923 bt_addr_t peer_rpa; 924 } __packed; 925 926 #define BT_HCI_OP_LE_READ_LOCAL_RPA BT_OP(BT_OGF_LE, 0x002c) 927 struct bt_hci_cp_le_read_local_rpa { 928 bt_addr_le_t peer_id_addr; 929 } __packed; 930 struct bt_hci_rp_le_read_local_rpa { 931 u8_t status; 932 bt_addr_t local_rpa; 933 } __packed; 934 935 #define BT_HCI_ADDR_RES_DISABLE 0x00 936 #define BT_HCI_ADDR_RES_ENABLE 0x01 937 938 #define BT_HCI_OP_LE_SET_ADDR_RES_ENABLE BT_OP(BT_OGF_LE, 0x002d) 939 struct bt_hci_cp_le_set_addr_res_enable { 940 u8_t enable; 941 } __packed; 942 943 #define BT_HCI_OP_LE_SET_RPA_TIMEOUT BT_OP(BT_OGF_LE, 0x002e) 944 struct bt_hci_cp_le_set_rpa_timeout { 945 u16_t rpa_timeout; 946 } __packed; 947 948 #define BT_HCI_OP_LE_READ_MAX_DATA_LEN BT_OP(BT_OGF_LE, 0x002f) 949 struct bt_hci_rp_le_read_max_data_len { 950 u8_t status; 951 u16_t max_tx_octets; 952 u16_t max_tx_time; 953 u16_t max_rx_octets; 954 u16_t max_rx_time; 955 } __packed; 956 957 #define BT_HCI_LE_PHY_1M 0x01 958 #define BT_HCI_LE_PHY_2M 0x02 959 #define BT_HCI_LE_PHY_CODED 0x03 960 961 #define BT_HCI_OP_LE_READ_PHY BT_OP(BT_OGF_LE, 0x0030) 962 struct bt_hci_cp_le_read_phy { 963 u16_t handle; 964 } __packed; 965 struct bt_hci_rp_le_read_phy { 966 u8_t status; 967 u16_t handle; 968 u8_t tx_phy; 969 u8_t rx_phy; 970 } __packed; 971 972 #define BT_HCI_LE_PHY_TX_ANY BIT(0) 973 #define BT_HCI_LE_PHY_RX_ANY BIT(1) 974 975 #define BT_HCI_LE_PHY_PREFER_1M BIT(0) 976 #define BT_HCI_LE_PHY_PREFER_2M BIT(1) 977 #define BT_HCI_LE_PHY_PREFER_CODED BIT(2) 978 979 #define BT_HCI_OP_LE_SET_DEFAULT_PHY BT_OP(BT_OGF_LE, 0x0031) 980 struct bt_hci_cp_le_set_default_phy { 981 u8_t all_phys; 982 u8_t tx_phys; 983 u8_t rx_phys; 984 } __packed; 985 986 #define BT_HCI_LE_PHY_CODED_ANY 0x00 987 #define BT_HCI_LE_PHY_CODED_S2 0x01 988 #define BT_HCI_LE_PHY_CODED_S8 0x02 989 990 #define BT_HCI_OP_LE_SET_PHY BT_OP(BT_OGF_LE, 0x0032) 991 struct bt_hci_cp_le_set_phy { 992 u16_t handle; 993 u8_t all_phys; 994 u8_t tx_phys; 995 u8_t rx_phys; 996 u16_t phy_opts; 997 } __packed; 998 999 #define BT_HCI_LE_MOD_INDEX_STANDARD 0x00 1000 #define BT_HCI_LE_MOD_INDEX_STABLE 0x01 1001 1002 #define BT_HCI_OP_LE_ENH_RX_TEST BT_OP(BT_OGF_LE, 0x0033) 1003 struct bt_hci_cp_le_enh_rx_test { 1004 u8_t rx_ch; 1005 u8_t phy; 1006 u8_t mod_index; 1007 } __packed; 1008 1009 /* Extends BT_HCI_LE_PHY */ 1010 #define BT_HCI_LE_TX_PHY_CODED_S8 0x03 1011 #define BT_HCI_LE_TX_PHY_CODED_S2 0x04 1012 1013 #define BT_HCI_OP_LE_ENH_TX_TEST BT_OP(BT_OGF_LE, 0x0034) 1014 struct bt_hci_cp_le_enh_tx_test { 1015 u8_t tx_ch; 1016 u8_t test_data_len; 1017 u8_t pkt_payload; 1018 u8_t phy; 1019 } __packed; 1020 1021 #define BT_HCI_OP_LE_SET_ADV_SET_RANDOM_ADDR BT_OP(BT_OGF_LE, 0x0035) 1022 struct bt_hci_cp_le_set_adv_set_random_addr { 1023 u8_t handle; 1024 bt_addr_t bdaddr; 1025 } __packed; 1026 1027 #define BT_HCI_LE_ADV_PROP_CONN BIT(0) 1028 #define BT_HCI_LE_ADV_PROP_SCAN BIT(1) 1029 #define BT_HCI_LE_ADV_PROP_DIRECT BIT(2) 1030 #define BT_HCI_LE_ADV_PROP_HI_DC_CONN BIT(3) 1031 #define BT_HCI_LE_ADV_PROP_LEGACY BIT(4) 1032 #define BT_HCI_LE_ADV_PROP_ANON BIT(5) 1033 #define BT_HCI_LE_ADV_PROP_TX_POWER BIT(6) 1034 1035 #define BT_HCI_LE_ADV_SCAN_REQ_ENABLE 1 1036 #define BT_HCI_LE_ADV_SCAN_REQ_DISABLE 0 1037 1038 #define BT_HCI_LE_ADV_TX_POWER_NO_PREF 0x7F 1039 1040 #define BT_HCI_OP_LE_SET_EXT_ADV_PARAM BT_OP(BT_OGF_LE, 0x0036) 1041 struct bt_hci_cp_le_set_ext_adv_param { 1042 u8_t handle; 1043 u16_t props; 1044 u8_t prim_min_interval[3]; 1045 u8_t prim_max_interval[3]; 1046 u8_t prim_channel_map; 1047 u8_t own_addr_type; 1048 bt_addr_le_t peer_addr; 1049 u8_t filter_policy; 1050 s8_t tx_power; 1051 u8_t prim_adv_phy; 1052 u8_t sec_adv_max_skip; 1053 u8_t sec_adv_phy; 1054 u8_t sid; 1055 u8_t scan_req_notify_enable; 1056 } __packed; 1057 struct bt_hci_rp_le_set_ext_adv_param { 1058 u8_t status; 1059 s8_t tx_power; 1060 } __packed; 1061 1062 #define BT_HCI_LE_EXT_ADV_OP_INTERM_FRAG 0x00 1063 #define BT_HCI_LE_EXT_ADV_OP_FIRST_FRAG 0x01 1064 #define BT_HCI_LE_EXT_ADV_OP_LAST_FRAG 0x02 1065 #define BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA 0x03 1066 #define BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA 0x04 1067 1068 #define BT_HCI_LE_EXT_ADV_FRAG_ENABLED 0x00 1069 #define BT_HCI_LE_EXT_ADV_FRAG_DISABLED 0x01 1070 1071 #define BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN 251 1072 1073 #define BT_HCI_OP_LE_SET_EXT_ADV_DATA BT_OP(BT_OGF_LE, 0x0037) 1074 struct bt_hci_cp_le_set_ext_adv_data { 1075 u8_t handle; 1076 u8_t op; 1077 u8_t frag_pref; 1078 u8_t len; 1079 u8_t data[251]; 1080 } __packed; 1081 1082 #define BT_HCI_OP_LE_SET_EXT_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0038) 1083 struct bt_hci_cp_le_set_ext_scan_rsp_data { 1084 u8_t handle; 1085 u8_t op; 1086 u8_t frag_pref; 1087 u8_t len; 1088 u8_t data[251]; 1089 } __packed; 1090 1091 #define BT_HCI_OP_LE_SET_EXT_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0039) 1092 struct bt_hci_ext_adv_set { 1093 u8_t handle; 1094 u16_t duration; 1095 u8_t max_ext_adv_evts; 1096 } __packed; 1097 1098 struct bt_hci_cp_le_set_ext_adv_enable { 1099 u8_t enable; 1100 u8_t set_num; 1101 struct bt_hci_ext_adv_set s[0]; 1102 } __packed; 1103 1104 #define BT_HCI_OP_LE_READ_MAX_ADV_DATA_LEN BT_OP(BT_OGF_LE, 0x003a) 1105 struct bt_hci_rp_le_read_max_adv_data_len { 1106 u8_t status; 1107 u16_t max_adv_data_len; 1108 } __packed; 1109 1110 #define BT_HCI_OP_LE_READ_NUM_ADV_SETS BT_OP(BT_OGF_LE, 0x003b) 1111 struct bt_hci_rp_le_read_num_adv_sets { 1112 u8_t status; 1113 u8_t num_sets; 1114 } __packed; 1115 1116 #define BT_HCI_OP_LE_REMOVE_ADV_SET BT_OP(BT_OGF_LE, 0x003c) 1117 struct bt_hci_cp_le_remove_adv_set { 1118 u8_t handle; 1119 } __packed; 1120 1121 #define BT_HCI_OP_CLEAR_ADV_SETS BT_OP(BT_OGF_LE, 0x003d) 1122 1123 #define BT_HCI_OP_LE_SET_PER_ADV_PARAM BT_OP(BT_OGF_LE, 0x003e) 1124 struct bt_hci_cp_le_set_per_adv_param { 1125 u8_t handle; 1126 u16_t min_interval; 1127 u16_t max_interval; 1128 u16_t props; 1129 } __packed; 1130 1131 #define BT_HCI_OP_LE_SET_PER_ADV_DATA BT_OP(BT_OGF_LE, 0x003f) 1132 struct bt_hci_cp_le_set_per_adv_data { 1133 u8_t handle; 1134 u8_t op; 1135 u8_t len; 1136 u8_t data[251]; 1137 } __packed; 1138 1139 #define BT_HCI_OP_LE_SET_PER_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0040) 1140 struct bt_hci_cp_le_set_per_adv_enable { 1141 u8_t enable; 1142 u8_t handle; 1143 } __packed; 1144 1145 #define BT_HCI_OP_LE_SET_EXT_SCAN_PARAM BT_OP(BT_OGF_LE, 0x0041) 1146 struct bt_hci_ext_scan_phy { 1147 u8_t type; 1148 u16_t interval; 1149 u16_t window; 1150 } __packed; 1151 1152 #define BT_HCI_LE_EXT_SCAN_PHY_1M BIT(0) 1153 #define BT_HCI_LE_EXT_SCAN_PHY_2M BIT(1) 1154 #define BT_HCI_LE_EXT_SCAN_PHY_CODED BIT(2) 1155 1156 struct bt_hci_cp_le_set_ext_scan_param { 1157 u8_t own_addr_type; 1158 u8_t filter_policy; 1159 u8_t phys; 1160 struct bt_hci_ext_scan_phy p[0]; 1161 } __packed; 1162 1163 /* Extends BT_HCI_LE_SCAN_FILTER_DUP */ 1164 #define BT_HCI_LE_EXT_SCAN_FILTER_DUP_ENABLE_RESET 0x02 1165 1166 #define BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x0042) 1167 struct bt_hci_cp_le_set_ext_scan_enable { 1168 u8_t enable; 1169 u8_t filter_dup; 1170 u16_t duration; 1171 u16_t period; 1172 } __packed; 1173 1174 #define BT_HCI_OP_LE_EXT_CREATE_CONN BT_OP(BT_OGF_LE, 0x0043) 1175 struct bt_hci_ext_conn_phy { 1176 u16_t scan_interval; 1177 u16_t scan_window; 1178 u16_t conn_interval_min; 1179 u16_t conn_interval_max; 1180 u16_t conn_latency; 1181 u16_t supervision_timeout; 1182 u16_t min_ce_len; 1183 u16_t max_ce_len; 1184 } __packed; 1185 1186 struct bt_hci_cp_le_ext_create_conn { 1187 u8_t filter_policy; 1188 u8_t own_addr_type; 1189 bt_addr_le_t peer_addr; 1190 u8_t phys; 1191 struct bt_hci_ext_conn_phy p[0]; 1192 } __packed; 1193 1194 #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC BT_OP(BT_OGF_LE, 0x0044) 1195 struct bt_hci_cp_le_per_adv_create_sync { 1196 u8_t filter_policy; 1197 u8_t sid; 1198 bt_addr_le_t addr; 1199 u16_t skip; 1200 u16_t sync_timeout; 1201 u8_t unused; 1202 } __packed; 1203 1204 #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC_CANCEL BT_OP(BT_OGF_LE, 0x0045) 1205 1206 #define BT_HCI_OP_LE_PER_ADV_TERMINATE_SYNC BT_OP(BT_OGF_LE, 0x0046) 1207 struct bt_hci_cp_le_per_adv_terminate_sync { 1208 u16_t handle; 1209 } __packed; 1210 1211 #define BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0047) 1212 struct bt_hci_cp_le_add_dev_to_per_adv_list { 1213 bt_addr_le_t addr; 1214 u8_t sid; 1215 } __packed; 1216 1217 #define BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0048) 1218 struct bt_hci_cp_le_rem_dev_from_per_adv_list { 1219 bt_addr_le_t addr; 1220 u8_t sid; 1221 } __packed; 1222 1223 #define BT_HCI_OP_LE_CLEAR_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0049) 1224 1225 #define BT_HCI_OP_LE_READ_PER_ADV_LIST_SIZE BT_OP(BT_OGF_LE, 0x004a) 1226 struct bt_hci_rp_le_read_per_adv_list_size { 1227 u8_t status; 1228 u8_t list_size; 1229 } __packed; 1230 1231 #define BT_HCI_OP_LE_READ_TX_POWER BT_OP(BT_OGF_LE, 0x004b) 1232 struct bt_hci_rp_le_read_tx_power { 1233 u8_t status; 1234 s8_t min_tx_power; 1235 s8_t max_tx_power; 1236 } __packed; 1237 1238 #define BT_HCI_OP_LE_READ_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004c) 1239 struct bt_hci_rp_le_read_rf_path_comp { 1240 u8_t status; 1241 s16_t tx_path_comp; 1242 s16_t rx_path_comp; 1243 } __packed; 1244 1245 #define BT_HCI_OP_LE_WRITE_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004d) 1246 struct bt_hci_cp_le_write_rf_path_comp { 1247 s16_t tx_path_comp; 1248 s16_t rx_path_comp; 1249 } __packed; 1250 1251 #define BT_HCI_LE_PRIVACY_MODE_NETWORK 0x00 1252 #define BT_HCI_LE_PRIVACY_MODE_DEVICE 0x01 1253 1254 #define BT_HCI_OP_LE_SET_PRIVACY_MODE BT_OP(BT_OGF_LE, 0x004e) 1255 struct bt_hci_cp_le_set_privacy_mode { 1256 bt_addr_le_t id_addr; 1257 u8_t mode; 1258 } __packed; 1259 1260 /* Event definitions */ 1261 1262 #define BT_HCI_EVT_UNKNOWN 0x00 1263 #define BT_HCI_EVT_VENDOR 0xff 1264 1265 #define BT_HCI_EVT_INQUIRY_COMPLETE 0x01 1266 struct bt_hci_evt_inquiry_complete { 1267 u8_t status; 1268 } __packed; 1269 1270 #define BT_HCI_EVT_CONN_COMPLETE 0x03 1271 struct bt_hci_evt_conn_complete { 1272 u8_t status; 1273 u16_t handle; 1274 bt_addr_t bdaddr; 1275 u8_t link_type; 1276 u8_t encr_enabled; 1277 } __packed; 1278 1279 #define BT_HCI_EVT_CONN_REQUEST 0x04 1280 struct bt_hci_evt_conn_request { 1281 bt_addr_t bdaddr; 1282 u8_t dev_class[3]; 1283 u8_t link_type; 1284 } __packed; 1285 1286 #define BT_HCI_EVT_DISCONN_COMPLETE 0x05 1287 struct bt_hci_evt_disconn_complete { 1288 u8_t status; 1289 u16_t handle; 1290 u8_t reason; 1291 } __packed; 1292 1293 #define BT_HCI_EVT_AUTH_COMPLETE 0x06 1294 struct bt_hci_evt_auth_complete { 1295 u8_t status; 1296 u16_t handle; 1297 } __packed; 1298 1299 #define BT_HCI_EVT_REMOTE_NAME_REQ_COMPLETE 0x07 1300 struct bt_hci_evt_remote_name_req_complete { 1301 u8_t status; 1302 bt_addr_t bdaddr; 1303 u8_t name[248]; 1304 } __packed; 1305 1306 #define BT_HCI_EVT_ENCRYPT_CHANGE 0x08 1307 struct bt_hci_evt_encrypt_change { 1308 u8_t status; 1309 u16_t handle; 1310 u8_t encrypt; 1311 } __packed; 1312 1313 #define BT_HCI_EVT_REMOTE_FEATURES 0x0b 1314 struct bt_hci_evt_remote_features { 1315 u8_t status; 1316 u16_t handle; 1317 u8_t features[8]; 1318 } __packed; 1319 1320 #define BT_HCI_EVT_REMOTE_VERSION_INFO 0x0c 1321 struct bt_hci_evt_remote_version_info { 1322 u8_t status; 1323 u16_t handle; 1324 u8_t version; 1325 u16_t manufacturer; 1326 u16_t subversion; 1327 } __packed; 1328 1329 #define BT_HCI_EVT_CMD_COMPLETE 0x0e 1330 struct bt_hci_evt_cmd_complete { 1331 u8_t ncmd; 1332 u16_t opcode; 1333 } __packed; 1334 1335 struct bt_hci_evt_cc_status { 1336 u8_t status; 1337 } __packed; 1338 1339 #define BT_HCI_EVT_CMD_STATUS 0x0f 1340 struct bt_hci_evt_cmd_status { 1341 u8_t status; 1342 u8_t ncmd; 1343 u16_t opcode; 1344 } __packed; 1345 1346 #define BT_HCI_EVT_ROLE_CHANGE 0x12 1347 struct bt_hci_evt_role_change { 1348 u8_t status; 1349 bt_addr_t bdaddr; 1350 u8_t role; 1351 } __packed; 1352 1353 #define BT_HCI_EVT_NUM_COMPLETED_PACKETS 0x13 1354 struct bt_hci_evt_num_completed_packets { 1355 u8_t num_handles; 1356 struct bt_hci_handle_count h[0]; 1357 } __packed; 1358 1359 #define BT_HCI_EVT_PIN_CODE_REQ 0x16 1360 struct bt_hci_evt_pin_code_req { 1361 bt_addr_t bdaddr; 1362 } __packed; 1363 1364 #define BT_HCI_EVT_LINK_KEY_REQ 0x17 1365 struct bt_hci_evt_link_key_req { 1366 bt_addr_t bdaddr; 1367 } __packed; 1368 1369 /* Link Key types */ 1370 #define BT_LK_COMBINATION 0x00 1371 #define BT_LK_LOCAL_UNIT 0x01 1372 #define BT_LK_REMOTE_UNIT 0x02 1373 #define BT_LK_DEBUG_COMBINATION 0x03 1374 #define BT_LK_UNAUTH_COMBINATION_P192 0x04 1375 #define BT_LK_AUTH_COMBINATION_P192 0x05 1376 #define BT_LK_CHANGED_COMBINATION 0x06 1377 #define BT_LK_UNAUTH_COMBINATION_P256 0x07 1378 #define BT_LK_AUTH_COMBINATION_P256 0x08 1379 1380 #define BT_HCI_EVT_LINK_KEY_NOTIFY 0x18 1381 struct bt_hci_evt_link_key_notify { 1382 bt_addr_t bdaddr; 1383 u8_t link_key[16]; 1384 u8_t key_type; 1385 } __packed; 1386 1387 /* Overflow link types */ 1388 #define BT_OVERFLOW_LINK_SYNCH 0x00 1389 #define BT_OVERFLOW_LINK_ACL 0x01 1390 1391 #define BT_HCI_EVT_DATA_BUF_OVERFLOW 0x1a 1392 struct bt_hci_evt_data_buf_overflow { 1393 u8_t link_type; 1394 } __packed; 1395 1396 #define BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI 0x22 1397 struct bt_hci_evt_inquiry_result_with_rssi { 1398 bt_addr_t addr; 1399 u8_t pscan_rep_mode; 1400 u8_t reserved; 1401 u8_t cod[3]; 1402 u16_t clock_offset; 1403 s8_t rssi; 1404 } __packed; 1405 1406 #define BT_HCI_EVT_REMOTE_EXT_FEATURES 0x23 1407 struct bt_hci_evt_remote_ext_features { 1408 u8_t status; 1409 u16_t handle; 1410 u8_t page; 1411 u8_t max_page; 1412 u8_t features[8]; 1413 } __packed; 1414 1415 #define BT_HCI_EVT_SYNC_CONN_COMPLETE 0x2c 1416 struct bt_hci_evt_sync_conn_complete { 1417 u8_t status; 1418 u16_t handle; 1419 bt_addr_t bdaddr; 1420 u8_t link_type; 1421 u8_t tx_interval; 1422 u8_t retansmission_window; 1423 u16_t rx_pkt_length; 1424 u16_t tx_pkt_length; 1425 u8_t air_mode; 1426 } __packed; 1427 1428 #define BT_HCI_EVT_EXTENDED_INQUIRY_RESULT 0x2f 1429 struct bt_hci_evt_extended_inquiry_result { 1430 u8_t num_reports; 1431 bt_addr_t addr; 1432 u8_t pscan_rep_mode; 1433 u8_t reserved; 1434 u8_t cod[3]; 1435 u16_t clock_offset; 1436 s8_t rssi; 1437 u8_t eir[240]; 1438 } __packed; 1439 1440 #define BT_HCI_EVT_ENCRYPT_KEY_REFRESH_COMPLETE 0x30 1441 struct bt_hci_evt_encrypt_key_refresh_complete { 1442 u8_t status; 1443 u16_t handle; 1444 } __packed; 1445 1446 #define BT_HCI_EVT_IO_CAPA_REQ 0x31 1447 struct bt_hci_evt_io_capa_req { 1448 bt_addr_t bdaddr; 1449 } __packed; 1450 1451 #define BT_HCI_EVT_IO_CAPA_RESP 0x32 1452 struct bt_hci_evt_io_capa_resp { 1453 bt_addr_t bdaddr; 1454 u8_t capability; 1455 u8_t oob_data; 1456 u8_t authentication; 1457 } __packed; 1458 1459 #define BT_HCI_EVT_USER_CONFIRM_REQ 0x33 1460 struct bt_hci_evt_user_confirm_req { 1461 bt_addr_t bdaddr; 1462 bt_u32_t passkey; 1463 } __packed; 1464 1465 #define BT_HCI_EVT_USER_PASSKEY_REQ 0x34 1466 struct bt_hci_evt_user_passkey_req { 1467 bt_addr_t bdaddr; 1468 } __packed; 1469 1470 #define BT_HCI_EVT_SSP_COMPLETE 0x36 1471 struct bt_hci_evt_ssp_complete { 1472 u8_t status; 1473 bt_addr_t bdaddr; 1474 } __packed; 1475 1476 #define BT_HCI_EVT_USER_PASSKEY_NOTIFY 0x3b 1477 struct bt_hci_evt_user_passkey_notify { 1478 bt_addr_t bdaddr; 1479 bt_u32_t passkey; 1480 } __packed; 1481 1482 #define BT_HCI_EVT_LE_META_EVENT 0x3e 1483 struct bt_hci_evt_le_meta_event { 1484 u8_t subevent; 1485 } __packed; 1486 1487 #define BT_HCI_EVT_AUTH_PAYLOAD_TIMEOUT_EXP 0x57 1488 struct bt_hci_evt_auth_payload_timeout_exp { 1489 u16_t handle; 1490 } __packed; 1491 1492 #define BT_HCI_ROLE_MASTER 0x00 1493 #define BT_HCI_ROLE_SLAVE 0x01 1494 1495 #define BT_HCI_EVT_LE_CONN_COMPLETE 0x01 1496 struct bt_hci_evt_le_conn_complete { 1497 u8_t status; 1498 u16_t handle; 1499 u8_t role; 1500 bt_addr_le_t peer_addr; 1501 u16_t interval; 1502 u16_t latency; 1503 u16_t supv_timeout; 1504 u8_t clock_accuracy; 1505 } __packed; 1506 1507 #define BT_HCI_EVT_LE_ADVERTISING_REPORT 0x02 1508 struct bt_hci_evt_le_advertising_info { 1509 u8_t evt_type; 1510 bt_addr_le_t addr; 1511 u8_t length; 1512 u8_t data[0]; 1513 } __packed; 1514 struct bt_hci_evt_le_advertising_report { 1515 u8_t num_reports; 1516 struct bt_hci_evt_le_advertising_info adv_info[0]; 1517 } __packed; 1518 1519 #define BT_HCI_EVT_LE_CONN_UPDATE_COMPLETE 0x03 1520 struct bt_hci_evt_le_conn_update_complete { 1521 u8_t status; 1522 u16_t handle; 1523 u16_t interval; 1524 u16_t latency; 1525 u16_t supv_timeout; 1526 } __packed; 1527 1528 #define BT_HCI_EV_LE_REMOTE_FEAT_COMPLETE 0x04 1529 struct bt_hci_evt_le_remote_feat_complete { 1530 u8_t status; 1531 u16_t handle; 1532 u8_t features[8]; 1533 } __packed; 1534 1535 #define BT_HCI_EVT_LE_LTK_REQUEST 0x05 1536 struct bt_hci_evt_le_ltk_request { 1537 u16_t handle; 1538 u64_t rand; 1539 u16_t ediv; 1540 } __packed; 1541 1542 #define BT_HCI_EVT_LE_CONN_PARAM_REQ 0x06 1543 struct bt_hci_evt_le_conn_param_req { 1544 u16_t handle; 1545 u16_t interval_min; 1546 u16_t interval_max; 1547 u16_t latency; 1548 u16_t timeout; 1549 } __packed; 1550 1551 #define BT_HCI_EVT_LE_DATA_LEN_CHANGE 0x07 1552 struct bt_hci_evt_le_data_len_change { 1553 u16_t handle; 1554 u16_t max_tx_octets; 1555 u16_t max_tx_time; 1556 u16_t max_rx_octets; 1557 u16_t max_rx_time; 1558 } __packed; 1559 1560 #define BT_HCI_EVT_LE_P256_PUBLIC_KEY_COMPLETE 0x08 1561 struct bt_hci_evt_le_p256_public_key_complete { 1562 u8_t status; 1563 u8_t key[64]; 1564 } __packed; 1565 1566 #define BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE 0x09 1567 struct bt_hci_evt_le_generate_dhkey_complete { 1568 u8_t status; 1569 u8_t dhkey[32]; 1570 } __packed; 1571 1572 #define BT_HCI_EVT_LE_ENH_CONN_COMPLETE 0x0a 1573 struct bt_hci_evt_le_enh_conn_complete { 1574 u8_t status; 1575 u16_t handle; 1576 u8_t role; 1577 bt_addr_le_t peer_addr; 1578 bt_addr_t local_rpa; 1579 bt_addr_t peer_rpa; 1580 u16_t interval; 1581 u16_t latency; 1582 u16_t supv_timeout; 1583 u8_t clock_accuracy; 1584 } __packed; 1585 1586 #define BT_HCI_EVT_LE_DIRECT_ADV_REPORT 0x0b 1587 struct bt_hci_evt_le_direct_adv_info { 1588 u8_t evt_type; 1589 bt_addr_le_t addr; 1590 bt_addr_le_t dir_addr; 1591 s8_t rssi; 1592 } __packed; 1593 struct bt_hci_evt_le_direct_adv_report { 1594 u8_t num_reports; 1595 struct bt_hci_evt_le_direct_adv_info direct_adv_info[0]; 1596 } __packed; 1597 1598 #define BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE 0x0c 1599 struct bt_hci_evt_le_phy_update_complete { 1600 u8_t status; 1601 u16_t handle; 1602 u8_t tx_phy; 1603 u8_t rx_phy; 1604 } __packed; 1605 1606 #define BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT 0x0d 1607 1608 #define BT_HCI_LE_ADV_EVT_TYPE_CONN BIT(0) 1609 #define BT_HCI_LE_ADV_EVT_TYPE_SCAN BIT(1) 1610 #define BT_HCI_LE_ADV_EVT_TYPE_DIRECT BIT(2) 1611 #define BT_HCI_LE_ADV_EVT_TYPE_SCAN_RSP BIT(3) 1612 #define BT_HCI_LE_ADV_EVT_TYPE_LEGACY BIT(4) 1613 1614 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS(ev_type) (((ev_type) >> 5) & 0x03) 1615 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_COMPLETE 0 1616 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL 1 1617 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE 2 1618 1619 struct bt_hci_evt_le_ext_advertising_info { 1620 u16_t evt_type; 1621 bt_addr_le_t addr; 1622 u8_t prim_phy; 1623 u8_t sec_phy; 1624 u8_t sid; 1625 s8_t tx_power; 1626 s8_t rssi; 1627 u16_t interval; 1628 bt_addr_le_t direct_addr; 1629 u8_t length; 1630 u8_t data[0]; 1631 } __packed; 1632 struct bt_hci_evt_le_ext_advertising_report { 1633 u8_t num_reports; 1634 struct bt_hci_evt_le_ext_advertising_info adv_info[0]; 1635 } __packed; 1636 1637 #define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED 0x0e 1638 struct bt_hci_evt_le_per_adv_sync_established { 1639 u8_t status; 1640 u16_t handle; 1641 u8_t sid; 1642 bt_addr_le_t adv_addr; 1643 u8_t phy; 1644 u16_t interval; 1645 u8_t clock_accuracy; 1646 } __packed; 1647 1648 #define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT 0x0f 1649 struct bt_hci_evt_le_per_advertising_report { 1650 u16_t handle; 1651 s8_t tx_power; 1652 s8_t rssi; 1653 u8_t unused; 1654 u8_t data_status; 1655 u8_t length; 1656 u8_t data[0]; 1657 } __packed; 1658 1659 #define BT_HCI_EVT_LE_PER_ADV_SYNC_LOST 0x10 1660 struct bt_hci_evt_le_per_adv_sync_lost { 1661 u16_t handle; 1662 } __packed; 1663 1664 #define BT_HCI_EVT_LE_SCAN_TIMEOUT 0x11 1665 1666 #define BT_HCI_EVT_LE_ADV_SET_TERMINATED 0x12 1667 struct bt_hci_evt_le_adv_set_terminated { 1668 u8_t status; 1669 u8_t adv_handle; 1670 u16_t conn_handle; 1671 u8_t num_completed_ext_adv_evts; 1672 } __packed; 1673 1674 #define BT_HCI_EVT_LE_SCAN_REQ_RECEIVED 0x13 1675 struct bt_hci_evt_le_scan_req_received { 1676 u8_t handle; 1677 bt_addr_le_t addr; 1678 } __packed; 1679 1680 #define BT_HCI_LE_CHAN_SEL_ALGO_1 0x00 1681 #define BT_HCI_LE_CHAN_SEL_ALGO_2 0x01 1682 1683 #define BT_HCI_EVT_LE_CHAN_SEL_ALGO 0x14 1684 struct bt_hci_evt_le_chan_sel_algo { 1685 u16_t handle; 1686 u8_t chan_sel_algo; 1687 } __packed; 1688 1689 /* Event mask bits */ 1690 1691 #define BT_EVT_BIT(n) (1ULL << (n)) 1692 1693 #define BT_EVT_MASK_INQUIRY_COMPLETE BT_EVT_BIT(0) 1694 #define BT_EVT_MASK_CONN_COMPLETE BT_EVT_BIT(2) 1695 #define BT_EVT_MASK_CONN_REQUEST BT_EVT_BIT(3) 1696 #define BT_EVT_MASK_DISCONN_COMPLETE BT_EVT_BIT(4) 1697 #define BT_EVT_MASK_AUTH_COMPLETE BT_EVT_BIT(5) 1698 #define BT_EVT_MASK_REMOTE_NAME_REQ_COMPLETE BT_EVT_BIT(6) 1699 #define BT_EVT_MASK_ENCRYPT_CHANGE BT_EVT_BIT(7) 1700 #define BT_EVT_MASK_REMOTE_FEATURES BT_EVT_BIT(10) 1701 #define BT_EVT_MASK_REMOTE_VERSION_INFO BT_EVT_BIT(11) 1702 #define BT_EVT_MASK_HARDWARE_ERROR BT_EVT_BIT(15) 1703 #define BT_EVT_MASK_ROLE_CHANGE BT_EVT_BIT(17) 1704 #define BT_EVT_MASK_PIN_CODE_REQ BT_EVT_BIT(21) 1705 #define BT_EVT_MASK_LINK_KEY_REQ BT_EVT_BIT(22) 1706 #define BT_EVT_MASK_LINK_KEY_NOTIFY BT_EVT_BIT(23) 1707 #define BT_EVT_MASK_DATA_BUFFER_OVERFLOW BT_EVT_BIT(25) 1708 #define BT_EVT_MASK_INQUIRY_RESULT_WITH_RSSI BT_EVT_BIT(33) 1709 #define BT_EVT_MASK_REMOTE_EXT_FEATURES BT_EVT_BIT(34) 1710 #define BT_EVT_MASK_SYNC_CONN_COMPLETE BT_EVT_BIT(43) 1711 #define BT_EVT_MASK_EXTENDED_INQUIRY_RESULT BT_EVT_BIT(46) 1712 #define BT_EVT_MASK_ENCRYPT_KEY_REFRESH_COMPLETE BT_EVT_BIT(47) 1713 #define BT_EVT_MASK_IO_CAPA_REQ BT_EVT_BIT(48) 1714 #define BT_EVT_MASK_IO_CAPA_RESP BT_EVT_BIT(49) 1715 #define BT_EVT_MASK_USER_CONFIRM_REQ BT_EVT_BIT(50) 1716 #define BT_EVT_MASK_USER_PASSKEY_REQ BT_EVT_BIT(51) 1717 #define BT_EVT_MASK_SSP_COMPLETE BT_EVT_BIT(53) 1718 #define BT_EVT_MASK_USER_PASSKEY_NOTIFY BT_EVT_BIT(58) 1719 #define BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61) 1720 1721 /* Page 2 */ 1722 #define BT_EVT_MASK_PHY_LINK_COMPLETE BT_EVT_BIT(0) 1723 #define BT_EVT_MASK_CH_SELECTED_COMPLETE BT_EVT_BIT(1) 1724 #define BT_EVT_MASK_DISCONN_PHY_LINK_COMPLETE BT_EVT_BIT(2) 1725 #define BT_EVT_MASK_PHY_LINK_LOSS_EARLY_WARN BT_EVT_BIT(3) 1726 #define BT_EVT_MASK_PHY_LINK_RECOVERY BT_EVT_BIT(4) 1727 #define BT_EVT_MASK_LOG_LINK_COMPLETE BT_EVT_BIT(5) 1728 #define BT_EVT_MASK_DISCONN_LOG_LINK_COMPLETE BT_EVT_BIT(6) 1729 #define BT_EVT_MASK_FLOW_SPEC_MODIFY_COMPLETE BT_EVT_BIT(7) 1730 #define BT_EVT_MASK_NUM_COMPLETE_DATA_BLOCKS BT_EVT_BIT(8) 1731 #define BT_EVT_MASK_AMP_START_TEST BT_EVT_BIT(9) 1732 #define BT_EVT_MASK_AMP_TEST_END BT_EVT_BIT(10) 1733 #define BT_EVT_MASK_AMP_RX_REPORT BT_EVT_BIT(11) 1734 #define BT_EVT_MASK_AMP_SR_MODE_CHANGE_COMPLETE BT_EVT_BIT(12) 1735 #define BT_EVT_MASK_AMP_STATUS_CHANGE BT_EVT_BIT(13) 1736 #define BT_EVT_MASK_TRIGG_CLOCK_CAPTURE BT_EVT_BIT(14) 1737 #define BT_EVT_MASK_SYNCH_TRAIN_COMPLETE BT_EVT_BIT(15) 1738 #define BT_EVT_MASK_SYNCH_TRAIN_RX BT_EVT_BIT(16) 1739 #define BT_EVT_MASK_CL_SLAVE_BC_RX BT_EVT_BIT(17) 1740 #define BT_EVT_MASK_CL_SLAVE_BC_TIMEOUT BT_EVT_BIT(18) 1741 #define BT_EVT_MASK_TRUNC_PAGE_COMPLETE BT_EVT_BIT(19) 1742 #define BT_EVT_MASK_SLAVE_PAGE_RSP_TIMEOUT BT_EVT_BIT(20) 1743 #define BT_EVT_MASK_CL_SLAVE_BC_CH_MAP_CHANGE BT_EVT_BIT(21) 1744 #define BT_EVT_MASK_INQUIRY_RSP_NOT BT_EVT_BIT(22) 1745 #define BT_EVT_MASK_AUTH_PAYLOAD_TIMEOUT_EXP BT_EVT_BIT(23) 1746 #define BT_EVT_MASK_SAM_STATUS_CHANGE BT_EVT_BIT(24) 1747 1748 #define BT_EVT_MASK_LE_CONN_COMPLETE BT_EVT_BIT(0) 1749 #define BT_EVT_MASK_LE_ADVERTISING_REPORT BT_EVT_BIT(1) 1750 #define BT_EVT_MASK_LE_CONN_UPDATE_COMPLETE BT_EVT_BIT(2) 1751 #define BT_EVT_MASK_LE_REMOTE_FEAT_COMPLETE BT_EVT_BIT(3) 1752 #define BT_EVT_MASK_LE_LTK_REQUEST BT_EVT_BIT(4) 1753 #define BT_EVT_MASK_LE_CONN_PARAM_REQ BT_EVT_BIT(5) 1754 #define BT_EVT_MASK_LE_DATA_LEN_CHANGE BT_EVT_BIT(6) 1755 #define BT_EVT_MASK_LE_P256_PUBLIC_KEY_COMPLETE BT_EVT_BIT(7) 1756 #define BT_EVT_MASK_LE_GENERATE_DHKEY_COMPLETE BT_EVT_BIT(8) 1757 #define BT_EVT_MASK_LE_ENH_CONN_COMPLETE BT_EVT_BIT(9) 1758 #define BT_EVT_MASK_LE_DIRECT_ADV_REPORT BT_EVT_BIT(10) 1759 #define BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE BT_EVT_BIT(11) 1760 #define BT_EVT_MASK_LE_EXT_ADVERTISING_REPORT BT_EVT_BIT(12) 1761 #define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED BT_EVT_BIT(13) 1762 #define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT BT_EVT_BIT(14) 1763 #define BT_EVT_MASK_LE_PER_ADV_SYNC_LOST BT_EVT_BIT(15) 1764 #define BT_EVT_MASK_LE_SCAN_TIMEOUT BT_EVT_BIT(16) 1765 #define BT_EVT_MASK_LE_ADV_SET_TERMINATED BT_EVT_BIT(17) 1766 #define BT_EVT_MASK_LE_SCAN_REQ_RECEIVED BT_EVT_BIT(18) 1767 #define BT_EVT_MASK_LE_CHAN_SEL_ALGO BT_EVT_BIT(19) 1768 1769 /** Allocate a HCI command buffer. 1770 * 1771 * This function allocates a new buffer for a HCI command. It is given 1772 * the OpCode (encoded e.g. using the BT_OP macro) and the total length 1773 * of the parameters. Upon successful return the buffer is ready to have 1774 * the parameters encoded into it. 1775 * 1776 * @param opcode Command OpCode. 1777 * @param param_len Length of command parameters. 1778 * 1779 * @return Newly allocated buffer. 1780 */ 1781 struct net_buf *bt_hci_cmd_create(u16_t opcode, u8_t param_len); 1782 1783 /** Send a HCI command asynchronously. 1784 * 1785 * This function is used for sending a HCI command asynchronously. It can 1786 * either be called for a buffer created using bt_hci_cmd_create(), or 1787 * if the command has no parameters a NULL can be passed instead. The 1788 * sending of the command will happen asynchronously, i.e. upon successful 1789 * return from this function the caller only knows that it was queued 1790 * successfully. 1791 * 1792 * If synchronous behavior, and retrieval of the Command Complete parameters 1793 * is desired, the bt_hci_cmd_send_sync() API should be used instead. 1794 * 1795 * @param opcode Command OpCode. 1796 * @param buf Command buffer or NULL (if no parameters). 1797 * 1798 * @return 0 on success or negative error value on failure. 1799 */ 1800 int bt_hci_cmd_send(u16_t opcode, struct net_buf *buf); 1801 1802 /** Send a HCI command synchronously. 1803 * 1804 * This function is used for sending a HCI command synchronously. It can 1805 * either be called for a buffer created using bt_hci_cmd_create(), or 1806 * if the command has no parameters a NULL can be passed instead. 1807 * 1808 * The function will block until a Command Status or a Command Complete 1809 * event is returned. If either of these have a non-zero status the function 1810 * will return a negative error code and the response reference will not 1811 * be set. If the command completed successfully and a non-NULL rsp parameter 1812 * was given, this parameter will be set to point to a buffer containing 1813 * the response parameters. 1814 * 1815 * @param opcode Command OpCode. 1816 * @param buf Command buffer or NULL (if no parameters). 1817 * @param rsp Place to store a reference to the command response. May 1818 * be NULL if the caller is not interested in the response 1819 * parameters. If non-NULL is passed the caller is responsible 1820 * for calling net_buf_unref() on the buffer when done parsing 1821 * it. 1822 * 1823 * @return 0 on success or negative error value on failure. 1824 */ 1825 int bt_hci_cmd_send_sync(u16_t opcode, struct net_buf *buf, 1826 struct net_buf **rsp); 1827 1828 /** @brief Get connection handle for a connection. 1829 * 1830 * @param conn Connection object. 1831 * @param conn_handle Place to store the Connection handle. 1832 * 1833 * @return 0 on success or negative error value on failure. 1834 */ 1835 int bt_hci_get_conn_handle(const struct bt_conn *conn, u16_t *conn_handle); 1836 1837 /** @typedef bt_hci_vnd_evt_cb_t 1838 * @brief Callback type for vendor handling of HCI Vendor-Specific Events. 1839 * 1840 * A function of this type is registered with bt_hci_register_vnd_evt_cb() 1841 * and will be called for any HCI Vendor-Specific Event. 1842 * 1843 * @param buf Buffer containing event parameters. 1844 * 1845 * @return true if the function handles the event or false to defer the 1846 * handling of this event back to the stack. 1847 */ 1848 typedef bool bt_hci_vnd_evt_cb_t(struct net_buf_simple *buf); 1849 1850 /** Register user callback for HCI Vendor-Specific Events 1851 * 1852 * @param cb Callback to be called when the stack receives a 1853 * HCI Vendor-Specific Event. 1854 * 1855 * @return 0 on success or negative error value on failure. 1856 */ 1857 int bt_hci_register_vnd_evt_cb(bt_hci_vnd_evt_cb_t cb); 1858 1859 #ifdef __cplusplus 1860 } 1861 #endif 1862 1863 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_ */ 1864