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 19 #ifndef HCIMSGS_H 20 #define HCIMSGS_H 21 22 #include "bt_target.h" 23 #include "bt_types.h" 24 #include "device/include/esco_parameters.h" 25 #include "hcidefs.h" 26 27 #include <base/callback_forward.h> 28 29 void bte_main_hci_send(BT_HDR* p_msg, uint16_t event); 30 31 /* Message by message.... */ 32 33 /* Inquiry */ 34 /* Inquiry Cancel */ 35 36 /* Periodic Inquiry Mode */ 37 extern void btsnd_hcic_per_inq_mode(uint16_t max_period, uint16_t min_period, 38 const LAP inq_lap, uint8_t duration, 39 uint8_t response_cnt); 40 41 /* Periodic Inquiry Mode */ 42 43 /* Exit Periodic Inquiry Mode */ 44 extern void btsnd_hcic_exit_per_inq(void); 45 46 /* Create Connection */ 47 extern void btsnd_hcic_create_conn(const RawAddress& dest, 48 uint16_t packet_types, 49 uint8_t page_scan_rep_mode, 50 uint8_t page_scan_mode, 51 uint16_t clock_offset, uint8_t allow_switch); 52 53 /* Create Connection */ 54 55 /* Disconnect */ 56 namespace bluetooth { 57 namespace legacy { 58 namespace hci { 59 struct Interface { 60 // LINK_CONTROL 0x04xx 61 void (*StartInquiry)(const LAP inq_lap, uint8_t duration, 62 uint8_t response_cnt); 63 void (*InquiryCancel)(); 64 void (*StartPeriodicInquiryMode)(uint16_t max_period, uint16_t min_period, 65 const LAP inq_lap, uint8_t duration, 66 uint8_t response_cnt); 67 void (*ExitPeriodicInquiryMode)(); 68 void (*CreateConnection)(const RawAddress& dest, uint16_t packet_types, 69 uint8_t page_scan_rep_mode, uint8_t page_scan_mode, 70 uint16_t clock_offset, uint8_t allow_switch); 71 void (*Disconnect)(uint16_t handle, uint8_t reason); 72 // UNUSED 0x0407 btsnd_hcic_add_SCO_conn 73 void (*CreateConnectionCancel)(const RawAddress& dest); 74 void (*AcceptConnectionRequest)(const RawAddress& dest, uint8_t role); 75 void (*RejectConnectionRequest)(const RawAddress& dest, uint8_t reason); 76 void (*LinkKeyRequestReply)(const RawAddress& bd_addr, 77 const LinkKey& link_key); 78 void (*LinkKeyRequestNegativeReply)(const RawAddress& bd_addr); 79 void (*PinCodeRequestReply)(const RawAddress& bd_addr, uint8_t pin_code_len, 80 PIN_CODE pin_code); 81 void (*PinCodeRequestNegativeReply)(const RawAddress& bd_addr); 82 void (*ChangeConnectionPacketType)(uint16_t handle, uint16_t packet_types); 83 void (*AuthenticationRequested)(uint16_t handle); 84 void (*SetConnectionEncryption)(uint16_t handle, bool enable); 85 void (*ChangeConnectionLinkKey)(); // 0x0415, 86 // UNUSED 0x0416 87 void (*CentralLinkKey)(); // 0x0417, 88 void (*RemoteNameRequest)(const RawAddress& bd_addr, 89 uint8_t page_scan_rep_mode, uint8_t page_scan_mode, 90 uint16_t clock_offset); 91 void (*RemoteNameRequestCancel)(const RawAddress& bd_addr); 92 void (*ReadRemoteSupportedFeatures)(uint16_t handle); 93 void (*ReadRemoteExtendedFeatures)(uint16_t handle, uint8_t page_num); 94 void (*ReadRemoteVersionInformation)(uint16_t handle); 95 void (*ReadClockOffset)(uint16_t handle); 96 void (*ReadLmpHandle)(uint16_t handle); 97 void (*SetupSynchronousConnection)(uint16_t handle, 98 uint32_t transmit_bandwidth, 99 uint32_t receive_bandwidth, 100 uint16_t max_latency, uint16_t voice, 101 uint8_t retrans_effort, 102 uint16_t packet_types); 103 void (*AcceptSynchronousConnection)( 104 const RawAddress& bd_addr, uint32_t transmit_bandwidth, 105 uint32_t receive_bandwidth, uint16_t max_latency, uint16_t content_fmt, 106 uint8_t retrans_effort, uint16_t packet_types); 107 void (*RejectSynchronousConnection)(const RawAddress& bd_addr, 108 uint8_t reason); 109 void (*IoCapabilityRequestReply)(const RawAddress& bd_addr, 110 uint8_t capability, uint8_t oob_present, 111 uint8_t auth_req); 112 void (*UserConfirmationRequestReply)(const RawAddress& bd_addr, bool is_yes); 113 void (*UserConfirmationRequestNegativeReply)(const RawAddress& bd_addr, 114 bool is_yes); 115 void (*UserPasskeyRequestReply)(const RawAddress& bd_addr, uint32_t value); 116 void (*UserPasskeyRequestNegativeReply)(const RawAddress& bd_addr); 117 void (*RemoteOobDataRequestReply)(const RawAddress& bd_addr, const Octet16& c, 118 const Octet16& r); 119 void (*RemoteOobDataRequestNegativeReply)(const RawAddress& bd_addr); 120 void (*IoCapabilityRequestNegativeReply)(const RawAddress& bd_addr, 121 uint8_t err_code); 122 void (*EnhancedSetupSynchronousConnection)(uint16_t conn_handle, 123 enh_esco_params_t* p_params); 124 void (*EnhancedAcceptSynchronousConnection)(const RawAddress& bd_addr, 125 enh_esco_params_t* p_params); 126 void (*RemoteOobExtendedDataRequestReply)(); 127 128 // LINK_POLICY 0x08xx 129 void (*HoldMode)(uint16_t handle, uint16_t max_hold_period, 130 uint16_t min_hold_period); 131 void (*SniffMode)(uint16_t handle, uint16_t max_sniff_period, 132 uint16_t min_sniff_period, uint16_t sniff_attempt, 133 uint16_t sniff_timeout); 134 void (*ExitSniffMode)(uint16_t handle); 135 void (*QosSetup)(uint16_t handle, uint8_t flags, uint8_t service_type, 136 uint32_t token_rate, uint32_t peak, uint32_t latency, 137 uint32_t delay_var); 138 // UNUSED 0x0808 139 void (*RoleDiscovery)(); 140 void (*StartRoleSwitch)(const RawAddress& bd_addr, uint8_t role); 141 void (*ReadLinkPolicySettings)(); 142 void (*WriteLinkPolicySettings)(uint16_t handle, uint16_t settings); 143 void (*ReadDefaultLinkPolicySettings)(); 144 void (*WriteDefaultLinkPolicySettings)(uint16_t settings); 145 void (*FlowSpecification)(); 146 void (*SniffSubrating)(uint16_t handle, uint16_t max_lat, 147 uint16_t min_remote_lat, uint16_t min_local_lat); 148 149 // CONTROLLER_AND_BASEBAND 0x0Cxx 150 void (*SetEventMask)(); 151 void (*Reset)(); 152 void (*SetEventFilter)(uint8_t filt_type, uint8_t filt_cond_type, 153 uint8_t* filt_cond, uint8_t filt_cond_len); 154 void (*Flush)(); 155 void (*ReadPinType)(); 156 void (*WritePinType)(uint8_t type); 157 void (*CreateNewUnitKey)(); 158 void (*ReadStoredLinkKey)(); 159 void (*WriteStoredLinkKey)(); 160 void (*DeleteStoredLinkKey)(const RawAddress& bd_addr, bool delete_all_flag); 161 void (*WriteLocalName)(BD_NAME name); 162 void (*ReadLocalName)(); 163 void (*ReadConnectionAcceptTimeout)(); 164 void (*WriteConnectionAcceptTimeout)(uint16_t timeout); 165 void (*ReadPageTimeout)(); 166 void (*WritePageTimeout)(); 167 void (*ReadScanEnable)(); 168 void (*WriteScanEnable)(uint8_t flag); 169 void (*ReadPageScanActivity)(); 170 void (*WritePageScanActivity)(uint16_t interval, uint16_t window); 171 void (*ReadInquiryScanActivity)(); 172 void (*WriteInquiryScanActivity)(uint16_t interval, uint16_t window); 173 void (*ReadAuthenticationEnable)(); 174 void (*WriteAuthenticationEnable)(uint8_t flag); 175 void (*ReadClassOfDevice)(); 176 void (*WriteClassOfDevice)(DEV_CLASS dev_class); 177 void (*ReadVoiceSetting)(); 178 void (*WriteVoiceSetting)(uint16_t flags); 179 void (*ReadAutomaticFlushTimeout)(uint16_t handle); 180 void (*WriteAutomaticFlushTimeout)(uint16_t handle, uint16_t tout); 181 void (*ReadNumBroadcastRetransmits)(); 182 void (*WriteNumBroadcastRetransmits)(); 183 void (*ReadHoldModeActivity)(); 184 void (*WriteHoldModeActivity)(); 185 void (*ReadTransmitPowerLevel)(uint16_t handle, uint8_t type); 186 void (*ReadSynchronousFlowControlEnable)(); 187 void (*WriteSynchronousFlowControlEnable)(); 188 void (*SetControllerToHostFlowControl)(); 189 void (*HostBufferSize)(); 190 void (*HostNumCompletedPackets)(); 191 void (*ReadLinkSupervisionTimeout)(uint8_t local_controller_id, 192 uint16_t handle, uint16_t timeout); 193 void (*WriteLinkSupervisionTimeout)(); 194 void (*ReadNumberOfSupportedIac)(); 195 void (*ReadCurrentIacLap)(); 196 void (*WriteCurrentIacLap)(uint8_t num_cur_iac, LAP* const iac_lap); 197 void (*SetAfhHostChannelClassification)(); 198 void (*ReadInquiryScanType)(); 199 void (*WriteInquiryScanType)(uint8_t type); 200 void (*ReadInquiryMode)(); // 0x0C44, 201 void (*WriteInquiryMode)(uint8_t mode); 202 void (*ReadPageScanType)(); // 0x0C46, 203 void (*WritePageScanType)(uint8_t type); 204 void (*ReadAfhChannelAssessmentMode)(); 205 void (*WriteAfhChannelAssessmentMode)(); 206 void (*ReadExtendedInquiryResponse)(); 207 void (*WriteExtendedInquiryResponse)(void* buffer, uint8_t fec_req); 208 void (*RefreshEncryptionKey)(); 209 void (*ReadSimplePairingMode)(); 210 void (*WriteSimplePairingMode)(); 211 void (*ReadLocalOobData)(); 212 void (*ReadInquiryResponseTransmitPowerLevel)(); 213 void (*WriteInquiryTransmitPowerLevel)(); 214 void (*EnhancedFlush)(uint16_t handle, uint8_t packet_type); 215 void (*SendKeypressNotification)(const RawAddress& bd_addr, uint8_t notif); 216 217 // STATUS_PARAMETER 0x14xxS 218 void (*ReadFailedContactCounter)(uint16_t handle); 219 void (*ResetFailedContactCounter)(); 220 void (*ReadLinkQuality)(uint16_t handle); 221 // UNUSED 0x1404 222 void (*ReadRssi)(uint16_t handle); 223 void (*ReadAfhChannelMap)(); 224 void (*ReadClock)(); 225 void (*ReadEncryptionKeySize)(); 226 }; 227 228 const Interface& GetInterface(); 229 } // namespace hci 230 } // namespace legacy 231 } // namespace bluetooth 232 233 /* Disconnect */ 234 235 /* Add SCO Connection */ 236 extern void btsnd_hcic_add_SCO_conn(uint16_t handle, uint16_t packet_types); 237 238 /* Add SCO Connection */ 239 240 /* Create Connection Cancel */ 241 extern void btsnd_hcic_create_conn_cancel(const RawAddress& dest); 242 243 /* Create Connection Cancel */ 244 245 /* Accept Connection Request */ 246 extern void btsnd_hcic_accept_conn(const RawAddress& bd_addr, uint8_t role); 247 248 /* Accept Connection Request */ 249 250 /* Reject Connection Request */ 251 extern void btsnd_hcic_reject_conn(const RawAddress& bd_addr, uint8_t reason); 252 253 /* Reject Connection Request */ 254 255 /* Link Key Request Reply */ 256 extern void btsnd_hcic_link_key_req_reply(const RawAddress& bd_addr, 257 const LinkKey& link_key); 258 259 /* Link Key Request Reply */ 260 261 /* Link Key Request Neg Reply */ 262 extern void btsnd_hcic_link_key_neg_reply(const RawAddress& bd_addr); 263 264 /* Link Key Request Neg Reply */ 265 266 /* PIN Code Request Reply */ 267 extern void btsnd_hcic_pin_code_req_reply(const RawAddress& bd_addr, 268 uint8_t pin_code_len, 269 PIN_CODE pin_code); 270 271 /* PIN Code Request Reply */ 272 273 /* Link Key Request Neg Reply */ 274 extern void btsnd_hcic_pin_code_neg_reply(const RawAddress& bd_addr); 275 276 /* Link Key Request Neg Reply */ 277 278 /* Change Connection Type */ 279 extern void btsnd_hcic_change_conn_type(uint16_t handle, uint16_t packet_types); 280 281 /* Change Connection Type */ 282 283 extern void btsnd_hcic_auth_request( 284 uint16_t handle); /* Authentication Request */ 285 286 /* Set Connection Encryption */ 287 extern void btsnd_hcic_set_conn_encrypt(uint16_t handle, bool enable); 288 /* Set Connection Encryption */ 289 290 /* Remote Name Request */ 291 extern void btsnd_hcic_rmt_name_req(const RawAddress& bd_addr, 292 uint8_t page_scan_rep_mode, 293 uint8_t page_scan_mode, 294 uint16_t clock_offset); 295 /* Remote Name Request */ 296 297 /* Remote Name Request Cancel */ 298 extern void btsnd_hcic_rmt_name_req_cancel(const RawAddress& bd_addr); 299 /* Remote Name Request Cancel */ 300 301 extern void btsnd_hcic_rmt_features_req( 302 uint16_t handle); /* Remote Features Request */ 303 304 /* Remote Extended Features */ 305 extern void btsnd_hcic_rmt_ext_features(uint16_t handle, uint8_t page_num); 306 /* Remote Extended Features */ 307 308 extern void btsnd_hcic_rmt_ver_req( 309 uint16_t handle); /* Remote Version Info Request */ 310 extern void btsnd_hcic_read_rmt_clk_offset( 311 uint16_t handle); /* Remote Clock Offset */ 312 extern void btsnd_hcic_read_lmp_handle(uint16_t handle); /* Remote LMP Handle */ 313 extern void btsnd_hcic_setup_esco_conn(uint16_t handle, 314 uint32_t transmit_bandwidth, 315 uint32_t receive_bandwidth, 316 uint16_t max_latency, uint16_t voice, 317 uint8_t retrans_effort, 318 uint16_t packet_types); 319 extern void btsnd_hcic_accept_esco_conn( 320 const RawAddress& bd_addr, uint32_t transmit_bandwidth, 321 uint32_t receive_bandwidth, uint16_t max_latency, uint16_t content_fmt, 322 uint8_t retrans_effort, uint16_t packet_types); 323 324 extern void btsnd_hcic_reject_esco_conn(const RawAddress& bd_addr, 325 uint8_t reason); 326 /* Hold Mode */ 327 extern void btsnd_hcic_hold_mode(uint16_t handle, uint16_t max_hold_period, 328 uint16_t min_hold_period); 329 330 /* Hold Mode */ 331 332 /* Sniff Mode */ 333 extern void btsnd_hcic_sniff_mode(uint16_t handle, uint16_t max_sniff_period, 334 uint16_t min_sniff_period, 335 uint16_t sniff_attempt, 336 uint16_t sniff_timeout); 337 /* Sniff Mode */ 338 339 extern void btsnd_hcic_exit_sniff_mode(uint16_t handle); /* Exit Sniff Mode */ 340 341 /* Park Mode */ 342 extern void btsnd_hcic_park_mode(uint16_t handle, uint16_t beacon_max_interval, 343 uint16_t beacon_min_interval); 344 /* Park Mode */ 345 346 extern void btsnd_hcic_exit_park_mode(uint16_t handle); /* Exit Park Mode */ 347 348 /* QoS Setup */ 349 extern void btsnd_hcic_qos_setup(uint16_t handle, uint8_t flags, 350 uint8_t service_type, uint32_t token_rate, 351 uint32_t peak, uint32_t latency, 352 uint32_t delay_var); 353 /* QoS Setup */ 354 355 /* Switch Role Request */ 356 357 /* Write Policy Settings */ 358 extern void btsnd_hcic_write_policy_set(uint16_t handle, uint16_t settings); 359 /* Write Policy Settings */ 360 361 /* Write Default Policy Settings */ 362 extern void btsnd_hcic_write_def_policy_set(uint16_t settings); 363 /* Write Default Policy Settings */ 364 365 /****************************************** 366 * Lisbon Features 367 ******************************************/ 368 /* Sniff Subrating */ 369 extern void btsnd_hcic_sniff_sub_rate(uint16_t handle, uint16_t max_lat, 370 uint16_t min_remote_lat, 371 uint16_t min_local_lat); 372 /* Sniff Subrating */ 373 374 /* Extended Inquiry Response */ 375 extern void btsnd_hcic_write_ext_inquiry_response(void* buffer, 376 uint8_t fec_req); 377 /* IO Capabilities Response */ 378 extern void btsnd_hcic_io_cap_req_reply(const RawAddress& bd_addr, 379 uint8_t capability, uint8_t oob_present, 380 uint8_t auth_req); 381 /* IO Capabilities Req Neg Reply */ 382 extern void btsnd_hcic_io_cap_req_neg_reply(const RawAddress& bd_addr, 383 uint8_t err_code); 384 /* Read Local OOB Data */ 385 extern void btsnd_hcic_read_local_oob_data(void); 386 387 extern void btsnd_hcic_user_conf_reply(const RawAddress& bd_addr, bool is_yes); 388 389 extern void btsnd_hcic_user_passkey_reply(const RawAddress& bd_addr, 390 uint32_t value); 391 392 extern void btsnd_hcic_user_passkey_neg_reply(const RawAddress& bd_addr); 393 394 /* Remote OOB Data Request Reply */ 395 extern void btsnd_hcic_rem_oob_reply(const RawAddress& bd_addr, 396 const Octet16& c, const Octet16& r); 397 398 /* Remote OOB Data Request Negative Reply */ 399 extern void btsnd_hcic_rem_oob_neg_reply(const RawAddress& bd_addr); 400 401 /* Read Tx Power Level */ 402 extern void btsnd_hcic_read_inq_tx_power(void); 403 404 /* Read Default Erroneous Data Reporting */ 405 extern void btsnd_hcic_read_default_erroneous_data_rpt(void); 406 407 extern void btsnd_hcic_enhanced_flush(uint16_t handle, uint8_t packet_type); 408 409 extern void btsnd_hcic_send_keypress_notif(const RawAddress& bd_addr, 410 uint8_t notif); 411 /**** end of Simple Pairing Commands ****/ 412 413 extern void btsnd_hcic_set_event_filter(uint8_t filt_type, 414 uint8_t filt_cond_type, 415 uint8_t* filt_cond, 416 uint8_t filt_cond_len); 417 /* Set Event Filter */ 418 419 /* Delete Stored Key */ 420 extern void btsnd_hcic_delete_stored_key(const RawAddress& bd_addr, 421 bool delete_all_flag); 422 /* Delete Stored Key */ 423 424 /* Change Local Name */ 425 extern void btsnd_hcic_change_name(BD_NAME name); 426 427 #define HCIC_PARAM_SIZE_READ_CMD 0 428 429 #define HCIC_PARAM_SIZE_WRITE_PARAM1 1 430 431 #define HCIC_PARAM_SIZE_WRITE_PARAM3 3 432 433 extern void btsnd_hcic_write_pin_type(uint8_t type); /* Write PIN Type */ 434 extern void btsnd_hcic_write_auto_accept(uint8_t flag); /* Write Auto Accept */ 435 extern void btsnd_hcic_read_name(void); /* Read Local Name */ 436 extern void btsnd_hcic_write_page_tout( 437 uint16_t timeout); /* Write Page Timout */ 438 extern void btsnd_hcic_write_scan_enable(uint8_t flag); /* Write Scan Enable */ 439 extern void btsnd_hcic_write_pagescan_cfg( 440 uint16_t interval, uint16_t window); /* Write Page Scan Activity */ 441 /* Write Page Scan Activity */ 442 443 /* Write Inquiry Scan Activity */ 444 extern void btsnd_hcic_write_inqscan_cfg(uint16_t interval, uint16_t window); 445 /* Write Inquiry Scan Activity */ 446 447 extern void btsnd_hcic_write_auth_enable( 448 uint8_t flag); /* Write Authentication Enable */ 449 extern void btsnd_hcic_write_dev_class( 450 DEV_CLASS dev); /* Write Class of Device */ 451 extern void btsnd_hcic_write_voice_settings( 452 uint16_t flags); /* Write Voice Settings */ 453 454 extern void btsnd_hcic_write_auto_flush_tout( 455 uint16_t handle, uint16_t timeout); /* Write Retransmit Timout */ 456 457 extern void btsnd_hcic_read_tx_power(uint16_t handle, 458 uint8_t type); /* Read Tx Power */ 459 460 /* Read transmit power level parameter */ 461 extern void btsnd_hcic_host_num_xmitted_pkts( 462 uint8_t num_handles, uint16_t* handle, 463 uint16_t* num_pkts); /* Set Host Buffer Size */ 464 465 /* Write Link Supervision Timeout */ 466 extern void btsnd_hcic_write_link_super_tout(uint8_t local_controller_id, 467 uint16_t handle, uint16_t timeout); 468 /* Write Link Supervision Timeout */ 469 470 extern void btsnd_hcic_write_cur_iac_lap( 471 uint8_t num_cur_iac, LAP* const iac_lap); /* Write Current IAC LAP */ 472 /* Write Current IAC LAP */ 473 474 extern void btsnd_hcic_get_link_quality(uint16_t handle); /* Get Link Quality */ 475 extern void btsnd_hcic_read_rssi(uint16_t handle); /* Read RSSI */ 476 using ReadEncKeySizeCb = base::OnceCallback<void(uint8_t, uint16_t, uint8_t)>; 477 extern void btsnd_hcic_read_encryption_key_size(uint16_t handle, ReadEncKeySizeCb cb); 478 extern void btsnd_hcic_read_failed_contact_counter(uint16_t handle); 479 extern void btsnd_hcic_read_automatic_flush_timeout(uint16_t handle); 480 extern void btsnd_hcic_enable_test_mode( 481 void); /* Enable Device Under Test Mode */ 482 extern void btsnd_hcic_write_pagescan_type( 483 uint8_t type); /* Write Page Scan Type */ 484 extern void btsnd_hcic_write_inqscan_type( 485 uint8_t type); /* Write Inquiry Scan Type */ 486 extern void btsnd_hcic_write_inquiry_mode( 487 uint8_t type); /* Write Inquiry Mode */ 488 489 /* Enhanced setup SCO connection (CSA2) */ 490 extern void btsnd_hcic_enhanced_set_up_synchronous_connection( 491 uint16_t conn_handle, enh_esco_params_t* p_parms); 492 493 /* Enhanced accept SCO connection request (CSA2) */ 494 extern void btsnd_hcic_enhanced_accept_synchronous_connection( 495 const RawAddress& bd_addr, enh_esco_params_t* p_parms); 496 497 #define HCI_DATA_HANDLE_MASK 0x0FFF 498 499 #define HCID_GET_HANDLE_EVENT(p) \ 500 (uint16_t)((*((uint8_t*)((p) + 1) + (p)->offset) + \ 501 (*((uint8_t*)((p) + 1) + (p)->offset + 1) << 8))) 502 503 #define HCID_GET_HANDLE(u16) (uint16_t)((u16)&HCI_DATA_HANDLE_MASK) 504 505 #define HCI_DATA_EVENT_MASK 3 506 #define HCI_DATA_EVENT_OFFSET 12 507 #define HCID_GET_EVENT(u16) \ 508 (uint8_t)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK) 509 510 extern void btsnd_hcic_vendor_spec_cmd(void* buffer, uint16_t opcode, 511 uint8_t len, uint8_t* p_data, 512 void* p_cmd_cplt_cback); 513 514 /******************************************************************************* 515 * BLE Commands 516 * Note: "local_controller_id" is for transport, not counted in HCI 517 * message size 518 ******************************************************************************/ 519 #define HCIC_BLE_RAND_DI_SIZE 8 520 521 #define HCIC_BLE_CHNL_MAP_SIZE 5 522 #define HCIC_PARAM_SIZE_BLE_READ_PHY 2 523 #define HCIC_PARAM_SIZE_BLE_SET_PHY 7 524 525 /* ULP HCI command */ 526 extern void btsnd_hcic_ble_set_evt_mask(BT_EVENT_MASK event_mask); 527 528 extern void btsnd_hcic_ble_read_buffer_size(void); 529 530 extern void btsnd_hcic_ble_read_local_spt_feat(void); 531 532 extern void btsnd_hcic_ble_set_local_used_feat(uint8_t feat_set[8]); 533 534 extern void btsnd_hcic_ble_set_random_addr(const RawAddress& random_addr); 535 536 extern void btsnd_hcic_ble_write_adv_params( 537 uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type, 538 uint8_t addr_type_own, uint8_t addr_type_dir, const RawAddress& direct_bda, 539 uint8_t channel_map, uint8_t adv_filter_policy); 540 541 extern void btsnd_hcic_ble_read_adv_chnl_tx_power(void); 542 543 extern void btsnd_hcic_ble_set_adv_data(uint8_t data_len, uint8_t* p_data); 544 545 extern void btsnd_hcic_ble_set_scan_rsp_data(uint8_t data_len, 546 uint8_t* p_scan_rsp); 547 548 extern void btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable); 549 550 extern void btsnd_hcic_ble_set_scan_params(uint8_t scan_type, uint16_t scan_int, 551 uint16_t scan_win, uint8_t addr_type, 552 uint8_t scan_filter_policy); 553 554 extern void btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable, 555 uint8_t duplicate); 556 557 extern void btsnd_hcic_ble_create_ll_conn( 558 uint16_t scan_int, uint16_t scan_win, uint8_t init_filter_policy, 559 uint8_t addr_type_peer, const RawAddress& bda_peer, uint8_t addr_type_own, 560 uint16_t conn_int_min, uint16_t conn_int_max, uint16_t conn_latency, 561 uint16_t conn_timeout, uint16_t min_ce_len, uint16_t max_ce_len); 562 563 extern void btsnd_hcic_ble_create_conn_cancel(void); 564 565 extern void btsnd_hcic_ble_read_acceptlist_size(void); 566 567 extern void btsnd_hcic_ble_clear_acceptlist( 568 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 569 570 extern void btsnd_hcic_ble_add_acceptlist( 571 uint8_t addr_type, const RawAddress& bda, 572 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 573 574 extern void btsnd_hcic_ble_remove_from_acceptlist( 575 uint8_t addr_type, const RawAddress& bda, 576 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 577 578 extern void btsnd_hcic_ble_upd_ll_conn_params( 579 uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max, 580 uint16_t conn_latency, uint16_t conn_timeout, uint16_t min_len, 581 uint16_t max_len); 582 583 extern void btsnd_hcic_ble_set_host_chnl_class( 584 uint8_t chnl_map[HCIC_BLE_CHNL_MAP_SIZE]); 585 586 extern void btsnd_hcic_ble_read_chnl_map(uint16_t handle); 587 588 extern void btsnd_hcic_ble_read_remote_feat(uint16_t handle); 589 590 extern void btsnd_hcic_ble_encrypt(uint8_t* key, uint8_t key_len, 591 uint8_t* plain_text, uint8_t pt_len, 592 void* p_cmd_cplt_cback); 593 594 extern void btsnd_hcic_ble_rand(base::Callback<void(BT_OCTET8)> cb); 595 596 extern void btsnd_hcic_ble_start_enc(uint16_t handle, 597 uint8_t rand[HCIC_BLE_RAND_DI_SIZE], 598 uint16_t ediv, const Octet16& ltk); 599 600 extern void btsnd_hcic_ble_ltk_req_reply(uint16_t handle, const Octet16& ltk); 601 602 extern void btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle); 603 604 extern void btsnd_hcic_ble_read_supported_states(void); 605 606 extern void btsnd_hcic_ble_write_host_supported(uint8_t le_host_spt, 607 uint8_t simul_le_host_spt); 608 609 extern void btsnd_hcic_ble_read_host_supported(void); 610 611 extern void btsnd_hcic_ble_receiver_test(uint8_t rx_freq); 612 613 extern void btsnd_hcic_ble_transmitter_test(uint8_t tx_freq, 614 uint8_t test_data_len, 615 uint8_t payload); 616 extern void btsnd_hcic_ble_test_end(void); 617 618 extern void btsnd_hcic_ble_rc_param_req_reply( 619 uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max, 620 uint16_t conn_latency, uint16_t conn_timeout, uint16_t min_ce_len, 621 uint16_t max_ce_len); 622 623 extern void btsnd_hcic_ble_rc_param_req_neg_reply(uint16_t handle, 624 uint8_t reason); 625 626 extern void btsnd_hcic_ble_set_data_length(uint16_t conn_handle, 627 uint16_t tx_octets, 628 uint16_t tx_time); 629 630 extern void btsnd_hcic_ble_add_device_resolving_list(uint8_t addr_type_peer, 631 const RawAddress& bda_peer, 632 const Octet16& irk_peer, 633 const Octet16& irk_local); 634 635 struct scanning_phy_cfg { 636 uint8_t scan_type; 637 uint16_t scan_int; 638 uint16_t scan_win; 639 }; 640 641 extern void btsnd_hcic_ble_set_extended_scan_params( 642 uint8_t own_address_type, uint8_t scanning_filter_policy, 643 uint8_t scanning_phys, scanning_phy_cfg* phy_cfg); 644 645 extern void btsnd_hcic_ble_set_extended_scan_enable(uint8_t enable, 646 uint8_t filter_duplicates, 647 uint16_t duration, 648 uint16_t period); 649 650 struct EXT_CONN_PHY_CFG { 651 uint16_t scan_int; 652 uint16_t scan_win; 653 uint16_t conn_int_min; 654 uint16_t conn_int_max; 655 uint16_t conn_latency; 656 uint16_t sup_timeout; 657 uint16_t min_ce_len; 658 uint16_t max_ce_len; 659 }; 660 661 extern void btsnd_hcic_ble_ext_create_conn(uint8_t init_filter_policy, 662 uint8_t addr_type_own, 663 uint8_t addr_type_peer, 664 const RawAddress& bda_peer, 665 uint8_t initiating_phys, 666 EXT_CONN_PHY_CFG* phy_cfg); 667 668 extern void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer, 669 const RawAddress& bda_peer); 670 671 extern void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer, 672 const RawAddress& bda_peer, 673 uint8_t privacy_type); 674 675 extern void btsnd_hcic_ble_clear_resolving_list(void); 676 677 extern void btsnd_hcic_ble_read_resolvable_addr_peer( 678 uint8_t addr_type_peer, const RawAddress& bda_peer); 679 680 extern void btsnd_hcic_ble_read_resolvable_addr_local( 681 uint8_t addr_type_peer, const RawAddress& bda_peer); 682 683 extern void btsnd_hcic_ble_set_addr_resolution_enable( 684 uint8_t addr_resolution_enable); 685 686 extern void btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout); 687 688 extern void btsnd_hcic_read_authenticated_payload_tout(uint16_t handle); 689 690 extern void btsnd_hcic_write_authenticated_payload_tout(uint16_t handle, 691 uint16_t timeout); 692 693 extern void btsnd_hcic_read_iso_tx_sync( 694 uint16_t iso_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 695 696 struct EXT_CIS_CFG { 697 uint8_t cis_id; 698 uint16_t max_sdu_size_mtos; 699 uint16_t max_sdu_size_stom; 700 uint8_t phy_mtos; 701 uint8_t phy_stom; 702 uint8_t rtn_mtos; 703 uint8_t rtn_stom; 704 }; 705 706 extern void btsnd_hcic_set_cig_params( 707 uint8_t cig_id, uint32_t sdu_itv_mtos, uint32_t sdu_itv_stom, uint8_t sca, 708 uint8_t packing, uint8_t framing, uint16_t max_trans_lat_stom, 709 uint16_t max_trans_lat_mtos, uint8_t cis_cnt, const EXT_CIS_CFG* cis_cfg, 710 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 711 712 struct EXT_CIS_TEST_CFG { 713 uint8_t cis_id; 714 uint8_t nse; 715 uint16_t max_sdu_size_mtos; 716 uint16_t max_sdu_size_stom; 717 uint8_t max_pdu_mtos; 718 uint8_t max_pdu_stom; 719 uint8_t phy_mtos; 720 uint8_t phy_stom; 721 uint8_t bn_mtos; 722 uint8_t bn_stom; 723 }; 724 725 struct EXT_CIS_CREATE_CFG { 726 uint16_t cis_conn_handle; 727 uint16_t acl_conn_handle; 728 }; 729 730 extern void btsnd_hcic_create_cis( 731 uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_create_cfg, 732 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 733 734 extern void btsnd_hcic_remove_cig( 735 uint8_t cig_id, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 736 737 extern void btsnd_hcic_accept_cis_req(uint16_t conn_handle); 738 739 extern void btsnd_hcic_rej_cis_req( 740 uint16_t conn_handle, uint8_t reason, 741 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 742 743 extern void btsnd_hcic_req_peer_sca(uint16_t conn_handle); 744 745 extern void btsnd_hcic_create_big(uint8_t big_handle, uint8_t adv_handle, 746 uint8_t num_bis, uint32_t sdu_itv, 747 uint16_t max_sdu_size, uint16_t max_trans_lat, 748 uint8_t rtn, uint8_t phy, uint8_t packing, 749 uint8_t framing, uint8_t enc, 750 std::array<uint8_t, 16> bcst_code); 751 752 extern void btsnd_hcic_term_big(uint8_t big_handle, uint8_t reason); 753 754 extern void btsnd_hcic_big_create_sync(uint8_t big_handle, uint16_t sync_handle, 755 uint8_t enc, 756 std::array<uint8_t, 16> bcst_code, 757 uint8_t mse, uint16_t big_sync_timeout, 758 std::vector<uint8_t> bis); 759 760 extern void btsnd_hcic_big_term_sync( 761 uint8_t big_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 762 763 extern void btsnd_hcic_setup_iso_data_path( 764 uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id, 765 uint8_t codec_id_format, uint16_t codec_id_company, 766 uint16_t codec_id_vendor, uint32_t controller_delay, 767 std::vector<uint8_t> codec_conf, 768 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 769 770 extern void btsnd_hcic_remove_iso_data_path( 771 uint16_t iso_handle, uint8_t data_path_dir, 772 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 773 774 extern void btsnd_hcic_read_iso_link_quality( 775 uint16_t iso_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 776 777 extern void btsnd_hcic_ble_periodic_advertising_create_sync( 778 uint8_t options, uint8_t adv_sid, uint8_t adv_addr_type, 779 const RawAddress& adv_addr, uint16_t skip_num, uint16_t sync_timeout, 780 uint8_t sync_cte_type); 781 782 extern void btsnd_hcic_ble_periodic_advertising_create_sync_cancel( 783 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 784 785 extern void btsnd_hcic_ble_periodic_advertising_terminate_sync( 786 uint16_t sync_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 787 788 extern void btsnd_hci_ble_add_device_to_periodic_advertiser_list( 789 uint8_t adv_addr_type, const RawAddress& adv_addr, uint8_t adv_sid, 790 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 791 792 extern void btsnd_hci_ble_remove_device_from_periodic_advertiser_list( 793 uint8_t adv_addr_type, const RawAddress& adv_addr, uint8_t adv_sid, 794 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 795 796 extern void btsnd_hci_ble_clear_periodic_advertiser_list( 797 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 798 799 extern void btsnd_hci_ble_read_periodic_advertiser_list_size( 800 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 801 802 extern void btsnd_hcic_ble_set_periodic_advertising_receive_enable( 803 uint16_t sync_handle, bool enable, 804 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 805 806 extern void btsnd_hcic_ble_periodic_advertising_sync_transfer( 807 uint16_t conn_handle, uint16_t service_data, uint16_t sync_handle, 808 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 809 810 extern void btsnd_hcic_ble_periodic_advertising_set_info_transfer( 811 uint16_t conn_handle, uint16_t service_data, uint8_t adv_handle, 812 base::OnceCallback<void(uint8_t*, uint16_t)> cb); 813 814 extern void btsnd_hcic_ble_set_periodic_advertising_sync_transfer_params( 815 uint16_t conn_handle, uint8_t mode, uint16_t skip, uint16_t sync_timeout, 816 uint8_t cte_type, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 817 818 extern void 819 btsnd_hcic_ble_set_default_periodic_advertising_sync_transfer_params( 820 uint16_t conn_handle, uint8_t mode, uint16_t skip, uint16_t sync_timeout, 821 uint8_t cte_type, base::OnceCallback<void(uint8_t*, uint16_t)> cb); 822 823 #define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4 824 825 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0 826 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2 827 828 #endif 829