xref: /btstack/src/hci_cmd.h (revision 56042629188ece1ffe1766326545c3c2833c10e8)
1*56042629SMatthias Ringwald /*
2*56042629SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3*56042629SMatthias Ringwald  *
4*56042629SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*56042629SMatthias Ringwald  * modification, are permitted provided that the following conditions
6*56042629SMatthias Ringwald  * are met:
7*56042629SMatthias Ringwald  *
8*56042629SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*56042629SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*56042629SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*56042629SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*56042629SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*56042629SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*56042629SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*56042629SMatthias Ringwald  *    from this software without specific prior written permission.
16*56042629SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17*56042629SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18*56042629SMatthias Ringwald  *    monetary gain.
19*56042629SMatthias Ringwald  *
20*56042629SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21*56042629SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*56042629SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*56042629SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24*56042629SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*56042629SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*56042629SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27*56042629SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*56042629SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*56042629SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30*56042629SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*56042629SMatthias Ringwald  * SUCH DAMAGE.
32*56042629SMatthias Ringwald  *
33*56042629SMatthias Ringwald  * Please inquire about commercial licensing options at
34*56042629SMatthias Ringwald  * [email protected]
35*56042629SMatthias Ringwald  *
36*56042629SMatthias Ringwald  */
37*56042629SMatthias Ringwald 
38*56042629SMatthias Ringwald /*
39*56042629SMatthias Ringwald  *  hci_cmd.h
40*56042629SMatthias Ringwald  *
41*56042629SMatthias Ringwald  *  Created by Matthias Ringwald on 7/23/09.
42*56042629SMatthias Ringwald  */
43*56042629SMatthias Ringwald 
44*56042629SMatthias Ringwald #ifndef __HCI_CMDS_H
45*56042629SMatthias Ringwald #define __HCI_CMDS_H
46*56042629SMatthias Ringwald 
47*56042629SMatthias Ringwald #include "bluetooth.h"
48*56042629SMatthias Ringwald #include "btstack_defines.h"
49*56042629SMatthias Ringwald 
50*56042629SMatthias Ringwald #include <stdint.h>
51*56042629SMatthias Ringwald #include <stdarg.h>
52*56042629SMatthias Ringwald 
53*56042629SMatthias Ringwald #if defined __cplusplus
54*56042629SMatthias Ringwald extern "C" {
55*56042629SMatthias Ringwald #endif
56*56042629SMatthias Ringwald 
57*56042629SMatthias Ringwald /**
58*56042629SMatthias Ringwald  *  Hardware state of Bluetooth controller
59*56042629SMatthias Ringwald  */
60*56042629SMatthias Ringwald typedef enum {
61*56042629SMatthias Ringwald     HCI_POWER_OFF = 0,
62*56042629SMatthias Ringwald     HCI_POWER_ON,
63*56042629SMatthias Ringwald     HCI_POWER_SLEEP
64*56042629SMatthias Ringwald } HCI_POWER_MODE;
65*56042629SMatthias Ringwald 
66*56042629SMatthias Ringwald /**
67*56042629SMatthias Ringwald  * State of BTstack
68*56042629SMatthias Ringwald  */
69*56042629SMatthias Ringwald typedef enum {
70*56042629SMatthias Ringwald     HCI_STATE_OFF = 0,
71*56042629SMatthias Ringwald     HCI_STATE_INITIALIZING,
72*56042629SMatthias Ringwald     HCI_STATE_WORKING,
73*56042629SMatthias Ringwald     HCI_STATE_HALTING,
74*56042629SMatthias Ringwald     HCI_STATE_SLEEPING,
75*56042629SMatthias Ringwald     HCI_STATE_FALLING_ASLEEP
76*56042629SMatthias Ringwald } HCI_STATE;
77*56042629SMatthias Ringwald 
78*56042629SMatthias Ringwald /**
79*56042629SMatthias Ringwald  * compact HCI Command packet description
80*56042629SMatthias Ringwald  */
81*56042629SMatthias Ringwald  typedef struct {
82*56042629SMatthias Ringwald     uint16_t    opcode;
83*56042629SMatthias Ringwald     const char *format;
84*56042629SMatthias Ringwald } hci_cmd_t;
85*56042629SMatthias Ringwald 
86*56042629SMatthias Ringwald 
87*56042629SMatthias Ringwald // HCI Commands - see hci_cmd.c for info on parameters
88*56042629SMatthias Ringwald extern const hci_cmd_t hci_accept_connection_request;
89*56042629SMatthias Ringwald extern const hci_cmd_t hci_accept_synchronous_connection;
90*56042629SMatthias Ringwald extern const hci_cmd_t hci_authentication_requested;
91*56042629SMatthias Ringwald extern const hci_cmd_t hci_change_connection_link_key;
92*56042629SMatthias Ringwald extern const hci_cmd_t hci_change_connection_packet_type;
93*56042629SMatthias Ringwald extern const hci_cmd_t hci_create_connection;
94*56042629SMatthias Ringwald extern const hci_cmd_t hci_create_connection_cancel;
95*56042629SMatthias Ringwald extern const hci_cmd_t hci_delete_stored_link_key;
96*56042629SMatthias Ringwald extern const hci_cmd_t hci_enhanced_setup_synchronous_connection;
97*56042629SMatthias Ringwald extern const hci_cmd_t hci_enhanced_accept_synchronous_connection;
98*56042629SMatthias Ringwald extern const hci_cmd_t hci_disconnect;
99*56042629SMatthias Ringwald extern const hci_cmd_t hci_host_buffer_size;
100*56042629SMatthias Ringwald extern const hci_cmd_t hci_inquiry;
101*56042629SMatthias Ringwald extern const hci_cmd_t hci_io_capability_request_reply;
102*56042629SMatthias Ringwald extern const hci_cmd_t hci_io_capability_request_negative_reply;
103*56042629SMatthias Ringwald extern const hci_cmd_t hci_inquiry_cancel;
104*56042629SMatthias Ringwald extern const hci_cmd_t hci_link_key_request_negative_reply;
105*56042629SMatthias Ringwald extern const hci_cmd_t hci_link_key_request_reply;
106*56042629SMatthias Ringwald extern const hci_cmd_t hci_pin_code_request_reply;
107*56042629SMatthias Ringwald extern const hci_cmd_t hci_pin_code_request_negative_reply;
108*56042629SMatthias Ringwald extern const hci_cmd_t hci_qos_setup;
109*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_bd_addr;
110*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_buffer_size;
111*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_le_host_supported;
112*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_link_policy_settings;
113*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_link_supervision_timeout;
114*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_version_information;
115*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_supported_commands;
116*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_local_supported_features;
117*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_num_broadcast_retransmissions;
118*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_remote_supported_features_command;
119*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_rssi;
120*56042629SMatthias Ringwald extern const hci_cmd_t hci_reject_connection_request;
121*56042629SMatthias Ringwald extern const hci_cmd_t hci_remote_name_request;
122*56042629SMatthias Ringwald extern const hci_cmd_t hci_remote_name_request_cancel;
123*56042629SMatthias Ringwald extern const hci_cmd_t hci_remote_oob_data_request_negative_reply;
124*56042629SMatthias Ringwald extern const hci_cmd_t hci_reset;
125*56042629SMatthias Ringwald extern const hci_cmd_t hci_role_discovery;
126*56042629SMatthias Ringwald extern const hci_cmd_t hci_set_event_mask;
127*56042629SMatthias Ringwald extern const hci_cmd_t hci_set_connection_encryption;
128*56042629SMatthias Ringwald extern const hci_cmd_t hci_setup_synchronous_connection;
129*56042629SMatthias Ringwald extern const hci_cmd_t hci_sniff_mode;
130*56042629SMatthias Ringwald extern const hci_cmd_t hci_switch_role_command;
131*56042629SMatthias Ringwald extern const hci_cmd_t hci_user_confirmation_request_negative_reply;
132*56042629SMatthias Ringwald extern const hci_cmd_t hci_user_confirmation_request_reply;
133*56042629SMatthias Ringwald extern const hci_cmd_t hci_user_passkey_request_negative_reply;
134*56042629SMatthias Ringwald extern const hci_cmd_t hci_user_passkey_request_reply;
135*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_authentication_enable;
136*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_class_of_device;
137*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_extended_inquiry_response;
138*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_inquiry_mode;
139*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_le_host_supported;
140*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_link_policy_settings;
141*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_link_supervision_timeout;
142*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_local_name;
143*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_num_broadcast_retransmissions;
144*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_page_timeout;
145*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_scan_enable;
146*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_simple_pairing_mode;
147*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_synchronous_flow_control_enable;
148*56042629SMatthias Ringwald extern const hci_cmd_t hci_read_loopback_mode;
149*56042629SMatthias Ringwald extern const hci_cmd_t hci_write_loopback_mode;
150*56042629SMatthias Ringwald 
151*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_add_device_to_white_list;
152*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_clear_white_list;
153*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_connection_update;
154*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_create_connection;
155*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_create_connection_cancel;
156*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_encrypt;
157*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_long_term_key_negative_reply;
158*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_long_term_key_request_reply;
159*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_rand;
160*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_advertising_channel_tx_power;
161*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_buffer_size ;
162*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_channel_map;
163*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_remote_used_features;
164*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_supported_features;
165*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_supported_states;
166*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_read_white_list_size;
167*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_receiver_test;
168*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_remove_device_from_white_list;
169*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertise_enable;
170*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertising_data;
171*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_advertising_parameters;
172*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_event_mask;
173*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_host_channel_classification;
174*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_random_address;
175*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_enable;
176*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_parameters;
177*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_set_scan_response_data;
178*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_start_encryption;
179*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_test_end;
180*56042629SMatthias Ringwald extern const hci_cmd_t hci_le_transmitter_test;
181*56042629SMatthias Ringwald 
182*56042629SMatthias Ringwald 
183*56042629SMatthias Ringwald /**
184*56042629SMatthias Ringwald  * construct HCI Command based on template
185*56042629SMatthias Ringwald  *
186*56042629SMatthias Ringwald  * Format:
187*56042629SMatthias Ringwald  *   1,2,3,4: one to four byte value
188*56042629SMatthias Ringwald  *   H: HCI connection handle
189*56042629SMatthias Ringwald  *   B: Bluetooth Baseband Address (BD_ADDR)
190*56042629SMatthias Ringwald  *   D: 8 byte data block
191*56042629SMatthias Ringwald  *   E: Extended Inquiry Result
192*56042629SMatthias Ringwald  *   N: Name up to 248 chars, \0 terminated
193*56042629SMatthias Ringwald  *   P: 16 byte Pairing code
194*56042629SMatthias Ringwald  *   A: 31 bytes advertising data
195*56042629SMatthias Ringwald  *   S: Service Record (Data Element Sequence)
196*56042629SMatthias Ringwald  */
197*56042629SMatthias Ringwald  uint16_t hci_cmd_create_from_template(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr);
198*56042629SMatthias Ringwald 
199*56042629SMatthias Ringwald 
200*56042629SMatthias Ringwald #if defined __cplusplus
201*56042629SMatthias Ringwald }
202*56042629SMatthias Ringwald #endif
203*56042629SMatthias Ringwald 
204*56042629SMatthias Ringwald #endif // __HCI_CMDS_H
205