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 /* 39 * hci_cmd.h 40 * 41 * Created by Matthias Ringwald on 7/23/09. 42 */ 43 44 #ifndef HCI_CMDS_H 45 #define HCI_CMDS_H 46 47 #include "bluetooth.h" 48 #include "btstack_defines.h" 49 50 #include <stdint.h> 51 #include <stdarg.h> 52 53 #if defined __cplusplus 54 extern "C" { 55 #endif 56 57 /** 58 * Hardware state of Bluetooth controller 59 */ 60 typedef enum { 61 HCI_POWER_OFF = 0, 62 HCI_POWER_ON, 63 HCI_POWER_SLEEP 64 } HCI_POWER_MODE; 65 66 /** 67 * State of BTstack 68 */ 69 typedef enum { 70 HCI_STATE_OFF = 0, 71 HCI_STATE_INITIALIZING, 72 HCI_STATE_WORKING, 73 HCI_STATE_HALTING, 74 HCI_STATE_SLEEPING, 75 HCI_STATE_FALLING_ASLEEP 76 } HCI_STATE; 77 78 /** 79 * compact HCI Command packet description 80 */ 81 typedef struct { 82 uint16_t opcode; 83 const char *format; 84 } hci_cmd_t; 85 86 87 // HCI Commands - see hci_cmd.c for info on parameters 88 extern const hci_cmd_t hci_accept_connection_request; 89 extern const hci_cmd_t hci_accept_synchronous_connection; 90 extern const hci_cmd_t hci_authentication_requested; 91 extern const hci_cmd_t hci_change_connection_link_key; 92 extern const hci_cmd_t hci_change_connection_packet_type; 93 extern const hci_cmd_t hci_create_connection; 94 extern const hci_cmd_t hci_create_connection_cancel; 95 extern const hci_cmd_t hci_delete_stored_link_key; 96 extern const hci_cmd_t hci_disconnect; 97 extern const hci_cmd_t hci_enable_device_under_test_mode; 98 extern const hci_cmd_t hci_enhanced_accept_synchronous_connection; 99 extern const hci_cmd_t hci_enhanced_setup_synchronous_connection; 100 extern const hci_cmd_t hci_exit_sniff_mode; 101 extern const hci_cmd_t hci_flush; 102 extern const hci_cmd_t hci_host_buffer_size; 103 extern const hci_cmd_t hci_inquiry; 104 extern const hci_cmd_t hci_inquiry_cancel; 105 extern const hci_cmd_t hci_io_capability_request_negative_reply; 106 extern const hci_cmd_t hci_io_capability_request_reply; 107 extern const hci_cmd_t hci_link_key_request_negative_reply; 108 extern const hci_cmd_t hci_link_key_request_reply; 109 extern const hci_cmd_t hci_pin_code_request_negative_reply; 110 extern const hci_cmd_t hci_pin_code_request_reply; 111 extern const hci_cmd_t hci_qos_setup; 112 extern const hci_cmd_t hci_read_bd_addr; 113 extern const hci_cmd_t hci_read_buffer_size; 114 extern const hci_cmd_t hci_read_encryption_key_size; 115 extern const hci_cmd_t hci_read_le_host_supported; 116 extern const hci_cmd_t hci_read_link_policy_settings; 117 extern const hci_cmd_t hci_read_link_supervision_timeout; 118 extern const hci_cmd_t hci_read_local_extended_ob_data; 119 extern const hci_cmd_t hci_read_local_extended_oob_data; 120 extern const hci_cmd_t hci_read_local_name; 121 extern const hci_cmd_t hci_read_page_timeout; 122 extern const hci_cmd_t hci_read_page_scan_activity; 123 extern const hci_cmd_t hci_read_pin_type; 124 extern const hci_cmd_t hci_read_local_oob_data; 125 extern const hci_cmd_t hci_read_local_supported_commands; 126 extern const hci_cmd_t hci_read_local_supported_features; 127 extern const hci_cmd_t hci_read_local_version_information; 128 extern const hci_cmd_t hci_read_loopback_mode; 129 extern const hci_cmd_t hci_read_num_broadcast_retransmissions; 130 extern const hci_cmd_t hci_read_remote_supported_features_command; 131 extern const hci_cmd_t hci_read_remote_version_information; 132 extern const hci_cmd_t hci_read_transmit_power_level; 133 extern const hci_cmd_t hci_read_rssi; 134 extern const hci_cmd_t hci_reject_connection_request; 135 extern const hci_cmd_t hci_remote_name_request; 136 extern const hci_cmd_t hci_remote_name_request_cancel; 137 extern const hci_cmd_t hci_remote_oob_data_request_negative_reply; 138 extern const hci_cmd_t hci_remote_oob_data_request_reply; 139 extern const hci_cmd_t hci_reset; 140 extern const hci_cmd_t hci_role_discovery; 141 extern const hci_cmd_t hci_set_connection_encryption; 142 extern const hci_cmd_t hci_set_controller_to_host_flow_control; 143 extern const hci_cmd_t hci_set_event_mask; 144 extern const hci_cmd_t hci_setup_synchronous_connection; 145 extern const hci_cmd_t hci_sniff_mode; 146 extern const hci_cmd_t hci_switch_role_command; 147 extern const hci_cmd_t hci_user_confirmation_request_negative_reply; 148 extern const hci_cmd_t hci_user_confirmation_request_reply; 149 extern const hci_cmd_t hci_user_passkey_request_negative_reply; 150 extern const hci_cmd_t hci_user_passkey_request_reply; 151 extern const hci_cmd_t hci_write_authentication_enable; 152 extern const hci_cmd_t hci_write_class_of_device; 153 extern const hci_cmd_t hci_write_current_iac_lap_two_iacs; 154 extern const hci_cmd_t hci_write_default_erroneous_data_reporting; 155 extern const hci_cmd_t hci_write_default_link_policy_setting; 156 extern const hci_cmd_t hci_write_extended_inquiry_response; 157 extern const hci_cmd_t hci_write_inquiry_mode; 158 extern const hci_cmd_t hci_write_le_host_supported; 159 extern const hci_cmd_t hci_write_link_policy_settings; 160 extern const hci_cmd_t hci_write_link_supervision_timeout; 161 extern const hci_cmd_t hci_write_local_name; 162 extern const hci_cmd_t hci_write_loopback_mode; 163 extern const hci_cmd_t hci_write_num_broadcast_retransmissions; 164 extern const hci_cmd_t hci_write_page_timeout; 165 extern const hci_cmd_t hci_write_pin_type; 166 extern const hci_cmd_t hci_write_page_scan_activity; 167 extern const hci_cmd_t hci_write_scan_enable; 168 extern const hci_cmd_t hci_write_secure_connections_test_mode; 169 extern const hci_cmd_t hci_write_simple_pairing_debug_mode; 170 extern const hci_cmd_t hci_write_simple_pairing_mode; 171 extern const hci_cmd_t hci_write_synchronous_flow_control_enable; 172 173 extern const hci_cmd_t hci_le_add_device_to_white_list; 174 extern const hci_cmd_t hci_le_clear_white_list; 175 extern const hci_cmd_t hci_le_connection_update; 176 extern const hci_cmd_t hci_le_create_connection; 177 extern const hci_cmd_t hci_le_create_connection_cancel; 178 extern const hci_cmd_t hci_le_encrypt; 179 extern const hci_cmd_t hci_le_generate_dhkey; 180 extern const hci_cmd_t hci_le_long_term_key_negative_reply; 181 extern const hci_cmd_t hci_le_long_term_key_request_reply; 182 extern const hci_cmd_t hci_le_rand; 183 extern const hci_cmd_t hci_le_read_advertising_channel_tx_power; 184 extern const hci_cmd_t hci_le_read_buffer_size ; 185 extern const hci_cmd_t hci_le_read_channel_map; 186 extern const hci_cmd_t hci_le_read_local_p256_public_key; 187 extern const hci_cmd_t hci_le_read_maximum_data_length; 188 extern const hci_cmd_t hci_le_read_phy; 189 extern const hci_cmd_t hci_le_read_remote_used_features; 190 extern const hci_cmd_t hci_le_read_suggested_default_data_length; 191 extern const hci_cmd_t hci_le_read_supported_features; 192 extern const hci_cmd_t hci_le_read_supported_states; 193 extern const hci_cmd_t hci_le_read_white_list_size; 194 extern const hci_cmd_t hci_le_receiver_test; 195 extern const hci_cmd_t hci_le_remote_connection_parameter_request_negative_reply; 196 extern const hci_cmd_t hci_le_remote_connection_parameter_request_reply; 197 extern const hci_cmd_t hci_le_remove_device_from_white_list; 198 extern const hci_cmd_t hci_le_set_advertise_enable; 199 extern const hci_cmd_t hci_le_set_advertising_data; 200 extern const hci_cmd_t hci_le_set_advertising_parameters; 201 extern const hci_cmd_t hci_le_set_data_length; 202 extern const hci_cmd_t hci_le_set_default_phy; 203 extern const hci_cmd_t hci_le_set_event_mask; 204 extern const hci_cmd_t hci_le_set_host_channel_classification; 205 extern const hci_cmd_t hci_le_set_phy; 206 extern const hci_cmd_t hci_le_set_random_address; 207 extern const hci_cmd_t hci_le_set_scan_enable; 208 extern const hci_cmd_t hci_le_set_scan_parameters; 209 extern const hci_cmd_t hci_le_set_scan_response_data; 210 extern const hci_cmd_t hci_le_start_encryption; 211 extern const hci_cmd_t hci_le_test_end; 212 extern const hci_cmd_t hci_le_transmitter_test; 213 extern const hci_cmd_t hci_le_write_suggested_default_data_length; 214 215 // Broadcom / Cypress specific HCI commands 216 extern const hci_cmd_t hci_bcm_set_sleep_mode; 217 extern const hci_cmd_t hci_bcm_write_sco_pcm_int; 218 extern const hci_cmd_t hci_bcm_write_tx_power_table; 219 extern const hci_cmd_t hci_bcm_set_tx_pwr; 220 221 // TI specific HCI commands 222 extern const hci_cmd_t hci_ti_drpb_tester_con_tx; 223 extern const hci_cmd_t hci_ti_drpb_tester_packet_tx_rx; 224 225 /** 226 * construct HCI Command based on template 227 * 228 * Format: 229 * 1,2,3,4: one to four byte value 230 * H: HCI connection handle 231 * B: Bluetooth Baseband Address (BD_ADDR) 232 * D: 8 byte data block 233 * E: Extended Inquiry Result 234 * N: Name up to 248 chars, \0 terminated 235 * P: 16 byte Pairing code 236 * A: 31 bytes advertising data 237 * S: Service Record (Data Element Sequence) 238 */ 239 uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr); 240 241 242 #if defined __cplusplus 243 } 244 #endif 245 246 #endif // HCI_CMDS_H 247