2 * Copyright (C) 2012 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ANDROID_INCLUDE_BT_HH_H
18 #define ANDROID_INCLUDE_BT_HH_H
24 #define BTHH_MAX_DSC_LEN 884
26 /* HH connection states */
29 BTHH_CONN_STATE_CONNECTED = 0,
30 BTHH_CONN_STATE_CONNECTING,
31 BTHH_CONN_STATE_DISCONNECTED,
32 BTHH_CONN_STATE_DISCONNECTING,
33 BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST,
34 BTHH_CONN_STATE_FAILED_KBD_FROM_HOST,
35 BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES,
36 BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER,
37 BTHH_CONN_STATE_FAILED_GENERIC,
38 BTHH_CONN_STATE_UNKNOWN
39 } bthh_connection_state_t;
44 BTHH_HS_HID_NOT_READY, /* handshake error : device not ready */
45 BTHH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
46 BTHH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */
47 BTHH_HS_INVALID_PARAM, /* handshake error : invalid paremter */
48 BTHH_HS_ERROR, /* handshake error : unspecified HS error */
49 BTHH_ERR, /* general BTA HH error */
50 BTHH_ERR_SDP, /* SDP error */
51 BTHH_ERR_PROTO, /* SET_Protocol error,
52 only used in BTA_HH_OPEN_EVT callback */
53 BTHH_ERR_DB_FULL, /* device database full error, used */
54 BTHH_ERR_TOD_UNSPT, /* type of device not supported */
55 BTHH_ERR_NO_RES, /* out of system resources */
56 BTHH_ERR_AUTH_FAILED, /* authentication fail */
62 BTHH_REPORT_MODE = 0x00,
63 BTHH_BOOT_MODE = 0x01,
64 BTHH_UNSUPPORTED_MODE = 0xff
65 }bthh_protocol_mode_t;
69 BTHH_INPUT_REPORT = 1,
84 uint8_t dsc_list[BTHH_MAX_DSC_LEN];
87 /** Callback for connection state change.
88 * state will have one of the values from bthh_connection_state_t
90 typedef void (* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state);
92 /** Callback for vitual unplug api.
93 * the status of the vitual unplug
95 typedef void (* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status);
97 /** Callback for get hid info
98 * hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id, version, ctry_code, len
100 typedef void (* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t *hid_info);
102 /** Callback for get protocol api.
103 * the protocol mode is one of the value from bthh_protocol_mode_t
105 typedef void (* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode);
107 /** Callback for get/set_idle_time api.
109 typedef void (* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate);
111 /** Callback for get report api.
112 * if staus is ok rpt_data contains the report data
114 typedef void (* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size);
116 /** Callback for set_report/set_protocol api and if error
117 * occurs for get_report/get_protocol api.
119 typedef void (* bthh_handshake_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status);
121 /** BT-HH callback structure. */
123 /** set to sizeof(BtHfCallbacks) */
125 bthh_connection_state_callback connection_state_cb;
126 bthh_hid_info_callback hid_info_cb;
127 bthh_protocol_mode_callback protocol_mode_cb;
128 bthh_idle_time_callback idle_time_cb;
129 bthh_get_report_callback get_report_cb;
130 bthh_virtual_unplug_callback virtual_unplug_cb;
131 bthh_handshake_callback handshake_cb;
134 /** Represents the standard BT-HH interface. */
137 /** set to sizeof(BtHhInterface) */
141 * Register the BtHh callbacks
143 bt_status_t (*init)( bthh_callbacks_t* callbacks );
145 /** connect to hid device */
146 bt_status_t (*connect)( bt_bdaddr_t *bd_addr);
148 /** dis-connect from hid device */
149 bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
151 /** Virtual UnPlug (VUP) the specified HID device */
152 bt_status_t (*virtual_unplug)(bt_bdaddr_t *bd_addr);
154 /** Set the HID device descriptor for the specified HID device. */
155 bt_status_t (*set_info)(bt_bdaddr_t *bd_addr, bthh_hid_info_t *hid_info );
157 /** Get the HID proto mode. */
158 bt_status_t (*get_protocol) (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
160 /** Set the HID proto mode. */
161 bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
163 /** Send a GET_REPORT to HID device. */
164 bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize);
166 /** Send a SET_REPORT to HID device. */
167 bt_status_t (*set_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, char* report);
169 /** Send data to HID device. */
170 bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data);
172 /** Closes the interface. */
173 void (*cleanup)( void );
178 #endif /* ANDROID_INCLUDE_BT_HH_H */