156042629SMatthias Ringwald /* 256042629SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 356042629SMatthias Ringwald * 456042629SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 556042629SMatthias Ringwald * modification, are permitted provided that the following conditions 656042629SMatthias Ringwald * are met: 756042629SMatthias Ringwald * 856042629SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 956042629SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 1056042629SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 1156042629SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 1256042629SMatthias Ringwald * documentation and/or other materials provided with the distribution. 1356042629SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 1456042629SMatthias Ringwald * contributors may be used to endorse or promote products derived 1556042629SMatthias Ringwald * from this software without specific prior written permission. 1656042629SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 1756042629SMatthias Ringwald * personal benefit and not for any commercial purpose or for 1856042629SMatthias Ringwald * monetary gain. 1956042629SMatthias Ringwald * 2056042629SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 2156042629SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2256042629SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 2356042629SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 2456042629SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2556042629SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2656042629SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2756042629SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2856042629SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2956042629SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 3056042629SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3156042629SMatthias Ringwald * SUCH DAMAGE. 3256042629SMatthias Ringwald * 3356042629SMatthias Ringwald * Please inquire about commercial licensing options at 3456042629SMatthias Ringwald * [email protected] 3556042629SMatthias Ringwald * 3656042629SMatthias Ringwald */ 3756042629SMatthias Ringwald 3856042629SMatthias Ringwald /* 3956042629SMatthias Ringwald * hci_cmd.h 4056042629SMatthias Ringwald * 4156042629SMatthias Ringwald * Created by Matthias Ringwald on 7/23/09. 4256042629SMatthias Ringwald */ 4356042629SMatthias Ringwald 4480e33422SMatthias Ringwald #ifndef HCI_CMDS_H 4580e33422SMatthias Ringwald #define HCI_CMDS_H 4656042629SMatthias Ringwald 4756042629SMatthias Ringwald #include "bluetooth.h" 4856042629SMatthias Ringwald #include "btstack_defines.h" 4956042629SMatthias Ringwald 5056042629SMatthias Ringwald #include <stdint.h> 5156042629SMatthias Ringwald #include <stdarg.h> 5256042629SMatthias Ringwald 5356042629SMatthias Ringwald #if defined __cplusplus 5456042629SMatthias Ringwald extern "C" { 5556042629SMatthias Ringwald #endif 5656042629SMatthias Ringwald 5756042629SMatthias Ringwald /** 5856042629SMatthias Ringwald * Hardware state of Bluetooth controller 5956042629SMatthias Ringwald */ 6056042629SMatthias Ringwald typedef enum { 6156042629SMatthias Ringwald HCI_POWER_OFF = 0, 6256042629SMatthias Ringwald HCI_POWER_ON, 6356042629SMatthias Ringwald HCI_POWER_SLEEP 6456042629SMatthias Ringwald } HCI_POWER_MODE; 6556042629SMatthias Ringwald 6656042629SMatthias Ringwald /** 6756042629SMatthias Ringwald * State of BTstack 6856042629SMatthias Ringwald */ 6956042629SMatthias Ringwald typedef enum { 7056042629SMatthias Ringwald HCI_STATE_OFF = 0, 7156042629SMatthias Ringwald HCI_STATE_INITIALIZING, 7256042629SMatthias Ringwald HCI_STATE_WORKING, 7356042629SMatthias Ringwald HCI_STATE_HALTING, 7456042629SMatthias Ringwald HCI_STATE_SLEEPING, 7556042629SMatthias Ringwald HCI_STATE_FALLING_ASLEEP 7656042629SMatthias Ringwald } HCI_STATE; 7756042629SMatthias Ringwald 7856042629SMatthias Ringwald /** 7956042629SMatthias Ringwald * compact HCI Command packet description 8056042629SMatthias Ringwald */ 8156042629SMatthias Ringwald typedef struct { 8256042629SMatthias Ringwald uint16_t opcode; 8356042629SMatthias Ringwald const char *format; 8456042629SMatthias Ringwald } hci_cmd_t; 8556042629SMatthias Ringwald 8656042629SMatthias Ringwald 8756042629SMatthias Ringwald // HCI Commands - see hci_cmd.c for info on parameters 8856042629SMatthias Ringwald extern const hci_cmd_t hci_accept_connection_request; 8956042629SMatthias Ringwald extern const hci_cmd_t hci_accept_synchronous_connection; 9056042629SMatthias Ringwald extern const hci_cmd_t hci_authentication_requested; 9156042629SMatthias Ringwald extern const hci_cmd_t hci_change_connection_link_key; 9256042629SMatthias Ringwald extern const hci_cmd_t hci_change_connection_packet_type; 9356042629SMatthias Ringwald extern const hci_cmd_t hci_create_connection; 9456042629SMatthias Ringwald extern const hci_cmd_t hci_create_connection_cancel; 9556042629SMatthias Ringwald extern const hci_cmd_t hci_delete_stored_link_key; 9656042629SMatthias Ringwald extern const hci_cmd_t hci_disconnect; 9784ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_enable_device_under_test_mode; 98bed80775SMatthias Ringwald extern const hci_cmd_t hci_enhanced_accept_synchronous_connection; 99bed80775SMatthias Ringwald extern const hci_cmd_t hci_enhanced_setup_synchronous_connection; 1007cd21895SMatthias Ringwald extern const hci_cmd_t hci_exit_sniff_mode; 101e49d496aSMatthias Ringwald extern const hci_cmd_t hci_flush; 10256042629SMatthias Ringwald extern const hci_cmd_t hci_host_buffer_size; 10356042629SMatthias Ringwald extern const hci_cmd_t hci_inquiry; 10456042629SMatthias Ringwald extern const hci_cmd_t hci_inquiry_cancel; 105bed80775SMatthias Ringwald extern const hci_cmd_t hci_io_capability_request_negative_reply; 106bed80775SMatthias Ringwald extern const hci_cmd_t hci_io_capability_request_reply; 10756042629SMatthias Ringwald extern const hci_cmd_t hci_link_key_request_negative_reply; 10856042629SMatthias Ringwald extern const hci_cmd_t hci_link_key_request_reply; 10956042629SMatthias Ringwald extern const hci_cmd_t hci_pin_code_request_negative_reply; 110bed80775SMatthias Ringwald extern const hci_cmd_t hci_pin_code_request_reply; 11156042629SMatthias Ringwald extern const hci_cmd_t hci_qos_setup; 11256042629SMatthias Ringwald extern const hci_cmd_t hci_read_bd_addr; 11356042629SMatthias Ringwald extern const hci_cmd_t hci_read_buffer_size; 11497abfa24SMatthias Ringwald extern const hci_cmd_t hci_read_encryption_key_size; 11556042629SMatthias Ringwald extern const hci_cmd_t hci_read_le_host_supported; 11656042629SMatthias Ringwald extern const hci_cmd_t hci_read_link_policy_settings; 11756042629SMatthias Ringwald extern const hci_cmd_t hci_read_link_supervision_timeout; 118bed80775SMatthias Ringwald extern const hci_cmd_t hci_read_local_extended_ob_data; 119237daac5SMatthias Ringwald extern const hci_cmd_t hci_read_local_extended_oob_data; 120e90bae01SMatthias Ringwald extern const hci_cmd_t hci_read_local_name; 121195e82f3Sskoperst extern const hci_cmd_t hci_read_page_timeout; 122195e82f3Sskoperst extern const hci_cmd_t hci_read_page_scan_activity; 123*9af39d9fSMatthias Ringwald extern const hci_cmd_t hci_read_pin_type; 124237daac5SMatthias Ringwald extern const hci_cmd_t hci_read_local_oob_data; 12556042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_supported_commands; 12656042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_supported_features; 127237daac5SMatthias Ringwald extern const hci_cmd_t hci_read_local_version_information; 128bed80775SMatthias Ringwald extern const hci_cmd_t hci_read_loopback_mode; 12956042629SMatthias Ringwald extern const hci_cmd_t hci_read_num_broadcast_retransmissions; 13056042629SMatthias Ringwald extern const hci_cmd_t hci_read_remote_supported_features_command; 1318b22c04dSMatthias Ringwald extern const hci_cmd_t hci_read_remote_version_information; 13244751e25SMatthias Ringwald extern const hci_cmd_t hci_read_transmit_power_level; 13356042629SMatthias Ringwald extern const hci_cmd_t hci_read_rssi; 13456042629SMatthias Ringwald extern const hci_cmd_t hci_reject_connection_request; 13556042629SMatthias Ringwald extern const hci_cmd_t hci_remote_name_request; 13656042629SMatthias Ringwald extern const hci_cmd_t hci_remote_name_request_cancel; 13756042629SMatthias Ringwald extern const hci_cmd_t hci_remote_oob_data_request_negative_reply; 138bed80775SMatthias Ringwald extern const hci_cmd_t hci_remote_oob_data_request_reply; 13956042629SMatthias Ringwald extern const hci_cmd_t hci_reset; 14056042629SMatthias Ringwald extern const hci_cmd_t hci_role_discovery; 14156042629SMatthias Ringwald extern const hci_cmd_t hci_set_connection_encryption; 1422b838201SMatthias Ringwald extern const hci_cmd_t hci_set_controller_to_host_flow_control; 14384ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_set_event_mask; 14456042629SMatthias Ringwald extern const hci_cmd_t hci_setup_synchronous_connection; 14556042629SMatthias Ringwald extern const hci_cmd_t hci_sniff_mode; 14656042629SMatthias Ringwald extern const hci_cmd_t hci_switch_role_command; 14756042629SMatthias Ringwald extern const hci_cmd_t hci_user_confirmation_request_negative_reply; 14856042629SMatthias Ringwald extern const hci_cmd_t hci_user_confirmation_request_reply; 14956042629SMatthias Ringwald extern const hci_cmd_t hci_user_passkey_request_negative_reply; 15056042629SMatthias Ringwald extern const hci_cmd_t hci_user_passkey_request_reply; 15156042629SMatthias Ringwald extern const hci_cmd_t hci_write_authentication_enable; 15256042629SMatthias Ringwald extern const hci_cmd_t hci_write_class_of_device; 1539119d792SMilanka Ringwald extern const hci_cmd_t hci_write_current_iac_lap_two_iacs; 154483c5078SMatthias Ringwald extern const hci_cmd_t hci_write_default_erroneous_data_reporting; 15553138e7aSMatthias Ringwald extern const hci_cmd_t hci_write_default_link_policy_setting; 15656042629SMatthias Ringwald extern const hci_cmd_t hci_write_extended_inquiry_response; 15756042629SMatthias Ringwald extern const hci_cmd_t hci_write_inquiry_mode; 15856042629SMatthias Ringwald extern const hci_cmd_t hci_write_le_host_supported; 15956042629SMatthias Ringwald extern const hci_cmd_t hci_write_link_policy_settings; 16056042629SMatthias Ringwald extern const hci_cmd_t hci_write_link_supervision_timeout; 16156042629SMatthias Ringwald extern const hci_cmd_t hci_write_local_name; 162bed80775SMatthias Ringwald extern const hci_cmd_t hci_write_loopback_mode; 16356042629SMatthias Ringwald extern const hci_cmd_t hci_write_num_broadcast_retransmissions; 16456042629SMatthias Ringwald extern const hci_cmd_t hci_write_page_timeout; 165*9af39d9fSMatthias Ringwald extern const hci_cmd_t hci_write_pin_type; 166195e82f3Sskoperst extern const hci_cmd_t hci_write_page_scan_activity; 16756042629SMatthias Ringwald extern const hci_cmd_t hci_write_scan_enable; 16884ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_write_secure_connections_test_mode; 16984ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_write_simple_pairing_debug_mode; 17056042629SMatthias Ringwald extern const hci_cmd_t hci_write_simple_pairing_mode; 17156042629SMatthias Ringwald extern const hci_cmd_t hci_write_synchronous_flow_control_enable; 17256042629SMatthias Ringwald 17356042629SMatthias Ringwald extern const hci_cmd_t hci_le_add_device_to_white_list; 17456042629SMatthias Ringwald extern const hci_cmd_t hci_le_clear_white_list; 17556042629SMatthias Ringwald extern const hci_cmd_t hci_le_connection_update; 17656042629SMatthias Ringwald extern const hci_cmd_t hci_le_create_connection; 17756042629SMatthias Ringwald extern const hci_cmd_t hci_le_create_connection_cancel; 17856042629SMatthias Ringwald extern const hci_cmd_t hci_le_encrypt; 17982180fcaSMatthias Ringwald extern const hci_cmd_t hci_le_generate_dhkey; 18056042629SMatthias Ringwald extern const hci_cmd_t hci_le_long_term_key_negative_reply; 18156042629SMatthias Ringwald extern const hci_cmd_t hci_le_long_term_key_request_reply; 18256042629SMatthias Ringwald extern const hci_cmd_t hci_le_rand; 18356042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_advertising_channel_tx_power; 18456042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_buffer_size ; 18556042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_channel_map; 18682180fcaSMatthias Ringwald extern const hci_cmd_t hci_le_read_local_p256_public_key; 1870ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_read_maximum_data_length; 188ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_read_phy; 18956042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_remote_used_features; 1900ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_read_suggested_default_data_length; 19156042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_supported_features; 19256042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_supported_states; 19356042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_white_list_size; 19456042629SMatthias Ringwald extern const hci_cmd_t hci_le_receiver_test; 195fe704c95SMatthias Ringwald extern const hci_cmd_t hci_le_remote_connection_parameter_request_negative_reply; 196ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_remote_connection_parameter_request_reply; 19756042629SMatthias Ringwald extern const hci_cmd_t hci_le_remove_device_from_white_list; 19856042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertise_enable; 19956042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertising_data; 20056042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertising_parameters; 2010ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_set_data_length; 202ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_set_default_phy; 20356042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_event_mask; 20456042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_host_channel_classification; 205ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_set_phy; 20656042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_random_address; 20756042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_enable; 20856042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_parameters; 20956042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_response_data; 21056042629SMatthias Ringwald extern const hci_cmd_t hci_le_start_encryption; 21156042629SMatthias Ringwald extern const hci_cmd_t hci_le_test_end; 21256042629SMatthias Ringwald extern const hci_cmd_t hci_le_transmitter_test; 2130ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_write_suggested_default_data_length; 214a42798c3SMatthias Ringwald 215a42798c3SMatthias Ringwald // Broadcom / Cypress specific HCI commands 216a42798c3SMatthias Ringwald extern const hci_cmd_t hci_bcm_write_sco_pcm_int; 217eab6959fSMatthias Ringwald extern const hci_cmd_t hci_bcm_set_sleep_mode; 218a42798c3SMatthias Ringwald 21956042629SMatthias Ringwald /** 22056042629SMatthias Ringwald * construct HCI Command based on template 22156042629SMatthias Ringwald * 22256042629SMatthias Ringwald * Format: 22356042629SMatthias Ringwald * 1,2,3,4: one to four byte value 22456042629SMatthias Ringwald * H: HCI connection handle 22556042629SMatthias Ringwald * B: Bluetooth Baseband Address (BD_ADDR) 22656042629SMatthias Ringwald * D: 8 byte data block 22756042629SMatthias Ringwald * E: Extended Inquiry Result 22856042629SMatthias Ringwald * N: Name up to 248 chars, \0 terminated 22956042629SMatthias Ringwald * P: 16 byte Pairing code 23056042629SMatthias Ringwald * A: 31 bytes advertising data 23156042629SMatthias Ringwald * S: Service Record (Data Element Sequence) 23256042629SMatthias Ringwald */ 23356042629SMatthias Ringwald uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr); 23456042629SMatthias Ringwald 23556042629SMatthias Ringwald 23656042629SMatthias Ringwald #if defined __cplusplus 23756042629SMatthias Ringwald } 23856042629SMatthias Ringwald #endif 23956042629SMatthias Ringwald 24080e33422SMatthias Ringwald #endif // HCI_CMDS_H 241