bt_hh.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #ifndef ANDROID_INCLUDE_BT_HH_H
18 #define ANDROID_INCLUDE_BT_HH_H
19 
20 #include <stdint.h>
21 
22 __BEGIN_DECLS
23 
24 #define BTHH_MAX_DSC_LEN 884
25 
26 /* HH connection states */
27 typedef enum
28 {
40 
41 typedef enum
42 {
43  BTHH_OK = 0,
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 */
59 
60 /* Protocol modes */
61 typedef enum {
66 
67 /* Report types */
68 typedef enum {
73 
74 typedef struct
75 {
76  int attr_mask;
77  uint8_t sub_class;
78  uint8_t app_id;
79  int vendor_id;
81  int version;
82  uint8_t ctry_code;
83  int dl_len;
84  uint8_t dsc_list[BTHH_MAX_DSC_LEN];
86 
87 /** Callback for connection state change.
88  * state will have one of the values from bthh_connection_state_t
89  */
90 typedef void (* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state);
91 
92 /** Callback for vitual unplug api.
93  * the status of the vitual unplug
94  */
95 typedef void (* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status);
96 
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
99  */
100 typedef void (* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info);
101 
102 /** Callback for get protocol api.
103  * the protocol mode is one of the value from bthh_protocol_mode_t
104  */
105 typedef void (* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode);
106 
107 /** Callback for get/set_idle_time api.
108  */
109 typedef void (* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate);
110 
111 
112 /** Callback for get report api.
113  * if staus is ok rpt_data contains the report data
114  */
115 typedef void (* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size);
116 
117 /** Callback for set_report/set_protocol api and if error
118  * occurs for get_report/get_protocol api.
119  */
120 typedef void (* bthh_handshake_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status);
121 
122 
123 /** BT-HH callback structure. */
124 typedef struct {
125  /** set to sizeof(BtHfCallbacks) */
126  size_t size;
134 
136 
137 
138 
139 /** Represents the standard BT-HH interface. */
140 typedef struct {
141 
142  /** set to sizeof(BtHhInterface) */
143  size_t size;
144 
145  /**
146  * Register the BtHh callbacks
147  */
148  bt_status_t (*init)( bthh_callbacks_t* callbacks );
149 
150  /** connect to hid device */
151  bt_status_t (*connect)( bt_bdaddr_t *bd_addr);
152 
153  /** dis-connect from hid device */
154  bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
155 
156  /** Virtual UnPlug (VUP) the specified HID device */
157  bt_status_t (*virtual_unplug)(bt_bdaddr_t *bd_addr);
158 
159  /** Set the HID device descriptor for the specified HID device. */
160  bt_status_t (*set_info)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info );
161 
162  /** Get the HID proto mode. */
163  bt_status_t (*get_protocol) (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
164 
165  /** Set the HID proto mode. */
166  bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
167 
168  /** Send a GET_REPORT to HID device. */
169  bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize);
170 
171  /** Send a SET_REPORT to HID device. */
172  bt_status_t (*set_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, char* report);
173 
174  /** Send data to HID device. */
175  bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data);
176 
177  /** Closes the interface. */
178  void (*cleanup)( void );
179 
181 __END_DECLS
182 
183 #endif /* ANDROID_INCLUDE_BT_HH_H */
184 
185 
size_t size
Definition: bt_hh.h:126
Definition: bt_hh.h:49
#define BTHH_MAX_DSC_LEN
Definition: bt_hh.h:24
void(* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t *rpt_data, int rpt_size)
Definition: bt_hh.h:115
bthh_get_report_callback get_report_cb
Definition: bt_hh.h:131
void(* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status)
Definition: bt_hh.h:95
bthh_connection_state_t
Definition: bt_hh.h:27
uint8_t ctry_code
Definition: bt_hh.h:82
bt_status_t
Definition: bluetooth.h:80
uint8_t sub_class
Definition: bt_hh.h:77
bthh_virtual_unplug_callback virtual_unplug_cb
Definition: bt_hh.h:132
int attr_mask
Definition: bt_hh.h:76
void(* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)
Definition: bt_hh.h:100
void(* bthh_handshake_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status)
Definition: bt_hh.h:120
bthh_hid_info_callback hid_info_cb
Definition: bt_hh.h:128
bthh_connection_state_callback connection_state_cb
Definition: bt_hh.h:127
bthh_report_type_t
Definition: bt_hh.h:68
int dl_len
Definition: bt_hh.h:83
bthh_status_t
Definition: bt_hh.h:41
uint8_t app_id
Definition: bt_hh.h:78
bthh_handshake_callback handshake_cb
Definition: bt_hh.h:133
void(* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode)
Definition: bt_hh.h:105
void(* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate)
Definition: bt_hh.h:109
bthh_idle_time_callback idle_time_cb
Definition: bt_hh.h:130
int vendor_id
Definition: bt_hh.h:79
size_t size
Definition: bt_hh.h:143
bthh_protocol_mode_t
Definition: bt_hh.h:61
int version
Definition: bt_hh.h:81
int product_id
Definition: bt_hh.h:80
Definition: bt_hh.h:43
void(* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state)
Definition: bt_hh.h:90
bthh_protocol_mode_callback protocol_mode_cb
Definition: bt_hh.h:129