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 "hci.h" 49 #include "hci_cmd.h" 50 #include "btstack_debug.h" 51 52 #include <string.h> 53 54 55 #ifdef ENABLE_SDP 56 #include "classic/sdp_util.h" 57 #endif 58 59 // calculate combined ogf/ocf value 60 #define OPCODE(ogf, ocf) ((ocf) | ((ogf) << 10)) 61 62 #define INVALID_VAR_LEN 0xffffu 63 // hci_le_set_cig_parameters_test has 10 arrayed parameters 64 #define MAX_NR_ARRAY_FIELDS 10 65 #define INVALID_ARRAY_LEN 0xff 66 67 /** 68 * construct HCI Command based on template 69 * 70 * Format: 71 * 1,2,3,4: one to four byte value 72 * H: HCI connection handle 73 * B: Bluetooth Baseband Address (BD_ADDR) 74 * D: 8 byte data block 75 * E: Extended Inquiry Result 76 * N: Name up to 248 chars, \0 terminated 77 * P: 16 byte data block. Pairing code, Simple Pairing Hash and Randomizer 78 * A: 31 bytes advertising data 79 * S: Service Record (Data Element Sequence) 80 * Q: 32 byte data block, e.g. for X and Y coordinates of P-256 public key 81 * J: 8-bit length of variable size element 82 * V: variable size element, len was given with param 'J' 83 * a: number of elements in following arrayed parameters(s), specified as '[...]' 84 * b: bit field indicating number of arrayed parameters(s), specified as '[...]' 85 * [: start of arrayed param sequence 86 * ]: end of arrayed param sequence 87 */ 88 uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr){ 89 90 hci_cmd_buffer[0] = cmd->opcode & 0xffu; 91 hci_cmd_buffer[1] = cmd->opcode >> 8; 92 uint16_t pos = 3; 93 94 const char *format = cmd->format; 95 uint16_t word; 96 uint32_t longword; 97 uint8_t * ptr; 98 uint16_t var_len = INVALID_VAR_LEN; 99 100 const char * array_format = NULL; 101 void * array_data[MAX_NR_ARRAY_FIELDS]; 102 uint8_t array_num_elements = INVALID_ARRAY_LEN; 103 uint8_t array_num_fields; 104 uint8_t array_element_index; 105 106 bool done_format = false; 107 while (!done_format) { 108 bool done_array; 109 switch(*format) { 110 case 0: 111 done_format = true; 112 break; 113 case '1': // 8 bit value 114 word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE 115 hci_cmd_buffer[pos++] = word & 0xffu; 116 break; 117 case '2': // 16 bit value 118 word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE 119 hci_cmd_buffer[pos++] = word & 0xffu; 120 hci_cmd_buffer[pos++] = word >> 8; 121 break; 122 case 'H': // hci_handle 123 word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE 124 hci_cmd_buffer[pos++] = word & 0xffu; 125 hci_cmd_buffer[pos++] = word >> 8; 126 break; 127 case '3': 128 longword = va_arg(argptr, uint32_t); // LCOV_EXCL_BR_LINE 129 hci_cmd_buffer[pos++] = longword; 130 hci_cmd_buffer[pos++] = longword >> 8; 131 hci_cmd_buffer[pos++] = longword >> 16; 132 break; 133 case '4': 134 longword = va_arg(argptr, uint32_t); // LCOV_EXCL_BR_LINE 135 hci_cmd_buffer[pos++] = longword; 136 hci_cmd_buffer[pos++] = longword >> 8; 137 hci_cmd_buffer[pos++] = longword >> 16; 138 hci_cmd_buffer[pos++] = longword >> 24; 139 break; 140 case 'B': // bt-addr 141 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 142 hci_cmd_buffer[pos++] = ptr[5]; 143 hci_cmd_buffer[pos++] = ptr[4]; 144 hci_cmd_buffer[pos++] = ptr[3]; 145 hci_cmd_buffer[pos++] = ptr[2]; 146 hci_cmd_buffer[pos++] = ptr[1]; 147 hci_cmd_buffer[pos++] = ptr[0]; 148 break; 149 case 'D': // 8 byte data block 150 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 151 (void)memcpy(&hci_cmd_buffer[pos], ptr, 8); 152 pos += 8; 153 break; 154 case 'E': // Extended Inquiry Information 240 octets 155 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 156 (void)memcpy(&hci_cmd_buffer[pos], ptr, 240); 157 pos += 240; 158 break; 159 case 'N': { // UTF-8 string, null terminated 160 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 161 uint16_t len = strlen((const char*) ptr); 162 if (len > 248u) { 163 len = 248; 164 } 165 (void)memcpy(&hci_cmd_buffer[pos], ptr, len); 166 if (len < 248u) { 167 // fill remaining space with zeroes 168 memset(&hci_cmd_buffer[pos+len], 0u, 248u-len); 169 } 170 pos += 248; 171 break; 172 } 173 case 'P': // 16 byte PIN code or link key in little endian 174 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 175 (void)memcpy(&hci_cmd_buffer[pos], ptr, 16); 176 pos += 16; 177 break; 178 case 'K': // 16 byte OOB Data or Link Key in big endian 179 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 180 reverse_bytes(ptr, &hci_cmd_buffer[pos], 16); 181 pos += 16; 182 break; 183 #ifdef ENABLE_BLE 184 case 'A': // 31 bytes advertising data 185 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 186 (void)memcpy(&hci_cmd_buffer[pos], ptr, 31); 187 pos += 31; 188 break; 189 case 'J': // 8 bit variable length indicator for 'V' 190 word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE 191 var_len = word & 0xffu; 192 hci_cmd_buffer[pos++] = var_len; 193 break; 194 case 'V': 195 btstack_assert(var_len != INVALID_VAR_LEN); 196 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 197 (void)memcpy(&hci_cmd_buffer[pos], ptr, var_len); 198 pos += var_len; 199 var_len = INVALID_VAR_LEN; 200 break; 201 case 'a': 202 btstack_assert(array_num_elements == INVALID_ARRAY_LEN); 203 word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE 204 hci_cmd_buffer[pos++] = word & 0xff; 205 array_num_elements = word & 0xffu; 206 break; 207 case 'b': 208 btstack_assert(array_num_elements == INVALID_ARRAY_LEN); 209 word = va_arg(argptr, int); // LCOV_EXCL_BR_LINE 210 hci_cmd_buffer[pos++] = word & 0xff; 211 array_num_elements = count_set_bits_uint32(word & 0xffu); 212 break; 213 case '[': 214 btstack_assert(array_num_elements != INVALID_ARRAY_LEN); 215 // process array 216 format++; 217 array_format = format; 218 array_num_fields = 0; 219 done_array = false; 220 while (!done_array){ 221 switch (*format){ 222 case 0: 223 done_array = true; 224 done_format = true; 225 break; 226 case ']': 227 done_array = true; 228 break; 229 case '1': 230 case '2': 231 // all arrayed parameters are passed in as arrays 232 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 233 array_data[array_num_fields++] = ptr; 234 format++; 235 break; 236 default: 237 btstack_unreachable(); 238 break; 239 } 240 } 241 for (array_element_index = 0; array_element_index < array_num_elements ; array_element_index++){ 242 uint8_t array_field_index; 243 for (array_field_index = 0; array_field_index < array_num_fields ; array_field_index++){ 244 switch (array_format[array_field_index]){ 245 case '1': 246 hci_cmd_buffer[pos++] = ((const uint8_t *) array_data[array_field_index])[array_element_index]; 247 break; 248 case '2': 249 little_endian_store_16(hci_cmd_buffer, pos, ((const uint16_t *) array_data[array_field_index])[array_element_index]); 250 pos += 2; 251 break; 252 default: 253 btstack_unreachable(); 254 break; 255 } 256 } 257 } 258 break; 259 #endif 260 #ifdef ENABLE_LE_SECURE_CONNECTIONS 261 case 'Q': 262 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 263 reverse_bytes(ptr, &hci_cmd_buffer[pos], 32); 264 pos += 32; 265 break; 266 #endif 267 #ifdef ENABLE_SDP 268 // used by daemon 269 case 'S': { // Service Record (Data Element Sequence) 270 ptr = va_arg(argptr, uint8_t *); // LCOV_EXCL_BR_LINE 271 uint16_t len = de_get_len(ptr); 272 (void)memcpy(&hci_cmd_buffer[pos], ptr, len); 273 pos += len; 274 break; 275 } 276 #endif 277 default: 278 btstack_unreachable(); 279 break; 280 } 281 format++; 282 }; 283 hci_cmd_buffer[2] = pos - 3; 284 return pos; 285 } 286 287 /** 288 * Link Control Commands 289 */ 290 291 /** 292 * @param lap 293 * @param inquiry_length 294 * @param num_responses 295 */ 296 const hci_cmd_t hci_inquiry = { 297 HCI_OPCODE_HCI_INQUIRY, "311" 298 }; 299 300 /** 301 */ 302 const hci_cmd_t hci_inquiry_cancel = { 303 HCI_OPCODE_HCI_INQUIRY_CANCEL, "" 304 }; 305 306 /** 307 * @param bd_addr 308 * @param packet_type 309 * @param page_scan_repetition_mode 310 * @param reserved 311 * @param clock_offset 312 * @param allow_role_switch 313 */ 314 const hci_cmd_t hci_create_connection = { 315 HCI_OPCODE_HCI_CREATE_CONNECTION, "B21121" 316 }; 317 318 /** 319 * @param handle 320 * @param reason (0x05, 0x13-0x15, 0x1a, 0x29, see Errors Codes in BT Spec Part D) 321 */ 322 const hci_cmd_t hci_disconnect = { 323 HCI_OPCODE_HCI_DISCONNECT, "H1" 324 }; 325 326 /** 327 * @param bd_addr 328 */ 329 const hci_cmd_t hci_create_connection_cancel = { 330 HCI_OPCODE_HCI_CREATE_CONNECTION_CANCEL, "B" 331 }; 332 333 /** 334 * @param bd_addr 335 * @param role (become master, stay slave) 336 */ 337 const hci_cmd_t hci_accept_connection_request = { 338 HCI_OPCODE_HCI_ACCEPT_CONNECTION_REQUEST, "B1" 339 }; 340 341 /** 342 * @param bd_addr 343 * @param reason (e.g. CONNECTION REJECTED DUE TO LIMITED RESOURCES (0x0d)) 344 */ 345 const hci_cmd_t hci_reject_connection_request = { 346 HCI_OPCODE_HCI_REJECT_CONNECTION_REQUEST, "B1" 347 }; 348 349 /** 350 * @param bd_addr 351 * @param link_key 352 */ 353 const hci_cmd_t hci_link_key_request_reply = { 354 HCI_OPCODE_HCI_LINK_KEY_REQUEST_REPLY, "BP" 355 }; 356 357 /** 358 * @param bd_addr 359 */ 360 const hci_cmd_t hci_link_key_request_negative_reply = { 361 HCI_OPCODE_HCI_LINK_KEY_REQUEST_NEGATIVE_REPLY, "B" 362 }; 363 364 /** 365 * @param bd_addr 366 * @param pin_length 367 * @param pin (c-string) 368 */ 369 const hci_cmd_t hci_pin_code_request_reply = { 370 HCI_OPCODE_HCI_PIN_CODE_REQUEST_REPLY, "B1P" 371 }; 372 373 /** 374 * @param bd_addr 375 */ 376 const hci_cmd_t hci_pin_code_request_negative_reply = { 377 HCI_OPCODE_HCI_PIN_CODE_REQUEST_NEGATIVE_REPLY, "B" 378 }; 379 380 /** 381 * @param handle 382 * @param packet_type 383 */ 384 const hci_cmd_t hci_change_connection_packet_type = { 385 HCI_OPCODE_HCI_CHANGE_CONNECTION_PACKET_TYPE, "H2" 386 }; 387 388 /** 389 * @param handle 390 */ 391 const hci_cmd_t hci_authentication_requested = { 392 HCI_OPCODE_HCI_AUTHENTICATION_REQUESTED, "H" 393 }; 394 395 /** 396 * @param handle 397 * @param encryption_enable 398 */ 399 const hci_cmd_t hci_set_connection_encryption = { 400 HCI_OPCODE_HCI_SET_CONNECTION_ENCRYPTION, "H1" 401 }; 402 403 /** 404 * @param handle 405 */ 406 const hci_cmd_t hci_change_connection_link_key = { 407 HCI_OPCODE_HCI_CHANGE_CONNECTION_LINK_KEY, "H" 408 }; 409 410 /** 411 * @param bd_addr 412 * @param page_scan_repetition_mode 413 * @param reserved 414 * @param clock_offset 415 */ 416 const hci_cmd_t hci_remote_name_request = { 417 HCI_OPCODE_HCI_REMOTE_NAME_REQUEST, "B112" 418 }; 419 420 421 /** 422 * @param bd_addr 423 */ 424 const hci_cmd_t hci_remote_name_request_cancel = { 425 HCI_OPCODE_HCI_REMOTE_NAME_REQUEST_CANCEL, "B" 426 }; 427 428 /** 429 * @param handle 430 */ 431 const hci_cmd_t hci_read_remote_supported_features_command = { 432 HCI_OPCODE_HCI_READ_REMOTE_SUPPORTED_FEATURES_COMMAND, "H" 433 }; 434 435 /** 436 * @param handle 437 */ 438 const hci_cmd_t hci_read_remote_extended_features_command = { 439 HCI_OPCODE_HCI_READ_REMOTE_EXTENDED_FEATURES_COMMAND, "H1" 440 }; 441 442 /** 443 * @param handle 444 */ 445 const hci_cmd_t hci_read_remote_version_information = { 446 HCI_OPCODE_HCI_READ_REMOTE_VERSION_INFORMATION, "H" 447 }; 448 449 /** 450 * @param handle 451 * @param transmit_bandwidth 8000(64kbps) 452 * @param receive_bandwidth 8000(64kbps) 453 * @param max_latency >= 7ms for eSCO, 0xFFFF do not care 454 * @param voice_settings e.g. CVSD, Input Coding: Linear, Input Data Format: 2’s complement, data 16bit: 00011000000 == 0x60 455 * @param retransmission_effort e.g. 0xFF do not care 456 * @param packet_type at least EV3 for eSCO 457 */ 458 const hci_cmd_t hci_setup_synchronous_connection = { 459 HCI_OPCODE_HCI_SETUP_SYNCHRONOUS_CONNECTION, "H442212" 460 }; 461 462 /** 463 * @param bd_addr 464 * @param transmit_bandwidth 465 * @param receive_bandwidth 466 * @param max_latency 467 * @param voice_settings 468 * @param retransmission_effort 469 * @param packet_type 470 */ 471 const hci_cmd_t hci_accept_synchronous_connection = { 472 HCI_OPCODE_HCI_ACCEPT_SYNCHRONOUS_CONNECTION, "B442212" 473 }; 474 475 /** 476 * @param bd_addr 477 * @param IO_capability 478 * @param OOB_data_present 479 * @param authentication_requirements 480 */ 481 const hci_cmd_t hci_io_capability_request_reply = { 482 HCI_OPCODE_HCI_IO_CAPABILITY_REQUEST_REPLY, "B111" 483 }; 484 485 /** 486 * @param bd_addr 487 */ 488 const hci_cmd_t hci_user_confirmation_request_reply = { 489 HCI_OPCODE_HCI_USER_CONFIRMATION_REQUEST_REPLY, "B" 490 }; 491 492 /** 493 * @param bd_addr 494 */ 495 const hci_cmd_t hci_user_confirmation_request_negative_reply = { 496 HCI_OPCODE_HCI_USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY, "B" 497 }; 498 499 /** 500 * @param bd_addr 501 * @param numeric_value 502 */ 503 const hci_cmd_t hci_user_passkey_request_reply = { 504 HCI_OPCODE_HCI_USER_PASSKEY_REQUEST_REPLY, "B4" 505 }; 506 507 /** 508 * @param bd_addr 509 */ 510 const hci_cmd_t hci_user_passkey_request_negative_reply = { 511 HCI_OPCODE_HCI_USER_PASSKEY_REQUEST_NEGATIVE_REPLY, "B" 512 }; 513 514 /** 515 * @param bd_addr 516 * @param c Simple Pairing Hash C 517 * @param r Simple Pairing Randomizer R 518 */ 519 const hci_cmd_t hci_remote_oob_data_request_reply = { 520 HCI_OPCODE_HCI_REMOTE_OOB_DATA_REQUEST_REPLY, "BKK" 521 }; 522 523 /** 524 * @param bd_addr 525 */ 526 const hci_cmd_t hci_remote_oob_data_request_negative_reply = { 527 HCI_OPCODE_HCI_REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY, "B" 528 }; 529 530 /** 531 * @param bd_addr 532 * @param reason (Part D, Error codes) 533 */ 534 const hci_cmd_t hci_io_capability_request_negative_reply = { 535 HCI_OPCODE_HCI_IO_CAPABILITY_REQUEST_NEGATIVE_REPLY, "B1" 536 }; 537 538 /** 539 * @param handle 540 * @param transmit_bandwidth 541 * @param receive_bandwidth 542 * @param transmit_coding_format_type 543 * @param transmit_coding_format_company 544 * @param transmit_coding_format_codec 545 * @param receive_coding_format_type 546 * @param receive_coding_format_company 547 * @param receive_coding_format_codec 548 * @param transmit_coding_frame_size 549 * @param receive_coding_frame_size 550 * @param input_bandwidth 551 * @param output_bandwidth 552 * @param input_coding_format_type 553 * @param input_coding_format_company 554 * @param input_coding_format_codec 555 * @param output_coding_format_type 556 * @param output_coding_format_company 557 * @param output_coding_format_codec 558 * @param input_coded_data_size 559 * @param outupt_coded_data_size 560 * @param input_pcm_data_format 561 * @param output_pcm_data_format 562 * @param input_pcm_sample_payload_msb_position 563 * @param output_pcm_sample_payload_msb_position 564 * @param input_data_path 565 * @param output_data_path 566 * @param input_transport_unit_size 567 * @param output_transport_unit_size 568 * @param max_latency 569 * @param packet_type 570 * @param retransmission_effort 571 */ 572 const hci_cmd_t hci_enhanced_setup_synchronous_connection = { 573 HCI_OPCODE_HCI_ENHANCED_SETUP_SYNCHRONOUS_CONNECTION, "H4412212222441221222211111111221" 574 }; 575 576 /** 577 * @param bd_addr 578 * @param transmit_bandwidth 579 * @param receive_bandwidth 580 * @param transmit_coding_format_type 581 * @param transmit_coding_format_company 582 * @param transmit_coding_format_codec 583 * @param receive_coding_format_type 584 * @param receive_coding_format_company 585 * @param receive_coding_format_codec 586 * @param transmit_coding_frame_size 587 * @param receive_coding_frame_size 588 * @param input_bandwidth 589 * @param output_bandwidth 590 * @param input_coding_format_type 591 * @param input_coding_format_company 592 * @param input_coding_format_codec 593 * @param output_coding_format_type 594 * @param output_coding_format_company 595 * @param output_coding_format_codec 596 * @param input_coded_data_size 597 * @param outupt_coded_data_size 598 * @param input_pcm_data_format 599 * @param output_pcm_data_format 600 * @param input_pcm_sample_payload_msb_position 601 * @param output_pcm_sample_payload_msb_position 602 * @param input_data_path 603 * @param output_data_path 604 * @param input_transport_unit_size 605 * @param output_transport_unit_size 606 * @param max_latency 607 * @param packet_type 608 * @param retransmission_effort 609 */ 610 const hci_cmd_t hci_enhanced_accept_synchronous_connection = { 611 HCI_OPCODE_HCI_ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION, "B4412212222441221222211111111221" 612 }; 613 614 /** 615 * @param bd_addr 616 * @param c_192 Simple Pairing Hash C derived from P-192 public key 617 * @param r_192 Simple Pairing Randomizer derived from P-192 public key 618 * @param c_256 Simple Pairing Hash C derived from P-256 public key 619 * @param r_256 Simple Pairing Randomizer derived from P-256 public key 620 */ 621 const hci_cmd_t hci_remote_oob_extended_data_request_reply = { 622 HCI_OPCODE_HCI_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY, "BKKKK" 623 }; 624 625 /** 626 * Link Policy Commands 627 */ 628 629 /** 630 * @param handle 631 * @param sniff_max_interval 632 * @param sniff_min_interval 633 * @param sniff_attempt 634 * @param sniff_timeout 635 */ 636 const hci_cmd_t hci_sniff_mode = { 637 HCI_OPCODE_HCI_SNIFF_MODE, "H2222" 638 }; 639 640 /** 641 * @param handle 642 */ 643 const hci_cmd_t hci_exit_sniff_mode = { 644 HCI_OPCODE_HCI_EXIT_SNIFF_MODE, "H" 645 }; 646 647 /** 648 * @param handle 649 * @param flags 650 * @param service_type 651 * @param token_rate (bytes/s) 652 * @param peak_bandwith (bytes/s) 653 * @param latency (us) 654 * @param delay_variation (us) 655 */ 656 const hci_cmd_t hci_qos_setup = { 657 HCI_OPCODE_HCI_QOS_SETUP, "H114444" 658 }; 659 660 /** 661 * @param handle 662 */ 663 const hci_cmd_t hci_role_discovery = { 664 HCI_OPCODE_HCI_ROLE_DISCOVERY, "H" 665 }; 666 667 /** 668 * @param bd_addr 669 * @param role (0=master,1=slave) 670 */ 671 const hci_cmd_t hci_switch_role_command= { 672 HCI_OPCODE_HCI_SWITCH_ROLE_COMMAND, "B1" 673 }; 674 675 /** 676 * @param handle 677 */ 678 const hci_cmd_t hci_read_link_policy_settings = { 679 HCI_OPCODE_HCI_READ_LINK_POLICY_SETTINGS, "H" 680 }; 681 682 /** 683 * @param handle 684 * @param settings 685 */ 686 const hci_cmd_t hci_write_link_policy_settings = { 687 HCI_OPCODE_HCI_WRITE_LINK_POLICY_SETTINGS, "H2" 688 }; 689 690 /** 691 * @param handle 692 * @param max_latency 693 * @param min_remote_timeout 694 * @param min_local_timeout 695 */ 696 const hci_cmd_t hci_sniff_subrating = { 697 HCI_OPCODE_HCI_SNIFF_SUBRATING, "H222" 698 }; 699 700 /** 701 * @param policy 702 */ 703 const hci_cmd_t hci_write_default_link_policy_setting = { 704 HCI_OPCODE_HCI_WRITE_DEFAULT_LINK_POLICY_SETTING, "2" 705 }; 706 707 /** 708 * @param handle 709 * @param unused 710 * @param flow_direction 711 * @param service_type 712 * @param token_rate 713 * @param token_bucket_size 714 * @param peak_bandwidth 715 * @param access_latency 716 */ 717 const hci_cmd_t hci_flow_specification = { 718 HCI_OPCODE_HCI_FLOW_SPECIFICATION, "H1114444" 719 }; 720 721 722 /** 723 * Controller & Baseband Commands 724 */ 725 726 727 /** 728 * @param event_mask_lover_octets 729 * @param event_mask_higher_octets 730 */ 731 const hci_cmd_t hci_set_event_mask = { 732 HCI_OPCODE_HCI_SET_EVENT_MASK, "44" 733 }; 734 735 /** 736 */ 737 const hci_cmd_t hci_reset = { 738 HCI_OPCODE_HCI_RESET, "" 739 }; 740 741 /** 742 * @param handle 743 */ 744 const hci_cmd_t hci_flush = { 745 HCI_OPCODE_HCI_FLUSH, "H" 746 }; 747 748 /** 749 * @param handle 750 */ 751 const hci_cmd_t hci_read_pin_type = { 752 HCI_OPCODE_HCI_READ_PIN_TYPE, "" 753 }; 754 755 /** 756 * @param handle 757 */ 758 const hci_cmd_t hci_write_pin_type = { 759 HCI_OPCODE_HCI_WRITE_PIN_TYPE, "1" 760 }; 761 762 /** 763 * @param bd_addr 764 * @param delete_all_flags 765 */ 766 const hci_cmd_t hci_delete_stored_link_key = { 767 HCI_OPCODE_HCI_DELETE_STORED_LINK_KEY, "B1" 768 }; 769 770 #ifdef ENABLE_CLASSIC 771 /** 772 * @param local_name (UTF-8, Null Terminated, max 248 octets) 773 */ 774 const hci_cmd_t hci_write_local_name = { 775 HCI_OPCODE_HCI_WRITE_LOCAL_NAME, "N" 776 }; 777 #endif 778 779 /** 780 */ 781 const hci_cmd_t hci_read_local_name = { 782 HCI_OPCODE_HCI_READ_LOCAL_NAME, "" 783 }; 784 785 /** 786 */ 787 const hci_cmd_t hci_read_page_timeout = { 788 HCI_OPCODE_HCI_READ_PAGE_TIMEOUT, "" 789 }; 790 791 /** 792 * @param page_timeout (* 0.625 ms) 793 */ 794 const hci_cmd_t hci_write_page_timeout = { 795 HCI_OPCODE_HCI_WRITE_PAGE_TIMEOUT, "2" 796 }; 797 798 /** 799 * @param scan_enable (no, inq, page, inq+page) 800 */ 801 const hci_cmd_t hci_write_scan_enable = { 802 HCI_OPCODE_HCI_WRITE_SCAN_ENABLE, "1" 803 }; 804 805 /** 806 */ 807 const hci_cmd_t hci_read_page_scan_activity = { 808 HCI_OPCODE_HCI_READ_PAGE_SCAN_ACTIVITY, "" 809 }; 810 811 /** 812 * @param page_scan_interval (* 0.625 ms) 813 * @param page_scan_window (* 0.625 ms, must be <= page_scan_interval) 814 */ 815 const hci_cmd_t hci_write_page_scan_activity = { 816 HCI_OPCODE_HCI_WRITE_PAGE_SCAN_ACTIVITY, "22" 817 }; 818 819 /** 820 */ 821 const hci_cmd_t hci_read_inquiry_scan_activity = { 822 HCI_OPCODE_HCI_READ_INQUIRY_SCAN_ACTIVITY, "" 823 }; 824 825 /** 826 * @param inquiry_scan_interval (* 0.625 ms) 827 * @param inquiry_scan_window (* 0.625 ms, must be <= inquiry_scan_interval) 828 */ 829 const hci_cmd_t hci_write_inquiry_scan_activity = { 830 HCI_OPCODE_HCI_WRITE_INQUIRY_SCAN_ACTIVITY, "22" 831 }; 832 833 /** 834 * @param authentication_enable 835 */ 836 const hci_cmd_t hci_write_authentication_enable = { 837 HCI_OPCODE_HCI_WRITE_AUTHENTICATION_ENABLE, "1" 838 }; 839 840 /** 841 * @param class_of_device 842 */ 843 const hci_cmd_t hci_write_class_of_device = { 844 HCI_OPCODE_HCI_WRITE_CLASS_OF_DEVICE, "3" 845 }; 846 847 /** 848 */ 849 const hci_cmd_t hci_read_num_broadcast_retransmissions = { 850 HCI_OPCODE_HCI_READ_NUM_BROADCAST_RETRANSMISSIONS, "" 851 }; 852 853 /** 854 * @param num_broadcast_retransmissions (e.g. 0 for a single broadcast) 855 */ 856 const hci_cmd_t hci_write_num_broadcast_retransmissions = { 857 HCI_OPCODE_HCI_WRITE_NUM_BROADCAST_RETRANSMISSIONS, "1" 858 }; 859 860 /** 861 * @param connection_handle 862 * @param type 0 = current transmit level, 1 = max transmit level 863 */ 864 const hci_cmd_t hci_read_transmit_power_level = { 865 HCI_OPCODE_HCI_READ_TRANSMIT_POWER_LEVEL, "11" 866 }; 867 868 /** 869 * @param synchronous_flow_control_enable - if yes, num completed packet everts are sent for SCO packets 870 */ 871 const hci_cmd_t hci_write_synchronous_flow_control_enable = { 872 HCI_OPCODE_HCI_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE, "1" 873 }; 874 875 #ifdef ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL 876 877 /** 878 * @param flow_control_enable - 0: off, 1: ACL only, 2: SCO only, 3: ACL + SCO 879 */ 880 const hci_cmd_t hci_set_controller_to_host_flow_control = { 881 HCI_OPCODE_HCI_SET_CONTROLLER_TO_HOST_FLOW_CONTROL, "1" 882 }; 883 884 /** 885 * @param host_acl_data_packet_length 886 * @param host_synchronous_data_packet_length 887 * @param host_total_num_acl_data_packets 888 * @param host_total_num_synchronous_data_packets 889 */ 890 const hci_cmd_t hci_host_buffer_size = { 891 HCI_OPCODE_HCI_HOST_BUFFER_SIZE, "2122" 892 }; 893 894 895 #if 0 896 // 897 // command sent manually sent by hci_host_num_completed_packets 898 // 899 /** 900 * @note only single handle supported by BTstack command generator 901 * @param number_of_handles must be 1 902 * @param connection_handle 903 * @param host_num_of_completed_packets for the given connection handle 904 */ 905 const hci_cmd_t hci_host_number_of_completed_packets = { 906 HCI_OPCODE_HCI_HOST_NUMBER_OF_COMPLETED_PACKETS, "1H2" 907 }; 908 #endif 909 910 #endif 911 912 /** 913 * @param handle 914 */ 915 const hci_cmd_t hci_read_link_supervision_timeout = { 916 HCI_OPCODE_HCI_READ_LINK_SUPERVISION_TIMEOUT, "H" 917 }; 918 919 /** 920 * @param handle 921 * @param timeout (0x0001 - 0xFFFF Time -> Range: 0.625ms - 40.9 sec) 922 */ 923 const hci_cmd_t hci_write_link_supervision_timeout = { 924 HCI_OPCODE_HCI_WRITE_LINK_SUPERVISION_TIMEOUT, "H2" 925 }; 926 927 /** 928 * @param num_current_iac must be 2 929 * @param iac_lap1 930 * @param iac_lap2 931 */ 932 const hci_cmd_t hci_write_current_iac_lap_two_iacs = { 933 HCI_OPCODE_HCI_WRITE_CURRENT_IAC_LAP_TWO_IACS, "133" 934 }; 935 936 /** 937 * @param inquiry_scan_type (0x00 = standard, 0x01 = interlaced) 938 */ 939 const hci_cmd_t hci_write_inquiry_scan_type = { 940 HCI_OPCODE_HCI_WRITE_INQUIRY_SCAN_TYPE, "1" 941 }; 942 943 /** 944 * @param inquiry_mode (0x00 = standard, 0x01 = with RSSI, 0x02 = extended) 945 */ 946 const hci_cmd_t hci_write_inquiry_mode = { 947 HCI_OPCODE_HCI_WRITE_INQUIRY_MODE, "1" 948 }; 949 950 /** 951 * @param page_scan_type (0x00 = standard, 0x01 = interlaced) 952 */ 953 const hci_cmd_t hci_write_page_scan_type = { 954 HCI_OPCODE_HCI_WRITE_PAGE_SCAN_TYPE, "1" 955 }; 956 957 /** 958 * @param fec_required 959 * @param exstended_inquiry_response 960 */ 961 const hci_cmd_t hci_write_extended_inquiry_response = { 962 HCI_OPCODE_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE, "1E" 963 }; 964 965 /** 966 * @param mode (0 = off, 1 = on) 967 */ 968 const hci_cmd_t hci_write_simple_pairing_mode = { 969 HCI_OPCODE_HCI_WRITE_SIMPLE_PAIRING_MODE, "1" 970 }; 971 972 /** 973 */ 974 const hci_cmd_t hci_read_local_oob_data = { 975 HCI_OPCODE_HCI_READ_LOCAL_OOB_DATA, "" 976 // return status, C, R 977 }; 978 979 /** 980 * @param mode (0 = off, 1 = on) 981 */ 982 const hci_cmd_t hci_write_default_erroneous_data_reporting = { 983 HCI_OPCODE_HCI_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING, "1" 984 }; 985 986 /** 987 */ 988 const hci_cmd_t hci_read_le_host_supported = { 989 HCI_OPCODE_HCI_READ_LE_HOST_SUPPORTED, "" 990 // return: status, le supported host, simultaneous le host 991 }; 992 993 /** 994 * @param le_supported_host 995 * @param simultaneous_le_host 996 */ 997 const hci_cmd_t hci_write_le_host_supported = { 998 HCI_OPCODE_HCI_WRITE_LE_HOST_SUPPORTED, "11" 999 // return: status 1000 }; 1001 1002 /** 1003 * @param secure_connections_host_support 1004 */ 1005 const hci_cmd_t hci_write_secure_connections_host_support = { 1006 HCI_OPCODE_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT, "1" 1007 // return: status 1008 }; 1009 1010 /** 1011 */ 1012 const hci_cmd_t hci_read_local_extended_oob_data = { 1013 HCI_OPCODE_HCI_READ_LOCAL_EXTENDED_OOB_DATA, "" 1014 // return status, C_192, R_192, R_256, C_256 1015 }; 1016 1017 1018 /** 1019 * Testing Commands 1020 */ 1021 1022 1023 /** 1024 */ 1025 const hci_cmd_t hci_read_loopback_mode = { 1026 HCI_OPCODE_HCI_READ_LOOPBACK_MODE, "" 1027 // return: status, loopback mode (0 = off, 1 = local loopback, 2 = remote loopback) 1028 }; 1029 1030 /** 1031 * @param loopback_mode 1032 */ 1033 const hci_cmd_t hci_write_loopback_mode = { 1034 HCI_OPCODE_HCI_WRITE_LOOPBACK_MODE, "1" 1035 // return: status 1036 }; 1037 1038 /** 1039 */ 1040 const hci_cmd_t hci_enable_device_under_test_mode = { 1041 HCI_OPCODE_HCI_ENABLE_DEVICE_UNDER_TEST_MODE, "" 1042 // return: status 1043 }; 1044 1045 /** 1046 * @param simple_pairing_debug_mode 1047 */ 1048 const hci_cmd_t hci_write_simple_pairing_debug_mode = { 1049 HCI_OPCODE_HCI_WRITE_SIMPLE_PAIRING_DEBUG_MODE, "1" 1050 // return: status 1051 }; 1052 1053 /** 1054 * @param handle 1055 * @param dm1_acl_u_mode 1056 * @param esco_loopback_mode 1057 */ 1058 const hci_cmd_t hci_write_secure_connections_test_mode = { 1059 HCI_OPCODE_HCI_WRITE_SECURE_CONNECTIONS_TEST_MODE, "H11" 1060 // return: status 1061 }; 1062 1063 1064 /** 1065 * Informational Parameters 1066 */ 1067 1068 const hci_cmd_t hci_read_local_version_information = { 1069 HCI_OPCODE_HCI_READ_LOCAL_VERSION_INFORMATION, "" 1070 }; 1071 const hci_cmd_t hci_read_local_supported_commands = { 1072 HCI_OPCODE_HCI_READ_LOCAL_SUPPORTED_COMMANDS, "" 1073 }; 1074 const hci_cmd_t hci_read_local_supported_features = { 1075 HCI_OPCODE_HCI_READ_LOCAL_SUPPORTED_FEATURES, "" 1076 }; 1077 const hci_cmd_t hci_read_buffer_size = { 1078 HCI_OPCODE_HCI_READ_BUFFER_SIZE, "" 1079 }; 1080 const hci_cmd_t hci_read_bd_addr = { 1081 HCI_OPCODE_HCI_READ_BD_ADDR, "" 1082 }; 1083 1084 /** 1085 * Status Paramters 1086 */ 1087 1088 /** 1089 * @param handle 1090 */ 1091 const hci_cmd_t hci_read_rssi = { 1092 HCI_OPCODE_HCI_READ_RSSI, "H" 1093 }; 1094 1095 /** 1096 * @param handle 1097 */ 1098 const hci_cmd_t hci_read_encryption_key_size = { 1099 HCI_OPCODE_HCI_READ_ENCRYPTION_KEY_SIZE, "H" 1100 }; 1101 1102 1103 #ifdef ENABLE_BLE 1104 /** 1105 * Low Energy Commands 1106 */ 1107 1108 /** 1109 * @param event_mask_lower_octets 1110 * @param event_mask_higher_octets 1111 */ 1112 const hci_cmd_t hci_le_set_event_mask = { 1113 HCI_OPCODE_HCI_LE_SET_EVENT_MASK, "44" 1114 // return: status 1115 }; 1116 1117 const hci_cmd_t hci_le_read_buffer_size = { 1118 HCI_OPCODE_HCI_LE_READ_BUFFER_SIZE, "" 1119 // return: status, le acl data packet len (16), total num le acl data packets(8) 1120 }; 1121 const hci_cmd_t hci_le_read_local_supported_features = { 1122 HCI_OPCODE_HCI_LE_READ_LOCAL_SUPPORTED_FEATURES, "" 1123 // return: LE_Features See [Vol 6] Part B, Section 4.6 1124 }; 1125 1126 /** 1127 * @param random_bd_addr 1128 */ 1129 const hci_cmd_t hci_le_set_random_address = { 1130 HCI_OPCODE_HCI_LE_SET_RANDOM_ADDRESS, "B" 1131 // return: status 1132 }; 1133 1134 /** 1135 * @param advertising_interval_min ([0x0020,0x4000], default: 0x0800, unit: 0.625 msec) 1136 * @param advertising_interval_max ([0x0020,0x4000], default: 0x0800, unit: 0.625 msec) 1137 * @param advertising_type (enum from 0: ADV_IND, ADC_DIRECT_IND, ADV_SCAN_IND, ADV_NONCONN_IND) 1138 * @param own_address_type (enum from 0: public device address, random device address) 1139 * @param direct_address_type () 1140 * @param direct_address (public or random address of device to be connecteed) 1141 * @param advertising_channel_map (flags: chan_37(1), chan_38(2), chan_39(4)) 1142 * @param advertising_filter_policy (enum from 0: scan any conn any, scan whitelist, con any, scan any conn whitelist, scan whitelist, con whitelist) 1143 */ 1144 const hci_cmd_t hci_le_set_advertising_parameters = { 1145 HCI_OPCODE_HCI_LE_SET_ADVERTISING_PARAMETERS, "22111B11" 1146 // return: status 1147 }; 1148 1149 const hci_cmd_t hci_le_read_advertising_channel_tx_power = { 1150 HCI_OPCODE_HCI_LE_READ_ADVERTISING_CHANNEL_TX_POWER, "" 1151 // return: status, level [-20,10] signed int (8), units dBm 1152 }; 1153 1154 /** 1155 * @param advertising_data_length 1156 * @param advertising_data (31 bytes) 1157 */ 1158 const hci_cmd_t hci_le_set_advertising_data= { 1159 HCI_OPCODE_HCI_LE_SET_ADVERTISING_DATA, "1A" 1160 // return: status 1161 }; 1162 1163 /** 1164 * @param scan_response_data_length 1165 * @param scan_response_data (31 bytes) 1166 */ 1167 const hci_cmd_t hci_le_set_scan_response_data= { 1168 HCI_OPCODE_HCI_LE_SET_SCAN_RESPONSE_DATA, "1A" 1169 // return: status 1170 }; 1171 1172 /** 1173 * @param advertise_enable (off: 0, on: 1) 1174 */ 1175 const hci_cmd_t hci_le_set_advertise_enable = { 1176 HCI_OPCODE_HCI_LE_SET_ADVERTISE_ENABLE, "1" 1177 // return: status 1178 }; 1179 1180 /** 1181 * @param le_scan_type (passive (0), active (1)) 1182 * @param le_scan_interval ([0x0004,0x4000], unit: 0.625 msec) 1183 * @param le_scan_window ([0x0004,0x4000], unit: 0.625 msec) 1184 * @param own_address_type (public (0), random (1)) 1185 * @param scanning_filter_policy (any (0), only whitelist (1)) 1186 */ 1187 const hci_cmd_t hci_le_set_scan_parameters = { 1188 HCI_OPCODE_HCI_LE_SET_SCAN_PARAMETERS, "12211" 1189 // return: status 1190 }; 1191 1192 /** 1193 * @param le_scan_enable (disabled (0), enabled (1)) 1194 * @param filter_duplices (disabled (0), enabled (1)) 1195 */ 1196 const hci_cmd_t hci_le_set_scan_enable = { 1197 HCI_OPCODE_HCI_LE_SET_SCAN_ENABLE, "11" 1198 // return: status 1199 }; 1200 1201 /** 1202 * @param le_scan_interval ([0x0004, 0x4000], unit: 0.625 msec) 1203 * @param le_scan_window ([0x0004, 0x4000], unit: 0.625 msec) 1204 * @param initiator_filter_policy (peer address type + peer address (0), whitelist (1)) 1205 * @param peer_address_type (public (0), random (1)) 1206 * @param peer_address 1207 * @param own_address_type (public (0), random (1)) 1208 * @param conn_interval_min ([0x0006, 0x0c80], unit: 1.25 msec) 1209 * @param conn_interval_max ([0x0006, 0x0c80], unit: 1.25 msec) 1210 * @param conn_latency (number of connection events [0x0000, 0x01f4]) 1211 * @param supervision_timeout ([0x000a, 0x0c80], unit: 10 msec) 1212 * @param minimum_CE_length ([0x0000, 0xffff], unit: 0.625 msec) 1213 * @param maximum_CE_length ([0x0000, 0xffff], unit: 0.625 msec) 1214 */ 1215 const hci_cmd_t hci_le_create_connection= { 1216 HCI_OPCODE_HCI_LE_CREATE_CONNECTION, "2211B1222222" 1217 // return: none -> le create connection complete event 1218 }; 1219 1220 const hci_cmd_t hci_le_create_connection_cancel = { 1221 HCI_OPCODE_HCI_LE_CREATE_CONNECTION_CANCEL, "" 1222 // return: status 1223 }; 1224 1225 const hci_cmd_t hci_le_read_white_list_size = { 1226 HCI_OPCODE_HCI_LE_READ_WHITE_LIST_SIZE, "" 1227 // return: status, number of entries in controller whitelist 1228 }; 1229 1230 const hci_cmd_t hci_le_clear_white_list = { 1231 HCI_OPCODE_HCI_LE_CLEAR_WHITE_LIST, "" 1232 // return: status 1233 }; 1234 1235 /** 1236 * @param address_type (public (0), random (1)) 1237 * @param bd_addr 1238 */ 1239 const hci_cmd_t hci_le_add_device_to_white_list = { 1240 HCI_OPCODE_HCI_LE_ADD_DEVICE_TO_WHITE_LIST, "1B" 1241 // return: status 1242 }; 1243 1244 /** 1245 * @param address_type (public (0), random (1)) 1246 * @param bd_addr 1247 */ 1248 const hci_cmd_t hci_le_remove_device_from_white_list = { 1249 HCI_OPCODE_HCI_LE_REMOVE_DEVICE_FROM_WHITE_LIST, "1B" 1250 // return: status 1251 }; 1252 1253 /** 1254 * @param conn_handle 1255 * @param conn_interval_min ([0x0006,0x0c80], unit: 1.25 msec) 1256 * @param conn_interval_max ([0x0006,0x0c80], unit: 1.25 msec) 1257 * @param conn_latency ([0x0000,0x03e8], number of connection events) 1258 * @param supervision_timeout ([0x000a,0x0c80], unit: 10 msec) 1259 * @param minimum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1260 * @param maximum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1261 */ 1262 const hci_cmd_t hci_le_connection_update = { 1263 HCI_OPCODE_HCI_LE_CONNECTION_UPDATE, "H222222" 1264 // return: none -> le connection update complete event 1265 }; 1266 1267 /** 1268 * @param channel_map_lower_32bits 1269 * @param channel_map_higher_5bits 1270 */ 1271 const hci_cmd_t hci_le_set_host_channel_classification = { 1272 HCI_OPCODE_HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION, "41" 1273 // return: status 1274 }; 1275 1276 /** 1277 * @param conn_handle 1278 */ 1279 const hci_cmd_t hci_le_read_channel_map = { 1280 HCI_OPCODE_HCI_LE_READ_CHANNEL_MAP, "H" 1281 // return: status, connection handle, channel map (5 bytes, 37 used) 1282 }; 1283 1284 /** 1285 * @param conn_handle 1286 */ 1287 const hci_cmd_t hci_le_read_remote_used_features = { 1288 HCI_OPCODE_HCI_LE_READ_REMOTE_USED_FEATURES, "H" 1289 // return: none -> le read remote used features complete event 1290 }; 1291 1292 /** 1293 * @param key ((128) for AES-128) 1294 * @param plain_text (128) 1295 */ 1296 const hci_cmd_t hci_le_encrypt = { 1297 HCI_OPCODE_HCI_LE_ENCRYPT, "PP" 1298 // return: status, encrypted data (128) 1299 }; 1300 1301 const hci_cmd_t hci_le_rand = { 1302 HCI_OPCODE_HCI_LE_RAND, "" 1303 // return: status, random number (64) 1304 }; 1305 1306 /** 1307 * @param conn_handle 1308 * @param random_number_lower_32bits 1309 * @param random_number_higher_32bits 1310 * @param encryption_diversifier (16) 1311 * @param long_term_key (128) 1312 */ 1313 const hci_cmd_t hci_le_start_encryption = { 1314 HCI_OPCODE_HCI_LE_START_ENCRYPTION, "H442P" 1315 // return: none -> encryption changed or encryption key refresh complete event 1316 }; 1317 1318 /** 1319 * @param connection_handle 1320 * @param long_term_key (128) 1321 */ 1322 const hci_cmd_t hci_le_long_term_key_request_reply = { 1323 HCI_OPCODE_HCI_LE_LONG_TERM_KEY_REQUEST_REPLY, "HP" 1324 // return: status, connection handle 1325 }; 1326 1327 /** 1328 * @param conn_handle 1329 */ 1330 const hci_cmd_t hci_le_long_term_key_negative_reply = { 1331 HCI_OPCODE_HCI_LE_LONG_TERM_KEY_NEGATIVE_REPLY, "H" 1332 // return: status, connection handle 1333 }; 1334 1335 /** 1336 * @param conn_handle 1337 */ 1338 const hci_cmd_t hci_le_read_supported_states = { 1339 HCI_OPCODE_HCI_LE_READ_SUPPORTED_STATES, "H" 1340 // return: status, LE states (64) 1341 }; 1342 1343 /** 1344 * @param rx_frequency ([0x00 0x27], frequency (MHz): 2420 + N*2) 1345 */ 1346 const hci_cmd_t hci_le_receiver_test = { 1347 HCI_OPCODE_HCI_LE_RECEIVER_TEST, "1" 1348 // return: status 1349 }; 1350 1351 /** 1352 * @param tx_frequency ([0x00 0x27], frequency (MHz): 2420 + N*2) 1353 * @param test_payload_lengh ([0x00,0x25]) 1354 * @param packet_payload ([0,7] different patterns) 1355 */ 1356 const hci_cmd_t hci_le_transmitter_test = { 1357 HCI_OPCODE_HCI_LE_TRANSMITTER_TEST, "111" 1358 // return: status 1359 }; 1360 1361 /** 1362 * @param end_test_cmd 1363 */ 1364 const hci_cmd_t hci_le_test_end = { 1365 HCI_OPCODE_HCI_LE_TEST_END, "1" 1366 // return: status, number of packets (8) 1367 }; 1368 1369 /** 1370 * @param conn_handle 1371 * @param conn_interval_min ([0x0006,0x0c80], unit: 1.25 msec) 1372 * @param conn_interval_max ([0x0006,0x0c80], unit: 1.25 msec) 1373 * @param conn_latency ([0x0000,0x03e8], number of connection events) 1374 * @param supervision_timeout ([0x000a,0x0c80], unit: 10 msec) 1375 * @param minimum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1376 * @param maximum_CE_length ([0x0000,0xffff], unit: 0.625 msec) 1377 */ 1378 const hci_cmd_t hci_le_remote_connection_parameter_request_reply = { 1379 HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY, "H222222" 1380 // return: status, connection handle 1381 }; 1382 1383 /** 1384 * @param con_handle 1385 * @param reason 1386 */ 1387 const hci_cmd_t hci_le_remote_connection_parameter_request_negative_reply = { 1388 HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY, "H1" 1389 // return: status, connection handle 1390 }; 1391 1392 /** 1393 * @param con_handle 1394 * @param tx_octets 1395 * @param tx_time 1396 */ 1397 const hci_cmd_t hci_le_set_data_length = { 1398 HCI_OPCODE_HCI_LE_SET_DATA_LENGTH, "H22" 1399 // return: status, connection handle 1400 }; 1401 1402 /** 1403 */ 1404 const hci_cmd_t hci_le_read_suggested_default_data_length = { 1405 HCI_OPCODE_HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH, "" 1406 // return: status, suggested max tx octets, suggested max tx time 1407 }; 1408 1409 /** 1410 * @param suggested_max_tx_octets 1411 * @param suggested_max_tx_time 1412 */ 1413 const hci_cmd_t hci_le_write_suggested_default_data_length = { 1414 HCI_OPCODE_HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH, "22" 1415 // return: status 1416 }; 1417 1418 /** 1419 */ 1420 const hci_cmd_t hci_le_read_local_p256_public_key = { 1421 HCI_OPCODE_HCI_LE_READ_LOCAL_P256_PUBLIC_KEY, "" 1422 // LE Read Local P-256 Public Key Complete is generated on completion 1423 }; 1424 1425 /** 1426 * @param public key 1427 * @param private key 1428 */ 1429 const hci_cmd_t hci_le_generate_dhkey = { 1430 HCI_OPCODE_HCI_LE_GENERATE_DHKEY, "QQ" 1431 // LE Generate DHKey Complete is generated on completion 1432 }; 1433 1434 /** 1435 * @param Peer_Identity_Address_Type 1436 * @param Peer_Identity_Address 1437 * @param Peer_IRK 1438 * @param Local_IRK 1439 */ 1440 const hci_cmd_t hci_le_add_device_to_resolving_list = { 1441 HCI_OPCODE_HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST, "1BPP" 1442 }; 1443 1444 /** 1445 * @param Peer_Identity_Address_Type 1446 * @param Peer_Identity_Address 1447 */ 1448 const hci_cmd_t hci_le_remove_device_from_resolving_list = { 1449 HCI_OPCODE_HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST, "1B" 1450 }; 1451 1452 /** 1453 */ 1454 const hci_cmd_t hci_le_clear_resolving_list = { 1455 HCI_OPCODE_HCI_LE_CLEAR_RESOLVING_LIST, "" 1456 }; 1457 1458 /** 1459 */ 1460 const hci_cmd_t hci_le_read_resolving_list_size = { 1461 HCI_OPCODE_HCI_LE_READ_RESOLVING_LIST_SIZE, "" 1462 }; 1463 1464 /** 1465 * @param Peer_Identity_Address_Type 1466 * @param Peer_Identity_Address 1467 */ 1468 const hci_cmd_t hci_le_read_peer_resolvable_address = { 1469 HCI_OPCODE_HCI_LE_READ_PEER_RESOLVABLE_ADDRESS, "" 1470 }; 1471 1472 /** 1473 * @param Peer_Identity_Address_Type 1474 * @param Peer_Identity_Address 1475 */ 1476 const hci_cmd_t hci_le_read_local_resolvable_address = { 1477 HCI_OPCODE_HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS, "" 1478 }; 1479 1480 /** 1481 * @param Address_Resolution_Enable 1482 */ 1483 const hci_cmd_t hci_le_set_address_resolution_enabled= { 1484 HCI_OPCODE_HCI_LE_SET_ADDRESS_RESOLUTION_ENABLED, "1" 1485 }; 1486 1487 /** 1488 * @param RPA_Timeout in seconds, range 0x0001 to 0x0E10, default: 900 s 1489 */ 1490 const hci_cmd_t hci_le_set_resolvable_private_address_timeout= { 1491 HCI_OPCODE_HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT, "2" 1492 }; 1493 1494 /** 1495 */ 1496 const hci_cmd_t hci_le_read_maximum_data_length = { 1497 HCI_OPCODE_HCI_LE_READ_MAXIMUM_DATA_LENGTH, "" 1498 // return: status, supported max tx octets, supported max tx time, supported max rx octets, supported max rx time 1499 }; 1500 1501 /** 1502 * @param con_handle 1503 */ 1504 const hci_cmd_t hci_le_read_phy = { 1505 HCI_OPCODE_HCI_LE_READ_PHY, "H" 1506 // return: status, connection handler, tx phy, rx phy 1507 }; 1508 1509 /** 1510 * @param all_phys 1511 * @param tx_phys 1512 * @param rx_phys 1513 */ 1514 const hci_cmd_t hci_le_set_default_phy = { 1515 HCI_OPCODE_HCI_LE_SET_DEFAULT_PHY, "111" 1516 // return: status 1517 }; 1518 1519 /** 1520 * @param con_handle 1521 * @param all_phys 1522 * @param tx_phys 1523 * @param rx_phys 1524 * @param phy_options 1525 */ 1526 const hci_cmd_t hci_le_set_phy = { 1527 HCI_OPCODE_HCI_LE_SET_PHY, "H1111" 1528 // LE PHY Update Complete is generated on completion 1529 }; 1530 1531 /** 1532 * @param rx_channel 1533 * @param phy 1534 * @param modulation_index 1535 */ 1536 const hci_cmd_t hci_le_receiver_test_v2 = { 1537 HCI_OPCODE_HCI_LE_RECEIVER_TEST_V2, "111" 1538 }; 1539 1540 /** 1541 * @param tx_channel 1542 * @param test_data_length 1543 * @param packet_payload 1544 * @param phy 1545 */ 1546 const hci_cmd_t hci_le_transmitter_test_v2 = { 1547 HCI_OPCODE_HCI_LE_TRANSMITTER_TEST_V2, "1111" 1548 }; 1549 1550 /** 1551 * @param advertising_handle 1552 * @param random_address 1553 */ 1554 const hci_cmd_t hci_le_set_advertising_set_random_address = { 1555 HCI_OPCODE_HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS, "1B" 1556 }; 1557 1558 /** 1559 * @param advertising_handle 1560 * @param advertising_event_properties 1561 * @param primary_advertising_interval_min in 0.625 ms, range: 0x000020..0xffffff 1562 * @param primary_advertising_interval_max in 0.625 ms, range: 0x000020..0xffffff 1563 * @param primary_advertising_channel_map 1564 * @param own_address_type 1565 * @param peer_address_type 1566 * @param peer_address 1567 * @param advertising_filter_policy 1568 * @param advertising_tx_power in dBm, range: -127..20 1569 * @param primary_advertising_phy 1570 * @param secondary_advertising_max_skip 1571 * @param secondary_advertising_phy 1572 * @param advertising_sid 1573 * @param scan_request_notification_enable 1574 */ 1575 const hci_cmd_t hci_le_set_extended_advertising_parameters = { 1576 HCI_OPCODE_HCI_LE_SET_EXTENDED_ADVERTISING_PARAMETERS, "1233111B1111111" 1577 }; 1578 1579 /** 1580 * @param advertising_handle 1581 * @param operation 1582 * @param fragment_preference 1583 * @param advertising_data_length 1584 * @param advertising_data 1585 */ 1586 1587 const hci_cmd_t hci_le_set_extended_advertising_data = { 1588 HCI_OPCODE_HCI_LE_SET_EXTENDED_ADVERTISING_DATA, "111JV" 1589 }; 1590 1591 /** 1592 * @param advertising_handle 1593 * @param operation 1594 * @param fragment_preference 1595 * @param scan_response_data_length 1596 * @param scan_response_data 1597 */ 1598 1599 const hci_cmd_t hci_le_set_extended_scan_response_data = { 1600 HCI_OPCODE_HCI_LE_SET_EXTENDED_SCAN_RESPONSE_DATA, "111JV" 1601 }; 1602 1603 /** 1604 * @param enable 1605 * @param num_sets 1606 * @param advertising_handle[i] 1607 * @param duration[i] 1608 * @param max_extended_advertising_events[i] 1609 */ 1610 1611 const hci_cmd_t hci_le_set_extended_advertising_enable = { 1612 HCI_OPCODE_HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE, "11[121]" 1613 }; 1614 1615 /** 1616 */ 1617 const hci_cmd_t hci_le_read_maximum_advertising_data_length = { 1618 HCI_OPCODE_HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH, "" 1619 }; 1620 1621 /** 1622 */ 1623 const hci_cmd_t hci_le_read_number_of_supported_advertising_sets = { 1624 HCI_OPCODE_HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS, "" 1625 }; 1626 1627 /** 1628 * @param advertising_handle 1629 */ 1630 const hci_cmd_t hci_le_remove_advertising_set = { 1631 HCI_OPCODE_HCI_LE_REMOVE_ADVERTISING_SET, "1" 1632 }; 1633 1634 /** 1635 */ 1636 const hci_cmd_t hci_le_clear_advertising_sets = { 1637 HCI_OPCODE_HCI_LE_CLEAR_ADVERTISING_SETS, "" 1638 }; 1639 1640 /** 1641 * @param advertising_handle 1642 * @param periodic_advertising_interval_min * 1.25 ms, range 0x0006..0xffff 1643 * @param periodic_advertising_interval_max * 1.25 ms, range 0x0006..0xffff 1644 * @param periodic_advertising_properties 1645 */ 1646 const hci_cmd_t hci_le_set_periodic_advertising_parameters = { 1647 HCI_OPCODE_HCI_LE_SET_PERIODIC_ADVERTISING_PARAMETERS, "1222" 1648 }; 1649 1650 /** 1651 * @param advertising_handle 1652 * @param operation 1653 * @param advertising_data_length 1654 * @param advertising_data 1655 */ 1656 1657 const hci_cmd_t hci_le_set_periodic_advertising_data = { 1658 HCI_OPCODE_HCI_LE_SET_PERIODIC_ADVERTISING_DATA, "11JV" 1659 }; 1660 1661 /** 1662 * @param enable 1663 * @param advertising_handle 1664 */ 1665 const hci_cmd_t hci_le_set_periodic_advertising_enable = { 1666 HCI_OPCODE_HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE, "11" 1667 }; 1668 1669 /** 1670 * @param own_address_type 1671 * @param scanning_filter_policy 1672 * @param scanning_phys 0 = LE 1M PHY | 2 = LE Coded PHY 1673 * @param scan_type 1674 * @param scan_interval * 0.625, range = 0x0004..0xffff 1675 * @param scan_window * 0.625, range = 0x0004..0xffff 1676 */ 1677 1678 // Variants for 1 (1M or Coded) PHY 1679 const hci_cmd_t hci_le_set_extended_scan_parameters_1 = { 1680 HCI_OPCODE_HCI_LE_SET_EXTENDED_SCAN_PARAMETERS, "111122" 1681 }; 1682 1683 // Variants for 2 (1M and Coded) PHY 1684 const hci_cmd_t hci_le_set_extended_scan_parameters_2 = { 1685 HCI_OPCODE_HCI_LE_SET_EXTENDED_SCAN_PARAMETERS, "111122122" 1686 }; 1687 1688 /** 1689 * @param enable 1690 * @param filter_duplicates 1691 * @param duration 0 = Scan continuously until explicitly disable, 10 ms 1692 * @param period 0 = Scan continuously, 1.28 s 1693 */ 1694 const hci_cmd_t hci_le_set_extended_scan_enable = { 1695 HCI_OPCODE_HCI_LE_SET_EXTENDED_SCAN_ENABLE, "1122" 1696 }; 1697 1698 /** 1699 * @param initiator_filter_policy 1700 * @param own_address_type 1701 * @param peer_address_type 1702 * @param peer_address 1703 * @param initiating_phys with bit 0 = LE 1M PHY, bit 1 = LE 2M PHY, bit 2 = Coded PHY 1704 * @param scan_interval[i] * 0.625 ms 1705 * @param scan_window[i] * 0.625 ms 1706 * @param connection_interval_min[i] * 1.25 ms 1707 * @param connection_interval_max[i] * 1.25 ms 1708 * @param connection_latency[i] 1709 * @param supervision_timeout[i] * 10 ms 1710 * @param min_ce_length[i] * 0.625 ms 1711 * @param max_ce_length[i] * 0.625 ms 1712 */ 1713 1714 const hci_cmd_t hci_le_extended_create_connection = { 1715 HCI_OPCODE_HCI_LE_EXTENDED_CREATE_CONNECTION, "111Bb[22222222]" 1716 }; 1717 1718 /** 1719 * @param options 1720 * @param advertising_sid 1721 * @param advertiser_address_type 1722 * @param advertiser_address 1723 * @param skip 1724 * @param sync_timeout * 10 ms 1725 * @param sync_cte_type 1726 */ 1727 const hci_cmd_t hci_le_periodic_advertising_create_sync = { 1728 HCI_OPCODE_HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC, "111B221" 1729 }; 1730 1731 /** 1732 */ 1733 const hci_cmd_t hci_le_periodic_advertising_create_sync_cancel = { 1734 HCI_OPCODE_HCI_LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL, "" 1735 }; 1736 1737 /** 1738 * @param sync_handle 1739 */ 1740 const hci_cmd_t hci_le_periodic_advertising_terminate_sync = { 1741 HCI_OPCODE_HCI_LE_PERIODIC_ADVERTISING_TERMINATE_SYNC, "" 1742 }; 1743 1744 /** 1745 * @param advertiser_address_type 1746 * @param advertiser_address 1747 * @param advertising_sid 1748 */ 1749 const hci_cmd_t hci_le_add_device_to_periodic_advertiser_list = { 1750 HCI_OPCODE_HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST, "1B1" 1751 }; 1752 1753 /** 1754 * @param advertiser_address_type 1755 * @param advertiser_address 1756 * @param advertising_sid 1757 */ 1758 const hci_cmd_t hci_le_remove_device_from_periodic_advertiser_list = { 1759 HCI_OPCODE_HCI_LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST, "1B1" 1760 }; 1761 1762 /** 1763 */ 1764 const hci_cmd_t hci_le_clear_periodic_advertiser_list = { 1765 HCI_OPCODE_HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST, "" 1766 }; 1767 1768 /** 1769 */ 1770 const hci_cmd_t hci_le_read_periodic_advertiser_list_size = { 1771 HCI_OPCODE_HCI_LE_READ_PERIODIC_ADVERTISER_LIST_SIZE, "" 1772 }; 1773 1774 /** 1775 */ 1776 const hci_cmd_t hci_le_read_transmit_power = { 1777 HCI_OPCODE_HCI_LE_READ_TRANSMIT_POWER, "" 1778 }; 1779 1780 /** 1781 */ 1782 const hci_cmd_t hci_le_read_rf_path_compensation = { 1783 HCI_OPCODE_HCI_LE_READ_RF_PATH_COMPENSATION, "" 1784 }; 1785 1786 /** 1787 * @param rf_tx_path_compensation_value * 0.1 dB, signed 1788 * @param rf_rx_path_compensation_value * 0.1 dB, signed 1789 */ 1790 const hci_cmd_t hci_le_write_rf_path_compensation = { 1791 HCI_OPCODE_HCI_LE_WRITE_RF_PATH_COMPENSATION, "22" 1792 }; 1793 1794 /** 1795 * @param peer_identity_address_type 1796 * @param peer_identity_address 1797 * @param privacy_mode 1798 */ 1799 const hci_cmd_t hci_le_set_privacy_mode = { 1800 HCI_OPCODE_HCI_LE_SET_PRIVACY_MODE, "1B1" 1801 }; 1802 1803 /** 1804 * @param rx_channel 1805 * @param phy 1806 * @param modulation_index 1807 * @param expected_cte_length 1808 * @param expected_cte_type 1809 * @param slot_durations 1810 * @param switching_pattern_length 1811 * @param antenna_ids[i] 1812 */ 1813 1814 const hci_cmd_t hci_le_receiver_test_v3 = { 1815 HCI_OPCODE_HCI_LE_RECEIVER_TEST_V3, "111111a[1]" 1816 }; 1817 1818 /** 1819 * @param tx_channel 1820 * @param test_data_length 1821 * @param packet_payload 1822 * @param phy 1823 * @param cte_length 1824 * @param cte_type 1825 * @param switching_pattern_length 1826 * @param antenna_ids[i] 1827 */ 1828 1829 const hci_cmd_t hci_le_transmitter_test_v3 = { 1830 HCI_OPCODE_HCI_LE_TRANSMITTER_TEST_V3, "111111a[1]" 1831 }; 1832 1833 /** 1834 * @param advertising_handle 1835 * @param cte_length 1836 * @param cte_type 1837 * @param cte_count 1838 * @param switching_pattern_length 1839 * @param antenna_ids[i] 1840 */ 1841 1842 const hci_cmd_t hci_le_set_connectionless_cte_transmit_parameters = { 1843 HCI_OPCODE_HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS, "1111a[1]" 1844 }; 1845 1846 /** 1847 * @param advertising_handle 1848 * @param cte_enable 1849 */ 1850 const hci_cmd_t hci_le_set_connectionless_cte_transmit_enable = { 1851 HCI_OPCODE_HCI_LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE, "11" 1852 }; 1853 1854 /** 1855 * @param sync_handle 1856 * @param sampling_enable 1857 * @param slot_durations 1858 * @param max_sampled_ctes 1859 * @param switching_pattern_length 1860 * @param antenna_ids[i] 1861 */ 1862 1863 const hci_cmd_t hci_le_set_connectionless_iq_sampling_enable = { 1864 HCI_OPCODE_HCI_LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE, "2111a[i]" 1865 }; 1866 1867 /** 1868 * @param connection_handle 1869 * @param sampling_enable 1870 * @param slot_durations 1871 * @param switching_pattern_length 1872 * @param antenna_ids[i] 1873 */ 1874 1875 const hci_cmd_t hci_le_set_connection_cte_receive_parameters = { 1876 HCI_OPCODE_HCI_LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS, "211a[1]" 1877 }; 1878 1879 /** 1880 * @param connection_handle 1881 * @param cte_types 1882 * @param switching_pattern_length 1883 * @param antenna_ids[i] 1884 */ 1885 1886 const hci_cmd_t hci_le_set_connection_cte_transmit_parameters = { 1887 HCI_OPCODE_HCI_LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS, "21a[1]" 1888 }; 1889 1890 /** 1891 * @param connection_handle 1892 * @param enable 1893 * @param cte_request_interval 1894 * @param requested_cte_length 1895 * @param requested_cte_type 1896 */ 1897 const hci_cmd_t hci_le_connection_cte_request_enable = { 1898 HCI_OPCODE_HCI_LE_CONNECTION_CTE_REQUEST_ENABLE, "H1211" 1899 }; 1900 1901 /** 1902 * @param connection_handle 1903 * @param enable 1904 */ 1905 const hci_cmd_t hci_le_connection_cte_response_enable = { 1906 HCI_OPCODE_HCI_LE_CONNECTION_CTE_RESPONSE_ENABLE, "H1" 1907 }; 1908 1909 /** 1910 */ 1911 const hci_cmd_t hci_le_read_antenna_information = { 1912 HCI_OPCODE_HCI_LE_READ_ANTENNA_INFORMATION, "" 1913 }; 1914 1915 /** 1916 * @param sync_handle 1917 * @param enable 1918 */ 1919 const hci_cmd_t hci_le_set_periodic_advertising_receive_enable = { 1920 HCI_OPCODE_HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE, "H1" 1921 }; 1922 1923 /** 1924 * @param connection_handle 1925 * @param service_data 1926 * @param sync_handle 1927 */ 1928 const hci_cmd_t hci_le_periodic_advertising_sync_transfer = { 1929 HCI_OPCODE_HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER, "H22" 1930 }; 1931 1932 /** 1933 * @param connection_handle 1934 * @param service_data 1935 * @param advertising_handle 1936 */ 1937 const hci_cmd_t hci_le_periodic_advertising_set_info_transfer = { 1938 HCI_OPCODE_HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER, "H21" 1939 }; 1940 1941 /** 1942 * @param connection_handle 1943 * @param mode 1944 * @param skip 1945 * @param sync_timeout 1946 * @param cte_type 1947 */ 1948 const hci_cmd_t hci_le_set_periodic_advertising_sync_transfer_parameters = { 1949 HCI_OPCODE_HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS, "H1221" 1950 }; 1951 1952 /** 1953 * @param mode 1954 * @param skip 1955 * @param sync_timeout 1956 * @param cte_type 1957 */ 1958 const hci_cmd_t hci_le_set_default_periodic_advertising_sync_transfer_parameters = { 1959 HCI_OPCODE_HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS, "1221" 1960 }; 1961 1962 /** 1963 * @param 256Remote_P-256_public_key_x 1964 * @param 256Remote_P-256_public_key_y 1965 * @param key_type 1966 */ 1967 const hci_cmd_t hci_le_generate_dhkey_v2 = { 1968 HCI_OPCODE_HCI_LE_GENERATE_DHKEY_V2, "QQ1" 1969 }; 1970 1971 /** 1972 * @param action 1973 */ 1974 const hci_cmd_t hci_le_modify_sleep_clock_accuracy = { 1975 HCI_OPCODE_HCI_LE_MODIFY_SLEEP_CLOCK_ACCURACY, "1" 1976 }; 1977 1978 /** 1979 */ 1980 const hci_cmd_t hci_opcode_hci_le_read_buffer_size_v2 = { 1981 HCI_OPCODE_HCI_OPCODE_HCI_LE_READ_BUFFER_SIZE_V2, "" 1982 }; 1983 1984 /** 1985 * @param connection_handle 1986 */ 1987 const hci_cmd_t hci_le_read_iso_tx_sync = { 1988 HCI_OPCODE_HCI_LE_READ_ISO_TX_SYNC, "H" 1989 }; 1990 1991 /** 1992 * @param cig_id 1993 * @param sdu_interval_m_to_s 1994 * @param sdu_interval_s_to_m 1995 * @param slaves_clock_accuracy 1996 * @param packing 1997 * @param framing 1998 * @param max_transport_latency_m_to_s 1999 * @param max_transport_latency_s_to_m 2000 * @param cis_count 2001 * @param cis_id[i] 2002 * @param max_sdu_m_to_s[i] 2003 * @param max_sdu_s_to_m[i] 2004 * @param phy_m_to_s[i] 2005 * @param phy_s_to_m[i] 2006 * @param rtn_m_to_s[i] 2007 * @param rtn_s_to_m[i] 2008 */ 2009 2010 const hci_cmd_t hci_le_set_cig_parameters = { 2011 HCI_OPCODE_HCI_LE_SET_CIG_PARAMETERS, "13311122a[1221111]" 2012 }; 2013 2014 /** 2015 * @param cig_id 2016 * @param sdu_interval_m_to_s 2017 * @param sdu_interval_s_to_m 2018 * @param ft_m_to_s 2019 * @param ft_s_to_m 2020 * @param iso_interval 2021 * @param slaves_clock_accuracy 2022 * @param packing 2023 * @param framing 2024 * @param max_transport_latency_m_to_s 2025 * @param max_transport_latency_s_to_m 2026 * @param cis_count 2027 * @param cis_id[i] 2028 * @param nse[i] 2029 * @param max_sdu_m_to_s[i] 2030 * @param max_sdu_s_to_m[i] 2031 * @param max_pdu_m_to_s[i] 2032 * @param max_pdu_s_to_m[i] 2033 * @param phy_m_to_s[i] 2034 * @param phy_s_to_m[i] 2035 * @param bn_m_to_s[i] 2036 * @param bn_s_to_m[i] 2037 */ 2038 2039 const hci_cmd_t hci_le_set_cig_parameters_test = { 2040 HCI_OPCODE_HCI_LE_SET_CIG_PARAMETERS_TEST, "133112111a[1122221111]" 2041 }; 2042 2043 /** 2044 * @param cis_count 2045 * @param cis_connection_handle[i] 2046 * @param acl_connection_handle[i] 2047 */ 2048 2049 const hci_cmd_t hci_le_create_cis = { 2050 HCI_OPCODE_HCI_LE_CREATE_CIS, "a[22]" 2051 }; 2052 2053 /** 2054 * @param cig_id 2055 */ 2056 const hci_cmd_t hci_le_remove_cig = { 2057 HCI_OPCODE_HCI_LE_REMOVE_CIG, "1" 2058 }; 2059 2060 /** 2061 * @param connection_handle 2062 */ 2063 const hci_cmd_t hci_le_accept_cis_request = { 2064 HCI_OPCODE_HCI_LE_ACCEPT_CIS_REQUEST, "H" 2065 }; 2066 2067 /** 2068 * @param connection_handle 2069 */ 2070 const hci_cmd_t hci_le_reject_cis_request = { 2071 HCI_OPCODE_HCI_LE_REJECT_CIS_REQUEST, "H" 2072 }; 2073 2074 /** 2075 * @param big_handle 2076 * @param advertising_handle 2077 * @param num_bis 2078 * @param sdu_interval 2079 * @param max_sdu 2080 * @param max_transport_latency 2081 * @param rtn 2082 * @param phy 2083 * @param packing 2084 * @param framing 2085 * @param encryption 2086 * @param broadcast_code 2087 */ 2088 const hci_cmd_t hci_le_create_big = { 2089 HCI_OPCODE_HCI_LE_CREATE_BIG, "11132211111P" 2090 }; 2091 2092 /** 2093 * @param big_handle 2094 * @param advertising_handle 2095 * @param num_bis 2096 * @param sdu_interval 2097 * @param iso_interval 2098 * @param nse 2099 * @param max_sdu 2100 * @param max_PDU 2101 * @param phy 2102 * @param packing 2103 * @param framing 2104 * @param bn 2105 * @param irc 2106 * @param pto 2107 * @param encryption 2108 * @param broadcast_code 2109 */ 2110 const hci_cmd_t hci_le_create_big_test = { 2111 HCI_OPCODE_HCI_LE_CREATE_BIG_TEST, "111321221111111P" 2112 }; 2113 2114 /** 2115 * @param big_handle 2116 * @param reason 2117 */ 2118 const hci_cmd_t hci_le_terminate_big = { 2119 HCI_OPCODE_HCI_LE_TERMINATE_BIG, "11" 2120 }; 2121 2122 /** 2123 * @param big_handle 2124 * @param sync_handle 2125 * @param encryption 2126 * @param broadcast_code 2127 * @param mse 2128 * @param big_sync_timeout 2129 * @param num_bis 2130 * @param bis[i] 2131 */ 2132 2133 const hci_cmd_t hci_le_big_create_sync = { 2134 HCI_OPCODE_HCI_LE_BIG_CREATE_SYNC, "1H1P12a[1]" 2135 }; 2136 2137 /** 2138 * @param big_handle 2139 */ 2140 const hci_cmd_t hci_le_big_terminate_sync = { 2141 HCI_OPCODE_HCI_LE_BIG_TERMINATE_SYNC, "" 2142 }; 2143 2144 /** 2145 * @param connection_handle 2146 */ 2147 const hci_cmd_t hci_le_request_peer_sca = { 2148 HCI_OPCODE_HCI_LE_REQUEST_PEER_SCA, "H" 2149 }; 2150 2151 /** 2152 * @param connection_handle 2153 * @param data_path_direction 2154 * @param data_path_id 2155 * @param codec_id_coding_format 2156 * @param codec_id_company_identifier (Shall be ignored if codec_id_coding_format is not 0xFF) 2157 * @param codec_id_vendor_codec_id (Shall be ignored if codec_id_coding_format is not 0xFF) 2158 * @param controller_delay 2159 * @param codec_configuration_length 2160 * @param codec_configuration 2161 */ 2162 2163 const hci_cmd_t hci_le_setup_iso_data_path = { 2164 HCI_OPCODE_HCI_LE_SETUP_ISO_DATA_PATH, "H111223JV" 2165 }; 2166 2167 /** 2168 * @param connection_handle 2169 */ 2170 const hci_cmd_t hci_le_remove_iso_data_path = { 2171 HCI_OPCODE_HCI_LE_REMOVE_ISO_DATA_PATH, "H1" 2172 }; 2173 2174 /** 2175 * @param connection_handle 2176 * @param paylaod_type 2177 */ 2178 const hci_cmd_t hci_le_iso_transmit_test = { 2179 HCI_OPCODE_HCI_LE_ISO_TRANSMIT_TEST, "H1" 2180 }; 2181 2182 /** 2183 * @param connection_handle 2184 * @param paylaod_type 2185 */ 2186 const hci_cmd_t hci_le_iso_receive_test = { 2187 HCI_OPCODE_HCI_LE_ISO_RECEIVE_TEST, "H1" 2188 }; 2189 2190 /** 2191 * @param connection_handle 2192 */ 2193 const hci_cmd_t hci_le_iso_read_test_counters = { 2194 HCI_OPCODE_HCI_LE_ISO_READ_TEST_COUNTERS, "H" 2195 }; 2196 2197 /** 2198 * @param connection_handle 2199 */ 2200 const hci_cmd_t hci_le_iso_test_end = { 2201 HCI_OPCODE_HCI_LE_ISO_TEST_END, "H" 2202 }; 2203 2204 /** 2205 * @param bit_number 2206 * @param bit_value 2207 */ 2208 const hci_cmd_t hci_le_set_host_feature = { 2209 HCI_OPCODE_HCI_LE_SET_HOST_FEATURE, "11" 2210 }; 2211 2212 /** 2213 * @param connection_handle 2214 */ 2215 const hci_cmd_t hci_le_read_iso_link_quality = { 2216 HCI_OPCODE_HCI_LE_READ_ISO_LINK_QUALITY, "H" 2217 }; 2218 2219 /** 2220 * @param connection_handle 2221 * @param phy 2222 */ 2223 const hci_cmd_t hci_le_enhanced_read_transmit_power_level = { 2224 HCI_OPCODE_HCI_LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL, "H1" 2225 }; 2226 2227 /** 2228 * @param connection_handle 2229 * @param phy 2230 */ 2231 const hci_cmd_t hci_le_read_remote_transmit_power_level = { 2232 HCI_OPCODE_HCI_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL, "H1" 2233 }; 2234 2235 /** 2236 * @param connection_handle 2237 * @param high_threshold 2238 * @param high_hysteresis 2239 * @param low_threshold 2240 * @param low_hysteresis 2241 * @param min_time_spent 2242 */ 2243 const hci_cmd_t hci_le_set_path_loss_reporting_parameters = { 2244 HCI_OPCODE_HCI_LE_SET_PATH_LOSS_REPORTING_PARAMETERS, "211112" 2245 }; 2246 2247 /** 2248 * @param connection_handle 2249 * @param enable 2250 */ 2251 const hci_cmd_t hci_le_set_path_loss_reporting_enable = { 2252 HCI_OPCODE_HCI_LE_SET_PATH_LOSS_REPORTING_ENABLE, "H1" 2253 }; 2254 2255 /** 2256 * @param connection_handle 2257 * @param local_enable 2258 * @param remote_enable 2259 */ 2260 const hci_cmd_t hci_le_set_transmit_power_reporting_enable = { 2261 HCI_OPCODE_HCI_LE_SET_TRANSMIT_POWER_REPORTING_ENABLE, "H11" 2262 }; 2263 2264 /** 2265 * @param tx_channel 2266 * @param test_data_length 2267 * @param packet_payload 2268 * @param phy 2269 * @param cte_length 2270 * @param cte_type 2271 * @param switching_pattern_length 2272 * @param antenna_ids[i] 2273 * @param transmit_power_level 2274 */ 2275 2276 const hci_cmd_t hci_le_transmitter_test_v4 = { 2277 HCI_OPCODE_HCI_LE_TRANSMITTER_TEST_V4, "111111a[1]1" 2278 }; 2279 2280 #endif 2281 2282 // Broadcom / Cypress specific HCI commands 2283 2284 /** 2285 * @brief Enable Wide-Band Speech / mSBC decoding for PCM 2286 * @param enable_wbs is 0 for disable, 1 for enable 2287 * @param uuid_wbs is 2 for EV2/EV3 2288 */ 2289 const hci_cmd_t hci_bcm_enable_wbs = { 2290 HCI_OPCODE_HCI_BCM_ENABLE_WBS, "12" 2291 // return: status 2292 }; 2293 2294 /** 2295 * @brief Configure SCO Routing (BCM) 2296 * @param sco_routing is 0 for PCM, 1 for Transport, 2 for Codec and 3 for I2S 2297 * @param pcm_interface_rate is 0 for 128KBps, 1 for 256 KBps, 2 for 512KBps, 3 for 1024KBps, and 4 for 2048Kbps 2298 * @param frame_type is 0 for short and 1 for long 2299 * @param sync_mode is 0 for slave and 1 for master 2300 * @param clock_mode is 0 for slabe and 1 for master 2301 */ 2302 const hci_cmd_t hci_bcm_write_sco_pcm_int = { 2303 HCI_OPCODE_HCI_BCM_WRITE_SCO_PCM_INT, "11111" 2304 // return: status 2305 }; 2306 2307 /** 2308 * @brief Configure the I2S/PCM interface (BCM) 2309 * @param i2s_enable is 0 for off, 1 for on 2310 * @param is_master is 0 for slave, is 1 for master 2311 * @param sample_rate is 0 for 8 kHz, 1 for 16 kHz, 2 for 4 kHz 2312 * @param clock_rate is 0 for 128 kz, 1 for 256 kHz, 2 for 512 khz, 3 for 1024 kHz, 4 for 2048 khz 2313 * @param clock_mode is 0 for slabe and 1 for master 2314 */ 2315 const hci_cmd_t hci_bcm_write_i2spcm_interface_param = { 2316 HCI_OPCODE_HCI_BCM_WRITE_I2SPCM_INTERFACE_PARAM, "1111" 2317 // return: status 2318 }; 2319 2320 2321 /** 2322 * @brief Activates selected Sleep Mode 2323 * @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 2324 * @param idle_threshold_host (modes 1,2,5,7) time until considered idle, unit roughly 300 ms 2325 * @param idle_threshold_controller (modes 1-7,9) time until considered idle, unit roughly 300 ms 2326 * @param bt_wake_active_mode (modes 1,2,7) 0 = BT_WAKE line is active high, 1 = BT_WAKE is active low 2327 * @param host_wake_active_mode (modes 1,2,5,7) 0 = HOST_WAKE line is active high, 1 = HOST_WAKE is active low 2328 * @param allow_host_sleep_during_sco (modes 1,2,3,5,7) 2329 * @param combine_sleep_mode_and_lpm (modes 1,2,3,5,7) 2330 * @param enable_tristate_control_of_uart_tx_line (modes 1,2,7) 2331 * @param active_connection_handling_on_suspend (modes 3,5) 2332 * @param resume_timeout (modes 3,5) 2333 * @param enable_break_to_host (mode 12) 2334 * @param pulsed_host_wake (modes 1,12) 2335 */ 2336 const hci_cmd_t hci_bcm_set_sleep_mode = { 2337 HCI_OPCODE_HCI_BCM_SET_SLEEP_MODE, "111111111111" 2338 }; 2339 2340 /** 2341 * @brief Set TX Power Table 2342 * @param is_le 0=classic, 1=LE 2343 * @param chip_max_tx_pwr_db chip level max TX power in dBM 2344 */ 2345 const hci_cmd_t hci_bcm_write_tx_power_table = { 2346 HCI_OPCODE_HCI_BCM_WRITE_TX_POWER_TABLE, "11" 2347 }; 2348 2349 const hci_cmd_t hci_bcm_set_tx_pwr = { 2350 HCI_OPCODE_HCI_BCM_SET_TX_PWR, "11H" 2351 }; 2352 2353 /** 2354 * @brief This command starts receiving packets using packet transmission parameters such as 2355 * frequency channel, packet type, and packet length. It is used for Packet RX. 2356 * @see https://processors.wiki.ti.com/index.php/CC256x_Testing_Guide#Continuous_RX 2357 * @param frequency 2358 * @param ADPLL loop mode 2359 */ 2360 const hci_cmd_t hci_ti_drpb_tester_con_rx = { 2361 0xFD17, "11" 2362 }; 2363 2364 /** 2365 * 2366 * 2367 * @brief This command tests the RF transceiver in continuous transmission mode. 2368 * The transmitter is activated by configuring the transmission parameters such as pattern, 2369 * modulation, and frequency. 2370 * @see processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands#HCI_VS_DRPb_Tester_Con_TX.280xFD84.29 2371 * @param modulation 2372 * @param test_pattern 2373 * @param frequency 2374 * @param power_level 2375 * @param reserved1 2376 * @param reserved2 2377 */ 2378 const hci_cmd_t hci_ti_drpb_tester_con_tx = { 2379 0xFD84, "111144" 2380 }; 2381 2382 /** 2383 * @brief This command starts sending/receiving packets using packet transmission parameters such as 2384 * frequency channel, packet type, and packet length. It is used for Packet TX/RX. 2385 * @see processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands#HCI_VS_DRPb_Tester_Packet_TX_RX_.280xFD85.29 2386 * @param frequency_mode 2387 * @param tx_single_frequency 2388 * @param rx_single_frequency 2389 * @param acl_packet_type 2390 * @paarm acl_packet_data_pattern 2391 * @param reserved 2392 * @param power_level 2393 * @param disable_whitening 2394 * @param prbs9_initialization_value 2395 */ 2396 const hci_cmd_t hci_ti_drpb_tester_packet_tx_rx = { 2397 0xFD85, "1111112112" 2398 }; 2399 2400 2401 /** 2402 * @param best effort access percentage 2403 * @param guaranteed access percentage 2404 * @param poll period 2405 * @param slave burst after tx 2406 * @param slave master search count 2407 * @param master burst after tx enable 2408 * @param master burst after rx limit 2409 */ 2410 const hci_cmd_t hci_ti_configure_ddip = { 2411 HCI_OPCODE_HCI_TI_VS_CONFIGURE_DDIP, "1111111" 2412 }; 2413 2414 /** 2415 * @brief This command is used to associate the requested ACL handle with Wide Band Speech configuration. 2416 * @param enable 0=disable, 1=enable 2417 * @param a3dp_role (NL5500, WL128x only) 0=source,1=sink 2418 * @param code_upload (NL5500, WL128x only) 0=do not load a3dp code, 1=load a3dp code 2419 * @param reserved for future use 2420 */ 2421 const hci_cmd_t hci_ti_avrp_enable = { 2422 0xFD92, "1112" 2423 }; 2424 2425 /** 2426 * @brief This command is used to associate the requested ACL handle with Wide Band Speech configuration. 2427 * @param acl_con_handle 2428 */ 2429 const hci_cmd_t hci_ti_wbs_associate = { 2430 0xFD78, "H" 2431 }; 2432 2433 /** 2434 * @brief This command is used to disassociate Wide Band Speech configuration from any ACL handle. 2435 */ 2436 const hci_cmd_t hci_ti_wbs_disassociate = { 2437 0xFD79, "" 2438 }; 2439 2440 /** 2441 * @brief This command configures the codec interface parameters and the PCM clock rate, which is relevant when 2442 the Bluetooth core generates the clock. This command must be used by the host to use the PCM 2443 interface. 2444 * @param clock_rate in kHz 2445 * @param clock_direction 0=master/output, 1=slave/input 2446 * @param frame_sync_frequency in Hz 2447 * @param frame_sync_duty_cycle 0=50% (I2S Format), 0x0001-0xffff number of cycles of PCM clock 2448 * @param frame_sync_edge 0=driven/sampled at rising edge, 1=driven/sampled at falling edge of PCM clock 2449 * @param frame_sync_polariy 0=active high, 1=active low 2450 * @param reserved1 2451 * @param channel_1_data_out_size sample size in bits 2452 * @param channel_1_data_out_offset number of PCM clock cycles between rising of frame sync and data start 2453 * @param channel_1_data_out_edge 0=data driven at rising edge, 1=data driven at falling edge of PCM clock 2454 * @param channel_1_data_in_size sample size in bits 2455 * @param channel_1_data_in_offset number of PCM clock cycles between rising of frame sync and data start 2456 * @param channel_1_data_in_edge 0=data sampled at rising edge, 1=data sampled at falling edge of PCM clock 2457 * @param fsync_multiplier this field is only relevant to CC256XB from service pack 0.2 !!! -> use 0x00 2458 * @param channel_2_data_out_size sample size in bits 2459 * @param channel_2_data_out_offset number of PCM clock cycles between rising of frame sync and data start 2460 * @param channel_2_data_out_edge 0=data driven at rising edge, 1=data driven at falling edge of PCM clock 2461 * @param channel_2_data_in_size sample size in bits 2462 * @param channel_2_data_in_offset number of PCM clock cycles between rising of frame sync and data start 2463 * @param channel_2_data_in_edge 0=data sampled at rising edge, 1=data sampled at falling edge of PCM clock 2464 * @param reserved2 2465 * 2466 */ 2467 const hci_cmd_t hci_ti_write_codec_config = { 2468 0xFD06, "214211122122112212211" 2469 }; 2470 2471 /** 2472 * @brief This command is used only for internal testing. 2473 * @see https://processors.wiki.ti.com/index.php/CC256x_Testing_Guide#Continuous_TX 2474 * @param frequency 2475 * @param ADPLL loop mode 2476 */ 2477 const hci_cmd_t hci_ti_drpb_enable_rf_calibration = { 2478 0xFD80, "141" 2479 }; 2480 2481 /** 2482 * @brief This command command is only required for the continuous TX test of modulated 2483 * (GFSK, π/4-DQPSK or 8DPSK) signal. This command should be skipped when performing continuous TX test for CW. 2484 * @see https://processors.wiki.ti.com/index.php/CC256x_Testing_Guide#Continuous_RX 2485 * @param frequency 2486 * @param ADPLL loop mode 2487 */ 2488 const hci_cmd_t hci_ti_write_hardware_register = { 2489 0xFF01, "42" 2490 }; 2491