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