xref: /btstack/src/hci_cmd.h (revision 80e33422a96c028b3a9c308fc4b9b874712dafb4)
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 
44*80e33422SMatthias Ringwald #ifndef HCI_CMDS_H
45*80e33422SMatthias 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;
11456042629SMatthias Ringwald extern const hci_cmd_t hci_read_le_host_supported;
11556042629SMatthias Ringwald extern const hci_cmd_t hci_read_link_policy_settings;
11656042629SMatthias Ringwald extern const hci_cmd_t hci_read_link_supervision_timeout;
117bed80775SMatthias Ringwald extern const hci_cmd_t hci_read_local_extended_ob_data;
118237daac5SMatthias Ringwald extern const hci_cmd_t hci_read_local_extended_oob_data;
119e90bae01SMatthias Ringwald extern const hci_cmd_t hci_read_local_name;
120237daac5SMatthias Ringwald extern const hci_cmd_t hci_read_local_oob_data;
12156042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_supported_commands;
12256042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_supported_features;
123237daac5SMatthias Ringwald extern const hci_cmd_t hci_read_local_version_information;
124bed80775SMatthias Ringwald extern const hci_cmd_t hci_read_loopback_mode;
12556042629SMatthias Ringwald extern const hci_cmd_t hci_read_num_broadcast_retransmissions;
12656042629SMatthias Ringwald extern const hci_cmd_t hci_read_remote_supported_features_command;
1278b22c04dSMatthias Ringwald extern const hci_cmd_t hci_read_remote_version_information;
12856042629SMatthias Ringwald extern const hci_cmd_t hci_read_rssi;
12956042629SMatthias Ringwald extern const hci_cmd_t hci_reject_connection_request;
13056042629SMatthias Ringwald extern const hci_cmd_t hci_remote_name_request;
13156042629SMatthias Ringwald extern const hci_cmd_t hci_remote_name_request_cancel;
13256042629SMatthias Ringwald extern const hci_cmd_t hci_remote_oob_data_request_negative_reply;
133bed80775SMatthias Ringwald extern const hci_cmd_t hci_remote_oob_data_request_reply;
13456042629SMatthias Ringwald extern const hci_cmd_t hci_reset;
13556042629SMatthias Ringwald extern const hci_cmd_t hci_role_discovery;
13656042629SMatthias Ringwald extern const hci_cmd_t hci_set_connection_encryption;
1372b838201SMatthias Ringwald extern const hci_cmd_t hci_set_controller_to_host_flow_control;
13884ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_set_event_mask;
13956042629SMatthias Ringwald extern const hci_cmd_t hci_setup_synchronous_connection;
14056042629SMatthias Ringwald extern const hci_cmd_t hci_sniff_mode;
14156042629SMatthias Ringwald extern const hci_cmd_t hci_switch_role_command;
14256042629SMatthias Ringwald extern const hci_cmd_t hci_user_confirmation_request_negative_reply;
14356042629SMatthias Ringwald extern const hci_cmd_t hci_user_confirmation_request_reply;
14456042629SMatthias Ringwald extern const hci_cmd_t hci_user_passkey_request_negative_reply;
14556042629SMatthias Ringwald extern const hci_cmd_t hci_user_passkey_request_reply;
14656042629SMatthias Ringwald extern const hci_cmd_t hci_write_authentication_enable;
14756042629SMatthias Ringwald extern const hci_cmd_t hci_write_class_of_device;
1489119d792SMilanka Ringwald extern const hci_cmd_t hci_write_current_iac_lap_two_iacs;
149483c5078SMatthias Ringwald extern const hci_cmd_t hci_write_default_erroneous_data_reporting;
15053138e7aSMatthias Ringwald extern const hci_cmd_t hci_write_default_link_policy_setting;
15156042629SMatthias Ringwald extern const hci_cmd_t hci_write_extended_inquiry_response;
15256042629SMatthias Ringwald extern const hci_cmd_t hci_write_inquiry_mode;
15356042629SMatthias Ringwald extern const hci_cmd_t hci_write_le_host_supported;
15456042629SMatthias Ringwald extern const hci_cmd_t hci_write_link_policy_settings;
15556042629SMatthias Ringwald extern const hci_cmd_t hci_write_link_supervision_timeout;
15656042629SMatthias Ringwald extern const hci_cmd_t hci_write_local_name;
157bed80775SMatthias Ringwald extern const hci_cmd_t hci_write_loopback_mode;
15856042629SMatthias Ringwald extern const hci_cmd_t hci_write_num_broadcast_retransmissions;
15956042629SMatthias Ringwald extern const hci_cmd_t hci_write_page_timeout;
16056042629SMatthias Ringwald extern const hci_cmd_t hci_write_scan_enable;
16184ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_write_secure_connections_test_mode;
16284ca9bd8SMatthias Ringwald extern const hci_cmd_t hci_write_simple_pairing_debug_mode;
16356042629SMatthias Ringwald extern const hci_cmd_t hci_write_simple_pairing_mode;
16456042629SMatthias Ringwald extern const hci_cmd_t hci_write_synchronous_flow_control_enable;
16556042629SMatthias Ringwald 
16656042629SMatthias Ringwald extern const hci_cmd_t hci_le_add_device_to_white_list;
16756042629SMatthias Ringwald extern const hci_cmd_t hci_le_clear_white_list;
16856042629SMatthias Ringwald extern const hci_cmd_t hci_le_connection_update;
16956042629SMatthias Ringwald extern const hci_cmd_t hci_le_create_connection;
17056042629SMatthias Ringwald extern const hci_cmd_t hci_le_create_connection_cancel;
17156042629SMatthias Ringwald extern const hci_cmd_t hci_le_encrypt;
17282180fcaSMatthias Ringwald extern const hci_cmd_t hci_le_generate_dhkey;
17356042629SMatthias Ringwald extern const hci_cmd_t hci_le_long_term_key_negative_reply;
17456042629SMatthias Ringwald extern const hci_cmd_t hci_le_long_term_key_request_reply;
17556042629SMatthias Ringwald extern const hci_cmd_t hci_le_rand;
17656042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_advertising_channel_tx_power;
17756042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_buffer_size ;
17856042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_channel_map;
17982180fcaSMatthias Ringwald extern const hci_cmd_t hci_le_read_local_p256_public_key;
1800ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_read_maximum_data_length;
181ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_read_phy;
18256042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_remote_used_features;
1830ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_read_suggested_default_data_length;
18456042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_supported_features;
18556042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_supported_states;
18656042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_white_list_size;
18756042629SMatthias Ringwald extern const hci_cmd_t hci_le_receiver_test;
188fe704c95SMatthias Ringwald extern const hci_cmd_t hci_le_remote_connection_parameter_request_negative_reply;
189ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_remote_connection_parameter_request_reply;
19056042629SMatthias Ringwald extern const hci_cmd_t hci_le_remove_device_from_white_list;
19156042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertise_enable;
19256042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertising_data;
19356042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertising_parameters;
1940ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_set_data_length;
195ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_set_default_phy;
19656042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_event_mask;
19756042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_host_channel_classification;
198ca13daefSMatthias Ringwald extern const hci_cmd_t hci_le_set_phy;
19956042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_random_address;
20056042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_enable;
20156042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_parameters;
20256042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_response_data;
20356042629SMatthias Ringwald extern const hci_cmd_t hci_le_start_encryption;
20456042629SMatthias Ringwald extern const hci_cmd_t hci_le_test_end;
20556042629SMatthias Ringwald extern const hci_cmd_t hci_le_transmitter_test;
2060ea2847fSMatthias Ringwald extern const hci_cmd_t hci_le_write_suggested_default_data_length;
207a42798c3SMatthias Ringwald 
208a42798c3SMatthias Ringwald // Broadcom / Cypress specific HCI commands
209a42798c3SMatthias Ringwald extern const hci_cmd_t hci_bcm_write_sco_pcm_int;
210a42798c3SMatthias Ringwald 
21156042629SMatthias Ringwald /**
21256042629SMatthias Ringwald  * construct HCI Command based on template
21356042629SMatthias Ringwald  *
21456042629SMatthias Ringwald  * Format:
21556042629SMatthias Ringwald  *   1,2,3,4: one to four byte value
21656042629SMatthias Ringwald  *   H: HCI connection handle
21756042629SMatthias Ringwald  *   B: Bluetooth Baseband Address (BD_ADDR)
21856042629SMatthias Ringwald  *   D: 8 byte data block
21956042629SMatthias Ringwald  *   E: Extended Inquiry Result
22056042629SMatthias Ringwald  *   N: Name up to 248 chars, \0 terminated
22156042629SMatthias Ringwald  *   P: 16 byte Pairing code
22256042629SMatthias Ringwald  *   A: 31 bytes advertising data
22356042629SMatthias Ringwald  *   S: Service Record (Data Element Sequence)
22456042629SMatthias Ringwald  */
22556042629SMatthias Ringwald  uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr);
22656042629SMatthias Ringwald 
22756042629SMatthias Ringwald 
22856042629SMatthias Ringwald #if defined __cplusplus
22956042629SMatthias Ringwald }
23056042629SMatthias Ringwald #endif
23156042629SMatthias Ringwald 
232*80e33422SMatthias Ringwald #endif // HCI_CMDS_H
233