1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 #define BTSTACK_FILE__ "hci_cmd.c" 39 40 /* 41 * hci_cmd.c 42 * 43 * Created by Matthias Ringwald on 7/23/09. 44 */ 45 46 #include "btstack_config.h" 47 48 #include "classic/sdp_util.h" 49 #include "hci.h" 50 #include "hci_cmd.h" 51 #include "btstack_debug.h" 52 53 #include <string.h> 54 55 // calculate combined ogf/ocf value 56 #define OPCODE(ogf, ocf) ((ocf) | ((ogf) << 10)) 57 58 /** 59 * construct HCI Command based on template 60 * 61 * Format: 62 * 1,2,3,4: one to four byte value 63 * H: HCI connection handle 64 * B: Bluetooth Baseband Address (BD_ADDR) 65 * D: 8 byte data block 66 * E: Extended Inquiry Result 67 * N: Name up to 248 chars, \0 terminated 68 * P: 16 byte data block. Pairing code, Simple Pairing Hash and Randomizer 69 * A: 31 bytes advertising data 70 * S: Service Record (Data Element Sequence) 71 * Q: 32 byte data block, e.g. for X and Y coordinates of P-256 public key 72 */ 73 uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr){ 74 75 hci_cmd_buffer[0] = cmd->opcode & 0xffu; 76 hci_cmd_buffer[1] = cmd->opcode >> 8; 77 int pos = 3; 78 79 const char *format = cmd->format; 80 uint16_t word; 81 uint32_t longword; 82 uint8_t * ptr; 83 while (*format) { 84 switch(*format) { 85 case '1': // 8 bit value 86 case '2': // 16 bit value 87 case 'H': // hci_handle 88 word = va_arg(argptr, int); // minimal va_arg is int: 2 bytes on 8+16 bit CPUs 89 hci_cmd_buffer[pos++] = word & 0xffu; 90 if (*format == '2') { 91 hci_cmd_buffer[pos++] = word >> 8; 92 } else if (*format == 'H') { 93 // TODO implement opaque client connection handles 94 // pass module handle for now 95 hci_cmd_buffer[pos++] = word >> 8; 96 } 97 break; 98 case '3': 99 case '4': 100 longword = va_arg(argptr, uint32_t); 101 // longword = va_arg(argptr, int); 102 hci_cmd_buffer[pos++] = longword; 103 hci_cmd_buffer[pos++] = longword >> 8; 104 hci_cmd_buffer[pos++] = longword >> 16; 105 if (*format == '4'){ 106 hci_cmd_buffer[pos++] = longword >> 24; 107 } 108 break; 109 case 'B': // bt-addr 110 ptr = va_arg(argptr, uint8_t *); 111 hci_cmd_buffer[pos++] = ptr[5]; 112 hci_cmd_buffer[pos++] = ptr[4]; 113 hci_cmd_buffer[pos++] = ptr[3]; 114 hci_cmd_buffer[pos++] = ptr[2]; 115 hci_cmd_buffer[pos++] = ptr[1]; 116 hci_cmd_buffer[pos++] = ptr[0]; 117 break; 118 case 'D': // 8 byte data block 119 ptr = va_arg(argptr, uint8_t *); 120 (void)memcpy(&hci_cmd_buffer[pos], ptr, 8); 121 pos += 8; 122 break; 123 case 'E': // Extended Inquiry Information 240 octets 124 ptr = va_arg(argptr, uint8_t *); 125 (void)memcpy(&hci_cmd_buffer[pos], ptr, 240); 126 pos += 240; 127 break; 128 case 'N': { // UTF-8 string, null terminated 129 ptr = va_arg(argptr, uint8_t *); 130 uint16_t len = strlen((const char*) ptr); 131 if (len > 248u) { 132 len = 248; 133 } 134 (void)memcpy(&hci_cmd_buffer[pos], ptr, len); 135 if (len < 248u) { 136 // fill remaining space with zeroes 137 memset(&hci_cmd_buffer[pos+len], 0u, 248u-len); 138 } 139 pos += 248; 140 break; 141 } 142 case 'P': // 16 byte PIN code or link key in little endian 143 ptr = va_arg(argptr, uint8_t *); 144 (void)memcpy(&hci_cmd_buffer[pos], ptr, 16); 145 pos += 16; 146 break; 147 #ifdef ENABLE_BLE 148 case 'A': // 31 bytes advertising data 149 ptr = va_arg(argptr, uint8_t *); 150 (void)memcpy(&hci_cmd_buffer[pos], ptr, 31); 151 pos += 31; 152 break; 153 #endif 154 #ifdef ENABLE_SDP 155 case 'S': { // Service Record (Data Element Sequence) 156 ptr = va_arg(argptr, uint8_t *); 157 uint16_t len = de_get_len(ptr); 158 (void)memcpy(&hci_cmd_buffer[pos], ptr, len); 159 pos += len; 160 break; 161 } 162 #endif 163 #ifdef ENABLE_LE_SECURE_CONNECTIONS 164 case 'Q': 165 ptr = va_arg(argptr, uint8_t *); 166 reverse_bytes(ptr, &hci_cmd_buffer[pos], 32); 167 pos += 32; 168 break; 169 #endif 170 case 'K': // 16 byte OOB Data or Link Key in big endian 171 ptr = va_arg(argptr, uint8_t *); 172 reverse_bytes(ptr, &hci_cmd_buffer[pos], 16); 173 pos += 16; 174 break; 175 default: 176 break; 177 } 178 format++; 179 }; 180 hci_cmd_buffer[2] = pos - 3; 181 return pos; 182 } 183 184 /** 185 * Link Control Commands 186 */ 187 188 /** 189 * @param lap 190 * @param inquiry_length 191 * @param num_responses 192 */ 193 const hci_cmd_t hci_inquiry = { 194 HCI_OPCODE_HCI_INQUIRY, "311" 195 }; 196 197 /** 198 */ 199 const hci_cmd_t hci_inquiry_cancel = { 200 HCI_OPCODE_HCI_INQUIRY_CANCEL, "" 201 }; 202 203 /** 204 * @param bd_addr 205 * @param packet_type 206 * @param page_scan_repetition_mode 207 * @param reserved 208 * @param clock_offset 209 * @param allow_role_switch 210 */ 211 const hci_cmd_t hci_create_connection = { 212 HCI_OPCODE_HCI_CREATE_CONNECTION, "B21121" 213 }; 214 215 /** 216 * @param handle 217 * @param reason (0x05, 0x13-0x15, 0x1a, 0x29, see Errors Codes in BT Spec Part D) 218 */ 219 const hci_cmd_t hci_disconnect = { 220 HCI_OPCODE_HCI_DISCONNECT, "H1" 221 }; 222 223 /** 224 * @param bd_addr 225 */ 226 const hci_cmd_t hci_create_connection_cancel = { 227 HCI_OPCODE_HCI_CREATE_CONNECTION_CANCEL, "B" 228 }; 229 230 /** 231 * @param bd_addr 232 * @param role (become master, stay slave) 233 */ 234 const hci_cmd_t hci_accept_connection_request = { 235 HCI_OPCODE_HCI_ACCEPT_CONNECTION_REQUEST, "B1" 236 }; 237 238 /** 239 * @param bd_addr 240 * @param reason (e.g. CONNECTION REJECTED DUE TO LIMITED RESOURCES (0x0d)) 241 */ 242 const hci_cmd_t hci_reject_connection_request = { 243 HCI_OPCODE_HCI_REJECT_CONNECTION_REQUEST, "B1" 244 }; 245 246 /** 247 * @param bd_addr 248 * @param link_key 249 */ 250 const hci_cmd_t hci_link_key_request_reply = { 251 HCI_OPCODE_HCI_LINK_KEY_REQUEST_REPLY, "BP" 252 }; 253 254 /** 255 * @param bd_addr 256 */ 257 const hci_cmd_t hci_link_key_request_negative_reply = { 258 HCI_OPCODE_HCI_LINK_KEY_REQUEST_NEGATIVE_REPLY, "B" 259 }; 260 261 /** 262 * @param bd_addr 263 * @param pin_length 264 * @param pin (c-string) 265 */ 266 const hci_cmd_t hci_pin_code_request_reply = { 267 HCI_OPCODE_HCI_PIN_CODE_REQUEST_REPLY, "B1P" 268 }; 269 270 /** 271 * @param bd_addr 272 */ 273 const hci_cmd_t hci_pin_code_request_negative_reply = { 274 HCI_OPCODE_HCI_PIN_CODE_REQUEST_NEGATIVE_REPLY, "B" 275 }; 276 277 /** 278 * @param handle 279 * @param packet_type 280 */ 281 const hci_cmd_t hci_change_connection_packet_type = { 282 HCI_OPCODE_HCI_CHANGE_CONNECTION_PACKET_TYPE, "H2" 283 }; 284 285 /** 286 * @param handle 287 */ 288 const hci_cmd_t hci_authentication_requested = { 289 HCI_OPCODE_HCI_AUTHENTICATION_REQUESTED, "H" 290 }; 291 292 /** 293 * @param handle 294 * @param encryption_enable 295 */ 296 const hci_cmd_t hci_set_connection_encryption = { 297 HCI_OPCODE_HCI_SET_CONNECTION_ENCRYPTION, "H1" 298 }; 299 300 /** 301 * @param handle 302 */ 303 const hci_cmd_t hci_change_connection_link_key = { 304 HCI_OPCODE_HCI_CHANGE_CONNECTION_LINK_KEY, "H" 305 }; 306 307 /** 308 * @param bd_addr 309 * @param page_scan_repetition_mode 310 * @param reserved 311 * @param clock_offset 312 */ 313 const hci_cmd_t hci_remote_name_request = { 314 HCI_OPCODE_HCI_REMOTE_NAME_REQUEST, "B112" 315 }; 316 317 318 /** 319 * @param bd_addr 320 */ 321 const hci_cmd_t hci_remote_name_request_cancel = { 322 HCI_OPCODE_HCI_REMOTE_NAME_REQUEST_CANCEL, "B" 323 }; 324 325 /** 326 * @param handle 327 */ 328 const hci_cmd_t hci_read_remote_supported_features_command = { 329 HCI_OPCODE_HCI_READ_REMOTE_SUPPORTED_FEATURES_COMMAND, "H" 330 }; 331 332 /** 333 * @param handle 334 */ 335 const hci_cmd_t hci_read_remote_extended_features_command = { 336 HCI_OPCODE_HCI_READ_REMOTE_EXTENDED_FEATURES_COMMAND, "H1" 337 }; 338 339 /** 340 * @param handle 341 */ 342 const hci_cmd_t hci_read_remote_version_information = { 343 HCI_OPCODE_HCI_READ_REMOTE_VERSION_INFORMATION, "H" 344 }; 345 346 /** 347 * @param handle 348 * @param transmit_bandwidth 8000(64kbps) 349 * @param receive_bandwidth 8000(64kbps) 350 * @param max_latency >= 7ms for eSCO, 0xFFFF do not care 351 * @param voice_settings e.g. CVSD, Input Coding: Linear, Input Data Format: 2’s complement, data 16bit: 00011000000 == 0x60 352 * @param retransmission_effort e.g. 0xFF do not care 353 * @param packet_type at least EV3 for eSCO 354 */ 355 const hci_cmd_t hci_setup_synchronous_connection = { 356 HCI_OPCODE_HCI_SETUP_SYNCHRONOUS_CONNECTION, "H442212" 357 }; 358 359 /** 360 * @param bd_addr 361 * @param transmit_bandwidth 362 * @param receive_bandwidth 363 * @param max_latency 364 * @param voice_settings 365 * @param retransmission_effort 366 * @param packet_type 367 */ 368 const hci_cmd_t hci_accept_synchronous_connection = { 369 HCI_OPCODE_HCI_ACCEPT_SYNCHRONOUS_CONNECTION, "B442212" 370 }; 371 372 /** 373 * @param bd_addr 374 * @param IO_capability 375 * @param OOB_data_present 376 * @param authentication_requirements 377 */ 378 const hci_cmd_t hci_io_capability_request_reply = { 379 HCI_OPCODE_HCI_IO_CAPABILITY_REQUEST_REPLY, "B111" 380 }; 381 382 /** 383 * @param bd_addr 384 */ 385 const hci_cmd_t hci_user_confirmation_request_reply = { 386 HCI_OPCODE_HCI_USER_CONFIRMATION_REQUEST_REPLY, "B" 387 }; 388 389 /** 390 * @param bd_addr 391 */ 392 const hci_cmd_t hci_user_confirmation_request_negative_reply = { 393 HCI_OPCODE_HCI_USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY, "B" 394 }; 395 396 /** 397 * @param bd_addr 398 * @param numeric_value 399 */ 400 const hci_cmd_t hci_user_passkey_request_reply = { 401 HCI_OPCODE_HCI_USER_PASSKEY_REQUEST_REPLY, "B4" 402 }; 403 404 /** 405 * @param bd_addr 406 */ 407 const hci_cmd_t hci_user_passkey_request_negative_reply = { 408 HCI_OPCODE_HCI_USER_PASSKEY_REQUEST_NEGATIVE_REPLY, "B" 409 }; 410 411 /** 412 * @param bd_addr 413 * @param c Simple Pairing Hash C 414 * @param r Simple Pairing Randomizer R 415 */ 416 const hci_cmd_t hci_remote_oob_data_request_reply = { 417 HCI_OPCODE_HCI_REMOTE_OOB_DATA_REQUEST_REPLY, "BKK" 418 }; 419 420 /** 421 * @param bd_addr 422 */ 423 const hci_cmd_t hci_remote_oob_data_request_negative_reply = { 424 HCI_OPCODE_HCI_REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY, "B" 425 }; 426 427 /** 428 * @param bd_addr 429 * @param reason (Part D, Error codes) 430 */ 431 const hci_cmd_t hci_io_capability_request_negative_reply = { 432 HCI_OPCODE_HCI_IO_CAPABILITY_REQUEST_NEGATIVE_REPLY, "B1" 433 }; 434 435 /** 436 * @param handle 437 * @param transmit_bandwidth 438 * @param receive_bandwidth 439 * @param transmit_coding_format_type 440 * @param transmit_coding_format_company 441 * @param transmit_coding_format_codec 442 * @param receive_coding_format_type 443 * @param receive_coding_format_company 444 * @param receive_coding_format_codec 445 * @param transmit_coding_frame_size 446 * @param receive_coding_frame_size 447 * @param input_bandwidth 448 * @param output_bandwidth 449 * @param input_coding_format_type 450 * @param input_coding_format_company 451 * @param input_coding_format_codec 452 * @param output_coding_format_type 453 * @param output_coding_format_company 454 * @param output_coding_format_codec 455 * @param input_coded_data_size 456 * @param outupt_coded_data_size 457 * @param input_pcm_data_format 458 * @param output_pcm_data_format 459 * @param input_pcm_sample_payload_msb_position 460 * @param output_pcm_sample_payload_msb_position 461 * @param input_data_path 462 * @param output_data_path 463 * @param input_transport_unit_size 464 * @param output_transport_unit_size 465 * @param max_latency 466 * @param packet_type 467 * @param retransmission_effort 468 */ 469 const hci_cmd_t hci_enhanced_setup_synchronous_connection = { 470 HCI_OPCODE_HCI_ENHANCED_SETUP_SYNCHRONOUS_CONNECTION, "H4412212222441221222211111111221" 471 }; 472 473 /** 474 * @param bd_addr 475 * @param transmit_bandwidth 476 * @param receive_bandwidth 477 * @param transmit_coding_format_type 478 * @param transmit_coding_format_company 479 * @param transmit_coding_format_codec 480 * @param receive_coding_format_type 481 * @param receive_coding_format_company 482 * @param receive_coding_format_codec 483 * @param transmit_coding_frame_size 484 * @param receive_coding_frame_size 485 * @param input_bandwidth 486 * @param output_bandwidth 487 * @param input_coding_format_type 488 * @param input_coding_format_company 489 * @param input_coding_format_codec 490 * @param output_coding_format_type 491 * @param output_coding_format_company 492 * @param output_coding_format_codec 493 * @param input_coded_data_size 494 * @param outupt_coded_data_size 495 * @param input_pcm_data_format 496 * @param output_pcm_data_format 497 * @param input_pcm_sample_payload_msb_position 498 * @param output_pcm_sample_payload_msb_position 499 * @param input_data_path 500 * @param output_data_path 501 * @param input_transport_unit_size 502 * @param output_transport_unit_size 503 * @param max_latency 504 * @param packet_type 505 * @param retransmission_effort 506 */ 507 const hci_cmd_t hci_enhanced_accept_synchronous_connection = { 508 HCI_OPCODE_HCI_ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION, "B4412212222441221222211111111221" 509 }; 510 511 /** 512 * @param bd_addr 513 * @param c_192 Simple Pairing Hash C derived from P-192 public key 514 * @param r_192 Simple Pairing Randomizer derived from P-192 public key 515 * @param c_256 Simple Pairing Hash C derived from P-256 public key 516 * @param r_256 Simple Pairing Randomizer derived from P-256 public key 517 */ 518 const hci_cmd_t hci_remote_oob_extended_data_request_reply = { 519 HCI_OPCODE_HCI_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY, "BKKKK" 520 }; 521 522 /** 523 * Link Policy Commands 524 */ 525 526 /** 527 * @param handle 528 * @param sniff_max_interval 529 * @param sniff_min_interval 530 * @param sniff_attempt 531 * @param sniff_timeout 532 */ 533 const hci_cmd_t hci_sniff_mode = { 534 HCI_OPCODE_HCI_SNIFF_MODE, "H2222" 535 }; 536 537 /** 538 * @param handle 539 */ 540 const hci_cmd_t hci_exit_sniff_mode = { 541 HCI_OPCODE_HCI_EXIT_SNIFF_MODE, "H" 542 }; 543 544 /** 545 * @param handle 546 * @param flags 547 * @param service_type 548 * @param token_rate (bytes/s) 549 * @param peak_bandwith (bytes/s) 550 * @param latency (us) 551 * @param delay_variation (us) 552 */ 553 const hci_cmd_t hci_qos_setup = { 554 HCI_OPCODE_HCI_QOS_SETUP, "H114444" 555 }; 556 557 /** 558 * @param handle 559 */ 560 const hci_cmd_t hci_role_discovery = { 561 HCI_OPCODE_HCI_ROLE_DISCOVERY, "H" 562 }; 563 564 /** 565 * @param bd_addr 566 * @param role (0=master,1=slave) 567 */ 568 const hci_cmd_t hci_switch_role_command= { 569 HCI_OPCODE_HCI_SWITCH_ROLE_COMMAND, "B1" 570 }; 571 572 /** 573 * @param handle 574 */ 575 const hci_cmd_t hci_read_link_policy_settings = { 576 HCI_OPCODE_HCI_READ_LINK_POLICY_SETTINGS, "H" 577 }; 578 579 /** 580 * @param handle 581 * @param settings 582 */ 583 const hci_cmd_t hci_write_link_policy_settings = { 584 HCI_OPCODE_HCI_WRITE_LINK_POLICY_SETTINGS, "H2" 585 }; 586 587 /** 588 * @param policy 589 */ 590 const hci_cmd_t hci_write_default_link_policy_setting = { 591 HCI_OPCODE_HCI_WRITE_DEFAULT_LINK_POLICY_SETTING, "2" 592 }; 593 594 595 /** 596 * Controller & Baseband Commands 597 */ 598 599 600 /** 601 * @param event_mask_lover_octets 602 * @param event_mask_higher_octets 603 */ 604 const hci_cmd_t hci_set_event_mask = { 605 HCI_OPCODE_HCI_SET_EVENT_MASK, "44" 606 }; 607 608 /** 609 */ 610 const hci_cmd_t hci_reset = { 611 HCI_OPCODE_HCI_RESET, "" 612 }; 613 614 /** 615 * @param handle 616 */ 617 const hci_cmd_t hci_flush = { 618 HCI_OPCODE_HCI_FLUSH, "H" 619 }; 620 621 /** 622 * @param handle 623 */ 624 const hci_cmd_t hci_read_pin_type = { 625 HCI_OPCODE_HCI_READ_PIN_TYPE, "" 626 }; 627 628 /** 629 * @param handle 630 */ 631 const hci_cmd_t hci_write_pin_type = { 632 HCI_OPCODE_HCI_WRITE_PIN_TYPE, "1" 633 }; 634 635 /** 636 * @param bd_addr 637 * @param delete_all_flags 638 */ 639 const hci_cmd_t hci_delete_stored_link_key = { 640 HCI_OPCODE_HCI_DELETE_STORED_LINK_KEY, "B1" 641 }; 642 643 #ifdef ENABLE_CLASSIC 644 /** 645 * @param local_name (UTF-8, Null Terminated, max 248 octets) 646 */ 647 const hci_cmd_t hci_write_local_name = { 648 HCI_OPCODE_HCI_WRITE_LOCAL_NAME, "N" 649 }; 650 #endif 651 652 /** 653 */ 654 const hci_cmd_t hci_read_local_name = { 655 HCI_OPCODE_HCI_READ_LOCAL_NAME, "" 656 }; 657 658 /** 659 */ 660 const hci_cmd_t hci_read_page_timeout = { 661 HCI_OPCODE_HCI_READ_PAGE_TIMEOUT, "" 662 }; 663 664 /** 665 * @param page_timeout (* 0.625 ms) 666 */ 667 const hci_cmd_t hci_write_page_timeout = { 668 HCI_OPCODE_HCI_WRITE_PAGE_TIMEOUT, "2" 669 }; 670 671 /** 672 * @param scan_enable (no, inq, page, inq+page) 673 */ 674 const hci_cmd_t hci_write_scan_enable = { 675 HCI_OPCODE_HCI_WRITE_SCAN_ENABLE, "1" 676 }; 677 678 /** 679 */ 680 const hci_cmd_t hci_read_page_scan_activity = { 681 HCI_OPCODE_HCI_READ_PAGE_SCAN_ACTIVITY, "" 682 }; 683 684 /** 685 * @param page_scan_interval (* 0.625 ms) 686 * @param page_scan_window (* 0.625 ms, must be <= page_scan_interval) 687 */ 688 const hci_cmd_t hci_write_page_scan_activity = { 689 HCI_OPCODE_HCI_WRITE_PAGE_SCAN_ACTIVITY, "22" 690 }; 691 692 /** 693 */ 694 const hci_cmd_t hci_read_inquiry_scan_activity = { 695 HCI_OPCODE_HCI_READ_INQUIRY_SCAN_ACTIVITY, "" 696 }; 697 698 /** 699 * @param inquiry_scan_interval (* 0.625 ms) 700 * @param inquiry_scan_window (* 0.625 ms, must be <= inquiry_scan_interval) 701 */ 702 const hci_cmd_t hci_write_inquiry_scan_activity = { 703 HCI_OPCODE_HCI_WRITE_INQUIRY_SCAN_ACTIVITY, "22" 704 }; 705 706 /** 707 * @param authentication_enable 708 */ 709 const hci_cmd_t hci_write_authentication_enable = { 710 HCI_OPCODE_HCI_WRITE_AUTHENTICATION_ENABLE, "1" 711 }; 712 713 /** 714 * @param class_of_device 715 */ 716 const hci_cmd_t hci_write_class_of_device = { 717 HCI_OPCODE_HCI_WRITE_CLASS_OF_DEVICE, "3" 718 }; 719 720 /** 721 */ 722 const hci_cmd_t hci_read_num_broadcast_retransmissions = { 723 HCI_OPCODE_HCI_READ_NUM_BROADCAST_RETRANSMISSIONS, "" 724 }; 725 726 /** 727 * @param num_broadcast_retransmissions (e.g. 0 for a single broadcast) 728 */ 729 const hci_cmd_t hci_write_num_broadcast_retransmissions = { 730 HCI_OPCODE_HCI_WRITE_NUM_BROADCAST_RETRANSMISSIONS, "1" 731 }; 732 733 /** 734 * @param connection_handle 735 * @param type 0 = current transmit level, 1 = max transmit level 736 */ 737 const hci_cmd_t hci_read_transmit_power_level = { 738 HCI_OPCODE_HCI_READ_TRANSMIT_POWER_LEVEL, "11" 739 }; 740 741 /** 742 * @param synchronous_flow_control_enable - if yes, num completed packet everts are sent for SCO packets 743 */ 744 const hci_cmd_t hci_write_synchronous_flow_control_enable = { 745 HCI_OPCODE_HCI_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE, "1" 746 }; 747 748 #ifdef ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL 749 750 /** 751 * @param flow_control_enable - 0: off, 1: ACL only, 2: SCO only, 3: ACL + SCO 752 */ 753 const hci_cmd_t hci_set_controller_to_host_flow_control = { 754 HCI_OPCODE_HCI_SET_CONTROLLER_TO_HOST_FLOW_CONTROL, "1" 755 }; 756 757 /** 758 * @param host_acl_data_packet_length 759 * @param host_synchronous_data_packet_length 760 * @param host_total_num_acl_data_packets 761 * @param host_total_num_synchronous_data_packets 762 */ 763 const hci_cmd_t hci_host_buffer_size = { 764 HCI_OPCODE_HCI_HOST_BUFFER_SIZE, "2122" 765 }; 766 767 768 #if 0 769 // 770 // command sent manually sent by hci_host_num_completed_packets 771 // 772 /** 773 * @note only single handle supported by BTstack command generator 774 * @param number_of_handles must be 1 775 * @param connection_handle 776 * @param host_num_of_completed_packets for the given connection handle 777 */ 778 const hci_cmd_t hci_host_number_of_completed_packets = { 779 HCI_OPCODE_HCI_HOST_NUMBER_OF_COMPLETED_PACKETS, "1H2" 780 }; 781 #endif 782 783 #endif 784 785 /** 786 * @param handle 787 */ 788 const hci_cmd_t hci_read_link_supervision_timeout = { 789 HCI_OPCODE_HCI_READ_LINK_SUPERVISION_TIMEOUT, "H" 790 }; 791 792 /** 793 * @param handle 794 * @param timeout (0x0001 - 0xFFFF Time -> Range: 0.625ms - 40.9 sec) 795 */ 796 const hci_cmd_t hci_write_link_supervision_timeout = { 797 HCI_OPCODE_HCI_WRITE_LINK_SUPERVISION_TIMEOUT, "H2" 798 }; 799 800 /** 801 * @param num_current_iac must be 2 802 * @param iac_lap1 803 * @param iac_lap2 804 */ 805 const hci_cmd_t hci_write_current_iac_lap_two_iacs = { 806 HCI_OPCODE_HCI_WRITE_CURRENT_IAC_LAP_TWO_IACS, "133" 807 }; 808 809 /** 810 * @param inquiry_scan_type (0x00 = standard, 0x01 = interlaced) 811 */ 812 const hci_cmd_t hci_write_inquiry_scan_type = { 813 HCI_OPCODE_HCI_WRITE_INQUIRY_SCAN_TYPE, "1" 814 }; 815 816 /** 817 * @param inquiry_mode (0x00 = standard, 0x01 = with RSSI, 0x02 = extended) 818 */ 819 const hci_cmd_t hci_write_inquiry_mode = { 820 HCI_OPCODE_HCI_WRITE_INQUIRY_MODE, "1" 821 }; 822 823 /** 824 * @param page_scan_type (0x00 = standard, 0x01 = interlaced) 825 */ 826 const hci_cmd_t hci_write_page_scan_type = { 827 HCI_OPCODE_HCI_WRITE_PAGE_SCAN_TYPE, "1" 828 }; 829 830 /** 831 * @param fec_required 832 * @param exstended_inquiry_response 833 */ 834 const hci_cmd_t hci_write_extended_inquiry_response = { 835 HCI_OPCODE_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE, "1E" 836 }; 837 838 /** 839 * @param mode (0 = off, 1 = on) 840 */ 841 const hci_cmd_t hci_write_simple_pairing_mode = { 842 HCI_OPCODE_HCI_WRITE_SIMPLE_PAIRING_MODE, "1" 843 }; 844 845 /** 846 */ 847 const hci_cmd_t hci_read_local_oob_data = { 848 HCI_OPCODE_HCI_READ_LOCAL_OOB_DATA, "" 849 // return status, C, R 850 }; 851 852 /** 853 * @param mode (0 = off, 1 = on) 854 */ 855 const hci_cmd_t hci_write_default_erroneous_data_reporting = { 856 HCI_OPCODE_HCI_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING, "1" 857 }; 858 859 /** 860 */ 861 const hci_cmd_t hci_read_le_host_supported = { 862 HCI_OPCODE_HCI_READ_LE_HOST_SUPPORTED, "" 863 // return: status, le supported host, simultaneous le host 864 }; 865 866 /** 867 * @param le_supported_host 868 * @param simultaneous_le_host 869 */ 870 const hci_cmd_t hci_write_le_host_supported = { 871 HCI_OPCODE_HCI_WRITE_LE_HOST_SUPPORTED, "11" 872 // return: status 873 }; 874 875 /** 876 * @param secure_connections_host_support 877 */ 878 const hci_cmd_t hci_write_secure_connections_host_support = { 879 HCI_OPCODE_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT, "1" 880 // return: status 881 }; 882 883 /** 884 */ 885 const hci_cmd_t hci_read_local_extended_oob_data = { 886 HCI_OPCODE_HCI_READ_LOCAL_EXTENDED_OOB_DATA, "" 887 // return status, C_192, R_192, R_256, C_256 888 }; 889 890 891 /** 892 * Testing Commands 893 */ 894 895 896 /** 897 */ 898 const hci_cmd_t hci_read_loopback_mode = { 899 HCI_OPCODE_HCI_READ_LOOPBACK_MODE, "" 900 // return: status, loopback mode (0 = off, 1 = local loopback, 2 = remote loopback) 901 }; 902 903 /** 904 * @param loopback_mode 905 */ 906 const hci_cmd_t hci_write_loopback_mode = { 907 HCI_OPCODE_HCI_WRITE_LOOPBACK_MODE, "1" 908 // return: status 909 }; 910 911 /** 912 */ 913 const hci_cmd_t hci_enable_device_under_test_mode = { 914 HCI_OPCODE_HCI_ENABLE_DEVICE_UNDER_TEST_MODE, "" 915 // return: status 916 }; 917 918 /** 919 * @param simple_pairing_debug_mode 920 */ 921 const hci_cmd_t hci_write_simple_pairing_debug_mode = { 922 HCI_OPCODE_HCI_WRITE_SIMPLE_PAIRING_DEBUG_MODE, "1" 923 // return: status 924 }; 925 926 /** 927 * @param handle 928 * @param dm1_acl_u_mode 929 * @param esco_loopback_mode 930 */ 931 const hci_cmd_t hci_write_secure_connections_test_mode = { 932 HCI_OPCODE_HCI_WRITE_SECURE_CONNECTIONS_TEST_MODE, "H11" 933 // return: status 934 }; 935 936 937 /** 938 * Informational Parameters 939 */ 940 941 const hci_cmd_t hci_read_local_version_information = { 942 HCI_OPCODE_HCI_READ_LOCAL_VERSION_INFORMATION, "" 943 }; 944 const hci_cmd_t hci_read_local_supported_commands = { 945 HCI_OPCODE_HCI_READ_LOCAL_SUPPORTED_COMMANDS, "" 946 }; 947 const hci_cmd_t hci_read_local_supported_features = { 948 HCI_OPCODE_HCI_READ_LOCAL_SUPPORTED_FEATURES, "" 949 }; 950 const hci_cmd_t hci_read_buffer_size = { 951 HCI_OPCODE_HCI_READ_BUFFER_SIZE, "" 952 }; 953 const hci_cmd_t hci_read_bd_addr = { 954 HCI_OPCODE_HCI_READ_BD_ADDR, "" 955 }; 956 957 /** 958 * Status Paramters 959 */ 960 961 /** 962 * @param handle 963 */ 964 const hci_cmd_t hci_read_rssi = { 965 HCI_OPCODE_HCI_READ_RSSI, "H" 966 }; 967 968 /** 969 * @param handle 970 */ 971 const hci_cmd_t hci_read_encryption_key_size = { 972 HCI_OPCODE_HCI_READ_ENCRYPTION_KEY_SIZE, "H" 973 }; 974 975 976 #ifdef ENABLE_BLE 977 /** 978 * Low Energy Commands 979 */ 980 981 /** 982 * @param event_mask_lower_octets 983 * @param event_mask_higher_octets 984 */ 985 const hci_cmd_t hci_le_set_event_mask = { 986 HCI_OPCODE_HCI_LE_SET_EVENT_MASK, "44" 987 // return: status 988 }; 989 990 const hci_cmd_t hci_le_read_buffer_size = { 991 HCI_OPCODE_HCI_LE_READ_BUFFER_SIZE, "" 992 // return: status, le acl data packet len (16), total num le acl data packets(8) 993 }; 994 const hci_cmd_t hci_le_read_supported_features = { 995 HCI_OPCODE_HCI_LE_READ_SUPPORTED_FEATURES, "" 996 // return: LE_Features See [Vol 6] Part B, Section 4.6 997 }; 998 999 /** 1000 * @param random_bd_addr 1001 */ 1002 const hci_cmd_t hci_le_set_random_address = { 1003 HCI_OPCODE_HCI_LE_SET_RANDOM_ADDRESS, "B" 1004 // return: status 1005 }; 1006 1007 /** 1008 * @param advertising_interval_min ([0x0020,0x4000], default: 0x0800, unit: 0.625 msec) 1009 * @param advertising_interval_max ([0x0020,0x4000], default: 0x0800, unit: 0.625 msec) 1010 * @param advertising_type (enum from 0: ADV_IND, ADC_DIRECT_IND, ADV_SCAN_IND, ADV_NONCONN_IND) 1011 * @param own_address_type (enum from 0: public device address, random device address) 1012 * @param direct_address_type () 1013 * @param direct_address (public or random address of device to be connecteed) 1014 * @param advertising_channel_map (flags: chan_37(1), chan_38(2), chan_39(4)) 1015 * @param advertising_filter_policy (enum from 0: scan any conn any, scan whitelist, con any, scan any conn whitelist, scan whitelist, con whitelist) 1016 */ 1017 const hci_cmd_t hci_le_set_advertising_parameters = { 1018 HCI_OPCODE_HCI_LE_SET_ADVERTISING_PARAMETERS, "22111B11" 1019 // return: status 1020 }; 1021 1022 const hci_cmd_t hci_le_read_advertising_channel_tx_power = { 1023 HCI_OPCODE_HCI_LE_READ_ADVERTISING_CHANNEL_TX_POWER, "" 1024 // return: status, level [-20,10] signed int (8), units dBm 1025 }; 1026 1027 /** 1028 * @param advertising_data_length 1029 * @param advertising_data (31 bytes) 1030 */ 1031 const hci_cmd_t hci_le_set_advertising_data= { 1032 HCI_OPCODE_HCI_LE_SET_ADVERTISING_DATA, "1A" 1033 // return: status 1034 }; 1035 1036 /** 1037 * @param scan_response_data_length 1038 * @param scan_response_data (31 bytes) 1039 */ 1040 const hci_cmd_t hci_le_set_scan_response_data= { 1041 HCI_OPCODE_HCI_LE_SET_SCAN_RESPONSE_DATA, "1A" 1042 // return: status 1043 }; 1044 1045 /** 1046 * @param advertise_enable (off: 0, on: 1) 1047 */ 1048 const hci_cmd_t hci_le_set_advertise_enable = { 1049 HCI_OPCODE_HCI_LE_SET_ADVERTISE_ENABLE, "1" 1050 // return: status 1051 }; 1052 1053 /** 1054 * @param le_scan_type (passive (0), active (1)) 1055 * @param le_scan_interval ([0x0004,0x4000], unit: 0.625 msec) 1056 * @param le_scan_window ([0x0004,0x4000], unit: 0.625 msec) 1057 * @param own_address_type (public (0), random (1)) 1058 * @param scanning_filter_policy (any (0), only whitelist (1)) 1059 */ 1060 const hci_cmd_t hci_le_set_scan_parameters = { 1061 HCI_OPCODE_HCI_LE_SET_SCAN_PARAMETERS, "12211" 1062 // return: status 1063 }; 1064 1065 /** 1066 * @param le_scan_enable (disabled (0), enabled (1)) 1067 * @param filter_duplices (disabled (0), enabled (1)) 1068 */ 1069 const hci_cmd_t hci_le_set_scan_enable = { 1070 HCI_OPCODE_HCI_LE_SET_SCAN_ENABLE, "11" 1071 // return: status 1072 }; 1073 1074 /** 1075 * @param le_scan_interval ([0x0004, 0x4000], unit: 0.625 msec) 1076 * @param le_scan_window ([0x0004, 0x4000], unit: 0.625 msec) 1077 * @param initiator_filter_policy (peer address type + peer address (0), whitelist (1)) 1078 * @param peer_address_type (public (0), random (1)) 1079 * @param peer_address 1080 * @param own_address_type (public (0), random (1)) 1081 * @param conn_interval_min ([0x0006, 0x0c80], unit: 1.25 msec) 1082 * @param conn_interval_max ([0x0006, 0x0c80], unit: 1.25 msec) 1083 * @param conn_latency (number of connection events [0x0000, 0x01f4]) 1084 * @param supervision_timeout ([0x000a, 0x0c80], unit: 10 msec) 1085 * @param minimum_CE_length ([0x0000, 0xffff], unit: 0.625 msec) 1086 * @param maximum_CE_length ([0x0000, 0xffff], unit: 0.625 msec) 1087 */ 1088 const hci_cmd_t hci_le_create_connection= { 1089 HCI_OPCODE_HCI_LE_CREATE_CONNECTION, "2211B1222222" 1090 // return: none -> le create connection complete event 1091 }; 1092 1093 const hci_cmd_t hci_le_create_connection_cancel = { 1094 HCI_OPCODE_HCI_LE_CREATE_CONNECTION_CANCEL, "" 1095 // return: status 1096 }; 1097 1098 const hci_cmd_t hci_le_read_white_list_size = { 1099 HCI_OPCODE_HCI_LE_READ_WHITE_LIST_SIZE, "" 1100 // return: status, number of entries in controller whitelist 1101 }; 1102 1103 const hci_cmd_t hci_le_clear_white_list = { 1104 HCI_OPCODE_HCI_LE_CLEAR_WHITE_LIST, "" 1105 // return: status 1106 }; 1107 1108 /** 1109 * @param address_type (public (0), random (1)) 1110 * @param bd_addr 1111 */ 1112 const hci_cmd_t hci_le_add_device_to_white_list = { 1113 HCI_OPCODE_HCI_LE_ADD_DEVICE_TO_WHITE_LIST, "1B" 1114 // return: status 1115 }; 1116 1117 /** 1118 * @param address_type (public (0), random (1)) 1119 * @param bd_addr 1120 */ 1121 const hci_cmd_t hci_le_remove_device_from_white_list = { 1122 HCI_OPCODE_HCI_LE_REMOVE_DEVICE_FROM_WHITE_LIST, "1B" 1123 // return: status 1124 }; 1125 1126 /** 1127 * @param conn_handle 1128 * @param conn_interval_min ([0x0006,0x0c80], unit: 1.25 msec) 1129 * @param conn_interval_max ([0x0006,0x0c80], unit: 1.25 msec) 1130 * @param conn_latency ([0x0000,0x03e8], number of connection events) 1131 * @param supervision_timeout ([0x000a,0x0c80], unit: 10 msec) 1132 * @param minimum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1133 * @param maximum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1134 */ 1135 const hci_cmd_t hci_le_connection_update = { 1136 HCI_OPCODE_HCI_LE_CONNECTION_UPDATE, "H222222" 1137 // return: none -> le connection update complete event 1138 }; 1139 1140 /** 1141 * @param channel_map_lower_32bits 1142 * @param channel_map_higher_5bits 1143 */ 1144 const hci_cmd_t hci_le_set_host_channel_classification = { 1145 HCI_OPCODE_HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION, "41" 1146 // return: status 1147 }; 1148 1149 /** 1150 * @param conn_handle 1151 */ 1152 const hci_cmd_t hci_le_read_channel_map = { 1153 HCI_OPCODE_HCI_LE_READ_CHANNEL_MAP, "H" 1154 // return: status, connection handle, channel map (5 bytes, 37 used) 1155 }; 1156 1157 /** 1158 * @param conn_handle 1159 */ 1160 const hci_cmd_t hci_le_read_remote_used_features = { 1161 HCI_OPCODE_HCI_LE_READ_REMOTE_USED_FEATURES, "H" 1162 // return: none -> le read remote used features complete event 1163 }; 1164 1165 /** 1166 * @param key ((128) for AES-128) 1167 * @param plain_text (128) 1168 */ 1169 const hci_cmd_t hci_le_encrypt = { 1170 HCI_OPCODE_HCI_LE_ENCRYPT, "PP" 1171 // return: status, encrypted data (128) 1172 }; 1173 1174 const hci_cmd_t hci_le_rand = { 1175 HCI_OPCODE_HCI_LE_RAND, "" 1176 // return: status, random number (64) 1177 }; 1178 1179 /** 1180 * @param conn_handle 1181 * @param random_number_lower_32bits 1182 * @param random_number_higher_32bits 1183 * @param encryption_diversifier (16) 1184 * @param long_term_key (128) 1185 */ 1186 const hci_cmd_t hci_le_start_encryption = { 1187 HCI_OPCODE_HCI_LE_START_ENCRYPTION, "H442P" 1188 // return: none -> encryption changed or encryption key refresh complete event 1189 }; 1190 1191 /** 1192 * @param connection_handle 1193 * @param long_term_key (128) 1194 */ 1195 const hci_cmd_t hci_le_long_term_key_request_reply = { 1196 HCI_OPCODE_HCI_LE_LONG_TERM_KEY_REQUEST_REPLY, "HP" 1197 // return: status, connection handle 1198 }; 1199 1200 /** 1201 * @param conn_handle 1202 */ 1203 const hci_cmd_t hci_le_long_term_key_negative_reply = { 1204 HCI_OPCODE_HCI_LE_LONG_TERM_KEY_NEGATIVE_REPLY, "H" 1205 // return: status, connection handle 1206 }; 1207 1208 /** 1209 * @param conn_handle 1210 */ 1211 const hci_cmd_t hci_le_read_supported_states = { 1212 HCI_OPCODE_HCI_LE_READ_SUPPORTED_STATES, "H" 1213 // return: status, LE states (64) 1214 }; 1215 1216 /** 1217 * @param rx_frequency ([0x00 0x27], frequency (MHz): 2420 + N*2) 1218 */ 1219 const hci_cmd_t hci_le_receiver_test = { 1220 HCI_OPCODE_HCI_LE_RECEIVER_TEST, "1" 1221 // return: status 1222 }; 1223 1224 /** 1225 * @param tx_frequency ([0x00 0x27], frequency (MHz): 2420 + N*2) 1226 * @param test_payload_lengh ([0x00,0x25]) 1227 * @param packet_payload ([0,7] different patterns) 1228 */ 1229 const hci_cmd_t hci_le_transmitter_test = { 1230 HCI_OPCODE_HCI_LE_TRANSMITTER_TEST, "111" 1231 // return: status 1232 }; 1233 1234 /** 1235 * @param end_test_cmd 1236 */ 1237 const hci_cmd_t hci_le_test_end = { 1238 HCI_OPCODE_HCI_LE_TEST_END, "1" 1239 // return: status, number of packets (8) 1240 }; 1241 1242 /** 1243 * @param conn_handle 1244 * @param conn_interval_min ([0x0006,0x0c80], unit: 1.25 msec) 1245 * @param conn_interval_max ([0x0006,0x0c80], unit: 1.25 msec) 1246 * @param conn_latency ([0x0000,0x03e8], number of connection events) 1247 * @param supervision_timeout ([0x000a,0x0c80], unit: 10 msec) 1248 * @param minimum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1249 * @param maximum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1250 */ 1251 const hci_cmd_t hci_le_remote_connection_parameter_request_reply = { 1252 HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY, "H222222" 1253 // return: status, connection handle 1254 }; 1255 1256 /** 1257 * @param con_handle 1258 * @param reason 1259 */ 1260 const hci_cmd_t hci_le_remote_connection_parameter_request_negative_reply = { 1261 HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY, "H1" 1262 // return: status, connection handle 1263 }; 1264 1265 /** 1266 * @param con_handle 1267 * @param tx_octets 1268 * @param tx_time 1269 */ 1270 const hci_cmd_t hci_le_set_data_length = { 1271 HCI_OPCODE_HCI_LE_SET_DATA_LENGTH, "H22" 1272 // return: status, connection handle 1273 }; 1274 1275 /** 1276 */ 1277 const hci_cmd_t hci_le_read_suggested_default_data_length = { 1278 HCI_OPCODE_HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH, "" 1279 // return: status, suggested max tx octets, suggested max tx time 1280 }; 1281 1282 /** 1283 * @param suggested_max_tx_octets 1284 * @param suggested_max_tx_time 1285 */ 1286 const hci_cmd_t hci_le_write_suggested_default_data_length = { 1287 HCI_OPCODE_HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH, "22" 1288 // return: status 1289 }; 1290 1291 /** 1292 */ 1293 const hci_cmd_t hci_le_read_local_p256_public_key = { 1294 HCI_OPCODE_HCI_LE_READ_LOCAL_P256_PUBLIC_KEY, "" 1295 // LE Read Local P-256 Public Key Complete is generated on completion 1296 }; 1297 1298 /** 1299 * @param public key 1300 * @param private key 1301 */ 1302 const hci_cmd_t hci_le_generate_dhkey = { 1303 HCI_OPCODE_HCI_LE_GENERATE_DHKEY, "QQ" 1304 // LE Generate DHKey Complete is generated on completion 1305 }; 1306 1307 /** 1308 * @param Peer_Identity_Address_Type 1309 * @param Peer_Identity_Address 1310 * @param Peer_IRK 1311 * @param Local_IRK 1312 */ 1313 const hci_cmd_t hci_le_add_device_to_resolving_list = { 1314 HCI_OPCODE_HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST, "1BPP" 1315 }; 1316 1317 /** 1318 * @param Peer_Identity_Address_Type 1319 * @param Peer_Identity_Address 1320 */ 1321 const hci_cmd_t hci_le_remove_device_from_resolving_list = { 1322 HCI_OPCODE_HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST, "1B" 1323 }; 1324 1325 /** 1326 */ 1327 const hci_cmd_t hci_le_clear_resolving_list = { 1328 HCI_OPCODE_HCI_LE_CLEAR_RESOLVING_LIST, "" 1329 }; 1330 1331 /** 1332 */ 1333 const hci_cmd_t hci_le_read_resolving_list_size = { 1334 HCI_OPCODE_HCI_LE_READ_RESOLVING_LIST_SIZE, "" 1335 }; 1336 1337 /** 1338 * @param Peer_Identity_Address_Type 1339 * @param Peer_Identity_Address 1340 */ 1341 const hci_cmd_t hci_le_read_peer_resolvable_address = { 1342 HCI_OPCODE_HCI_LE_READ_PEER_RESOLVABLE_ADDRESS, "" 1343 }; 1344 1345 /** 1346 * @param Peer_Identity_Address_Type 1347 * @param Peer_Identity_Address 1348 */ 1349 const hci_cmd_t hci_le_read_local_resolvable_address = { 1350 HCI_OPCODE_HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS, "" 1351 }; 1352 1353 /** 1354 * @param Address_Resolution_Enable 1355 */ 1356 const hci_cmd_t hci_le_set_address_resolution_enabled= { 1357 HCI_OPCODE_HCI_LE_SET_ADDRESS_RESOLUTION_ENABLED, "1" 1358 }; 1359 1360 /** 1361 * @param RPA_Timeout in seconds, range 0x0001 to 0x0E10, default: 900 s 1362 */ 1363 const hci_cmd_t hci_le_set_resolvable_private_address_timeout= { 1364 HCI_OPCODE_HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT, "2" 1365 }; 1366 1367 /** 1368 */ 1369 const hci_cmd_t hci_le_read_maximum_data_length = { 1370 HCI_OPCODE_HCI_LE_READ_MAXIMUM_DATA_LENGTH, "" 1371 // return: status, supported max tx octets, supported max tx time, supported max rx octets, supported max rx time 1372 }; 1373 1374 /** 1375 * @param con_handle 1376 */ 1377 const hci_cmd_t hci_le_read_phy = { 1378 HCI_OPCODE_HCI_LE_READ_PHY, "H" 1379 // return: status, connection handler, tx phy, rx phy 1380 }; 1381 1382 /** 1383 * @param all_phys 1384 * @param tx_phys 1385 * @param rx_phys 1386 */ 1387 const hci_cmd_t hci_le_set_default_phy = { 1388 HCI_OPCODE_HCI_LE_SET_DEFAULT_PHY, "111" 1389 // return: status 1390 }; 1391 1392 /** 1393 * @param con_handle 1394 * @param all_phys 1395 * @param tx_phys 1396 * @param rx_phys 1397 * @param phy_options 1398 */ 1399 const hci_cmd_t hci_le_set_phy = { 1400 HCI_OPCODE_HCI_LE_SET_PHY, "H1111" 1401 // LE PHY Update Complete is generated on completion 1402 }; 1403 1404 1405 #endif 1406 1407 // Broadcom / Cypress specific HCI commands 1408 1409 /** 1410 * @brief Enable Wide-Band Speech / mSBC decoding for PCM 1411 * @param enable_wbs is 0 for disable, 1 for enable 1412 * @param uuid_wbs is 2 for EV2/EV3 1413 */ 1414 const hci_cmd_t hci_bcm_enable_wbs = { 1415 HCI_OPCODE_HCI_BCM_ENABLE_WBS, "12" 1416 // return: status 1417 }; 1418 1419 /** 1420 * @brief Configure SCO Routing (BCM) 1421 * @param sco_routing is 0 for PCM, 1 for Transport, 2 for Codec and 3 for I2S 1422 * @param pcm_interface_rate is 0 for 128KBps, 1 for 256 KBps, 2 for 512KBps, 3 for 1024KBps, and 4 for 2048Kbps 1423 * @param frame_type is 0 for short and 1 for long 1424 * @param sync_mode is 0 for slave and 1 for master 1425 * @param clock_mode is 0 for slabe and 1 for master 1426 */ 1427 const hci_cmd_t hci_bcm_write_sco_pcm_int = { 1428 HCI_OPCODE_HCI_BCM_WRITE_SCO_PCM_INT, "11111" 1429 // return: status 1430 }; 1431 1432 /** 1433 * @brief Configure the I2S/PCM interface (BCM) 1434 * @param i2s_enable is 0 for off, 1 for on 1435 * @param is_master is 0 for slave, is 1 for master 1436 * @param sample_rate is 0 for 8 kHz, 1 for 16 kHz, 2 for 4 kHz 1437 * @param clock_rate is 0 for 128 kz, 1 for 256 kHz, 2 for 512 khz, 3 for 1024 kHz, 4 for 2048 khz 1438 * @param clock_mode is 0 for slabe and 1 for master 1439 */ 1440 const hci_cmd_t hci_bcm_write_i2spcm_interface_param = { 1441 HCI_OPCODE_HCI_BCM_WRITE_I2SPCM_INTERFACE_PARAM, "1111" 1442 // return: status 1443 }; 1444 1445 1446 /** 1447 * @brief Activates selected Sleep Mode 1448 * @param sleep_mode: 0=no sleep, 1=UART, 2=UART with Messaging, 3=USB, 4=H4IBSS, USB with Host Wake, 6=SDIO, 7=UART CS-N, 8=SPI, 9=H5, 10=H4DS, 12=UART with BREAK 1449 * @param idle_threshold_host (modes 1,2,5,7) time until considered idle, unit roughly 300 ms 1450 * @param idle_threshold_controller (modes 1-7,9) time until considered idle, unit roughly 300 ms 1451 * @param bt_wake_active_mode (modes 1,2,7) 0 = BT_WAKE line is active high, 1 = BT_WAKE is active low 1452 * @param host_wake_active_mode (modes 1,2,5,7) 0 = HOST_WAKE line is active high, 1 = HOST_WAKE is active low 1453 * @param allow_host_sleep_during_sco (modes 1,2,3,5,7) 1454 * @param combine_sleep_mode_and_lpm (modes 1,2,3,5,7) 1455 * @param enable_tristate_control_of_uart_tx_line (modes 1,2,7) 1456 * @param active_connection_handling_on_suspend (modes 3,5) 1457 * @param resume_timeout (modes 3,5) 1458 * @param enable_break_to_host (mode 12) 1459 * @param pulsed_host_wake (modes 1,12) 1460 */ 1461 const hci_cmd_t hci_bcm_set_sleep_mode = { 1462 HCI_OPCODE_HCI_BCM_SET_SLEEP_MODE, "111111111111" 1463 }; 1464 1465 /** 1466 * @brief Set TX Power Table 1467 * @param is_le 0=classic, 1=LE 1468 * @param chip_max_tx_pwr_db chip level max TX power in dBM 1469 */ 1470 const hci_cmd_t hci_bcm_write_tx_power_table = { 1471 HCI_OPCODE_HCI_BCM_WRITE_TX_POWER_TABLE, "11" 1472 }; 1473 1474 const hci_cmd_t hci_bcm_set_tx_pwr = { 1475 HCI_OPCODE_HCI_BCM_SET_TX_PWR, "11H" 1476 }; 1477 1478 /** 1479 * 1480 * 1481 * @brief This command tests the RF transceiver in continuous transmission mode. 1482 * The transmitter is activated by configuring the transmission parameters such as pattern, 1483 * modulation, and frequency. 1484 * @see processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands#HCI_VS_DRPb_Tester_Con_TX.280xFD84.29 1485 * @param modulation 1486 * @param test_patern 1487 * @param frequency 1488 * @param power_level 1489 * @param reserved1 1490 * @param reserved2 1491 */ 1492 const hci_cmd_t hci_ti_drpb_tester_con_tx = { 1493 0xFD84, "111144" 1494 }; 1495 1496 /** 1497 * @brief This command starts sending/receiving packets using packet transmission parameters such as 1498 * frequency channel, packet type, and packet length. It is used for Packet TX/RX. 1499 * @see processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands#HCI_VS_DRPb_Tester_Packet_TX_RX_.280xFD85.29 1500 * @param frequency_mode 1501 * @param tx_single_frequency 1502 * @param rx_single_frequency 1503 * @param acl_packet_type 1504 * @paarm acl_packet_data_pattern 1505 * @param reserved 1506 * @param power_level 1507 * @param disable_whitening 1508 * @param prbs9_initialization_value 1509 */ 1510 const hci_cmd_t hci_ti_drpb_tester_packet_tx_rx = { 1511 0xFD85, "1111112112" 1512 }; 1513 1514 /** 1515 * @brief This command is used to associate the requested ACL handle with Wide Band Speech configuration. 1516 * @param enable 0=disable, 1=enable 1517 * @param a3dp_role (NL5500, WL128x only) 0=source,1=sink 1518 * @param code_upload (NL5500, WL128x only) 0=do not load a3dp code, 1=load a3dp code 1519 * @param reserved for future use 1520 */ 1521 const hci_cmd_t hci_ti_avrp_enable = { 1522 0xFD92, "1112" 1523 }; 1524 1525 /** 1526 * @brief This command is used to associate the requested ACL handle with Wide Band Speech configuration. 1527 * @param acl_con_handle 1528 */ 1529 const hci_cmd_t hci_ti_wbs_associate = { 1530 0xFD78, "H" 1531 }; 1532 1533 /** 1534 * @brief This command is used to disassociate Wide Band Speech configuration from any ACL handle. 1535 */ 1536 const hci_cmd_t hci_ti_wbs_disassociate = { 1537 0xFD79, "" 1538 }; 1539 1540 /** 1541 * @brief This command configures the codec interface parameters and the PCM clock rate, which is relevant when 1542 the Bluetooth core generates the clock. This command must be used by the host to use the PCM 1543 interface. 1544 * @param clock_rate in kHz 1545 * @param clock_direction 0=master/output, 1=slave/input 1546 * @param frame_sync_frequency in Hz 1547 * @param frame_sync_duty_cycle 0=50% (I2S Format), 0x0001-0xffff number of cycles of PCM clock 1548 * @param frame_sync_edge 0=driven/sampled at rising edge, 1=driven/sampled at falling edge of PCM clock 1549 * @param frame_sync_polariy 0=active high, 1=active low 1550 * @param reserved1 1551 * @param channel_1_data_out_size sample size in bits 1552 * @param channel_1_data_out_offset number of PCM clock cycles between rising of frame sync and data start 1553 * @param channel_1_data_out_edge 0=data driven at rising edge, 1=data driven at falling edge of PCM clock 1554 * @param channel_1_data_in_size sample size in bits 1555 * @param channel_1_data_in_offset number of PCM clock cycles between rising of frame sync and data start 1556 * @param channel_1_data_in_edge 0=data sampled at rising edge, 1=data sampled at falling edge of PCM clock 1557 * @param fsync_multiplier this field is only relevant to CC256XB from service pack 0.2 !!! -> use 0x00 1558 * @param channel_2_data_out_size sample size in bits 1559 * @param channel_2_data_out_offset number of PCM clock cycles between rising of frame sync and data start 1560 * @param channel_2_data_out_edge 0=data driven at rising edge, 1=data driven at falling edge of PCM clock 1561 * @param channel_2_data_in_size sample size in bits 1562 * @param channel_2_data_in_offset number of PCM clock cycles between rising of frame sync and data start 1563 * @param channel_2_data_in_edge 0=data sampled at rising edge, 1=data sampled at falling edge of PCM clock 1564 * @param reserved2 1565 * 1566 */ 1567 const hci_cmd_t hci_ti_write_codec_config = { 1568 0xFD06, "214211122122112212211" 1569 }; 1570