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_enhanced_setup_synchronous_connection; 97 extern const hci_cmd_t hci_enhanced_accept_synchronous_connection; 98 extern const hci_cmd_t hci_disconnect; 99 extern const hci_cmd_t hci_host_buffer_size; 100 extern const hci_cmd_t hci_inquiry; 101 extern const hci_cmd_t hci_io_capability_request_reply; 102 extern const hci_cmd_t hci_io_capability_request_negative_reply; 103 extern const hci_cmd_t hci_inquiry_cancel; 104 extern const hci_cmd_t hci_link_key_request_negative_reply; 105 extern const hci_cmd_t hci_link_key_request_reply; 106 extern const hci_cmd_t hci_pin_code_request_reply; 107 extern const hci_cmd_t hci_pin_code_request_negative_reply; 108 extern const hci_cmd_t hci_qos_setup; 109 extern const hci_cmd_t hci_read_bd_addr; 110 extern const hci_cmd_t hci_read_buffer_size; 111 extern const hci_cmd_t hci_read_le_host_supported; 112 extern const hci_cmd_t hci_read_link_policy_settings; 113 extern const hci_cmd_t hci_read_link_supervision_timeout; 114 extern const hci_cmd_t hci_read_local_version_information; 115 extern const hci_cmd_t hci_read_local_supported_commands; 116 extern const hci_cmd_t hci_read_local_supported_features; 117 extern const hci_cmd_t hci_read_num_broadcast_retransmissions; 118 extern const hci_cmd_t hci_read_remote_supported_features_command; 119 extern const hci_cmd_t hci_read_rssi; 120 extern const hci_cmd_t hci_reject_connection_request; 121 extern const hci_cmd_t hci_remote_name_request; 122 extern const hci_cmd_t hci_remote_name_request_cancel; 123 extern const hci_cmd_t hci_remote_oob_data_request_negative_reply; 124 extern const hci_cmd_t hci_reset; 125 extern const hci_cmd_t hci_role_discovery; 126 extern const hci_cmd_t hci_set_event_mask; 127 extern const hci_cmd_t hci_set_connection_encryption; 128 extern const hci_cmd_t hci_setup_synchronous_connection; 129 extern const hci_cmd_t hci_sniff_mode; 130 extern const hci_cmd_t hci_switch_role_command; 131 extern const hci_cmd_t hci_user_confirmation_request_negative_reply; 132 extern const hci_cmd_t hci_user_confirmation_request_reply; 133 extern const hci_cmd_t hci_user_passkey_request_negative_reply; 134 extern const hci_cmd_t hci_user_passkey_request_reply; 135 extern const hci_cmd_t hci_write_authentication_enable; 136 extern const hci_cmd_t hci_write_class_of_device; 137 extern const hci_cmd_t hci_write_extended_inquiry_response; 138 extern const hci_cmd_t hci_write_inquiry_mode; 139 extern const hci_cmd_t hci_write_le_host_supported; 140 extern const hci_cmd_t hci_write_link_policy_settings; 141 extern const hci_cmd_t hci_write_link_supervision_timeout; 142 extern const hci_cmd_t hci_write_local_name; 143 extern const hci_cmd_t hci_write_num_broadcast_retransmissions; 144 extern const hci_cmd_t hci_write_page_timeout; 145 extern const hci_cmd_t hci_write_scan_enable; 146 extern const hci_cmd_t hci_write_simple_pairing_mode; 147 extern const hci_cmd_t hci_write_synchronous_flow_control_enable; 148 extern const hci_cmd_t hci_read_loopback_mode; 149 extern const hci_cmd_t hci_write_loopback_mode; 150 151 extern const hci_cmd_t hci_le_add_device_to_white_list; 152 extern const hci_cmd_t hci_le_clear_white_list; 153 extern const hci_cmd_t hci_le_connection_update; 154 extern const hci_cmd_t hci_le_create_connection; 155 extern const hci_cmd_t hci_le_create_connection_cancel; 156 extern const hci_cmd_t hci_le_encrypt; 157 extern const hci_cmd_t hci_le_long_term_key_negative_reply; 158 extern const hci_cmd_t hci_le_long_term_key_request_reply; 159 extern const hci_cmd_t hci_le_rand; 160 extern const hci_cmd_t hci_le_read_advertising_channel_tx_power; 161 extern const hci_cmd_t hci_le_read_buffer_size ; 162 extern const hci_cmd_t hci_le_read_channel_map; 163 extern const hci_cmd_t hci_le_read_remote_used_features; 164 extern const hci_cmd_t hci_le_read_supported_features; 165 extern const hci_cmd_t hci_le_read_supported_states; 166 extern const hci_cmd_t hci_le_read_white_list_size; 167 extern const hci_cmd_t hci_le_receiver_test; 168 extern const hci_cmd_t hci_le_remove_device_from_white_list; 169 extern const hci_cmd_t hci_le_set_advertise_enable; 170 extern const hci_cmd_t hci_le_set_advertising_data; 171 extern const hci_cmd_t hci_le_set_advertising_parameters; 172 extern const hci_cmd_t hci_le_set_event_mask; 173 extern const hci_cmd_t hci_le_set_host_channel_classification; 174 extern const hci_cmd_t hci_le_set_random_address; 175 extern const hci_cmd_t hci_le_set_scan_enable; 176 extern const hci_cmd_t hci_le_set_scan_parameters; 177 extern const hci_cmd_t hci_le_set_scan_response_data; 178 extern const hci_cmd_t hci_le_start_encryption; 179 extern const hci_cmd_t hci_le_test_end; 180 extern const hci_cmd_t hci_le_transmitter_test; 181 182 183 /** 184 * construct HCI Command based on template 185 * 186 * Format: 187 * 1,2,3,4: one to four byte value 188 * H: HCI connection handle 189 * B: Bluetooth Baseband Address (BD_ADDR) 190 * D: 8 byte data block 191 * E: Extended Inquiry Result 192 * N: Name up to 248 chars, \0 terminated 193 * P: 16 byte Pairing code 194 * A: 31 bytes advertising data 195 * S: Service Record (Data Element Sequence) 196 */ 197 uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr); 198 199 200 #if defined __cplusplus 201 } 202 #endif 203 204 #endif // __HCI_CMDS_H 205