FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/ms/src/mfw/mfw_bt_dm.h @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +-------------------------------------------------------------------+ | |
3 | PROJECT: MMI-Framework (8445) $Workfile:: mfw_bt_dm.h $| | |
4 | $Author:: NDH $Revision:: 1 $| | |
5 | CREATED: 17.04.04 $Modtime:: 17.04.04 10:48 $| | |
6 | STATE : code | | |
7 +-------------------------------------------------------------------+ | |
8 | |
9 | |
10 MODULE : MFW_BT | |
11 | |
12 PURPOSE : This module contains the definitions for MFW Bluetooth Device Manager Profile | |
13 | |
14 */ | |
15 | |
16 #ifndef DEF_MFW_BT_DM_HEADER | |
17 #define DEF_MFW_BT_DM_HEADER | |
18 | |
19 #include "bta_api.h" | |
20 #include "bd.h" | |
21 #include "mfw_bte.h" | |
22 | |
23 #define MFW_BT_NAME_LENGTH 34 | |
24 #define MFW_BT_DEFAULT_INQ_DURATION 4 | |
25 #define MFW_BT_MAX_PIN_CODE_LEN 16 | |
26 #define MFW_BT_MAX_CONSEC_CONNECTIONS MAX_L2CAP_LINKS | |
27 | |
28 /* redefine the BD_ADDR type in a "MFW-like" way */ | |
29 typedef BD_ADDR T_MFW_BT_DM_DEV_ADDR; | |
30 #define MFW_BT_DM_DEV_ADDR_LEN BD_ADDR_LEN | |
31 | |
32 /* | |
33 ** Event Parameter Structure Definitions | |
34 */ | |
35 typedef tBTA_DM_ENABLE T_MFW_BT_DM_ENABLE; | |
36 typedef tBTA_DM_LINK_UP T_MFW_BT_DM_LINK_UP; | |
37 typedef tBTA_DM_LINK_DOWN T_MFW_BT_DM_LINK_DOWN; | |
38 typedef tBTA_DM_PIN_REQ T_MFW_BT_DM_PIN_REQ; | |
39 | |
40 typedef tBTA_DM_AUTHORIZE T_MFW_BT_DM_AUTHORIZE_REQ; | |
41 typedef tBTA_DM_SIG_STRENGTH T_MFW_BT_DM_SIG_STRENGTH_IND; | |
42 | |
43 /* Search structures */ | |
44 typedef tBTA_DM_INQ_RES T_MFW_BT_DM_INQ_RES; | |
45 typedef tBTA_DM_INQ_CMPL T_MFW_BT_DM_INQ_CMPL; | |
46 | |
47 /* other BT structures*/ | |
48 typedef tBTA_SERVICE_MASK T_MFW_BT_SERVICE_MASK; | |
49 typedef tBTA_SIG_STRENGTH_MASK T_MFW_BT_DM_SIG_STRENGTH; | |
50 | |
51 typedef tBTA_DM_DISC T_MFW_BT_VIS_MASK; | |
52 | |
53 | |
54 enum | |
55 { | |
56 MFW_BT_AUTH_FAIL = 0, | |
57 MFW_BT_AUTH_ALWAYS, | |
58 MFW_BT_AUTH_ONCE | |
59 }; | |
60 | |
61 typedef UINT8 T_MFW_BT_AUTHORIZE; | |
62 | |
63 typedef struct | |
64 { | |
65 BD_ADDR bd_addr; | |
66 UINT8 bd_name[MFW_BT_NAME_LENGTH]; | |
67 BOOL is_success; | |
68 } | |
69 T_MFW_BT_DM_AUTH_CMPL; | |
70 | |
71 /* remote device */ | |
72 typedef struct | |
73 { | |
74 /* important!The first parameters should be the same as T_MFW_BT_REM_DEVICE_INFO */ | |
75 BD_ADDR bd_addr; | |
76 char friendly_name[MFW_BT_NAME_LENGTH]; | |
77 DEV_CLASS dev_class; | |
78 BOOL link_key_present; | |
79 BOOL is_trusted; | |
80 T_MFW_BT_SERVICE_MASK trusted_services; | |
81 T_MFW_BT_SERVICE_MASK services; | |
82 BOOL is_new; | |
83 /* then these are "internal" parameters */ | |
84 BOOL in_use; | |
85 char name[MFW_BT_NAME_LENGTH]; | |
86 LINK_KEY link_key; | |
87 } | |
88 T_MFW_BT_REM_DEVICE; | |
89 | |
90 | |
91 /* remote device. !!! Please keep this structure synchronized with the | |
92 previous one: T_MFW_BT_REM_DEVICE !!! */ | |
93 typedef struct | |
94 { | |
95 BD_ADDR bd_addr; | |
96 char name[MFW_BT_NAME_LENGTH]; | |
97 DEV_CLASS dev_class; | |
98 BOOLEAN link_key_present; | |
99 BOOLEAN is_trusted; | |
100 T_MFW_BT_SERVICE_MASK trusted_services; | |
101 T_MFW_BT_SERVICE_MASK services; | |
102 BOOL is_new; /* specify whether this device is already or not into our device DB */ | |
103 } | |
104 T_MFW_BT_REM_DEVICE_INFO; | |
105 | |
106 typedef T_MFW_BT_REM_DEVICE_INFO T_MFW_BT_DM_DISC_RES; | |
107 | |
108 | |
109 /* MFW_BT main control block */ | |
110 typedef struct | |
111 { | |
112 T_MFW_BT_SERVICE_MASK ui_current_active_connection; /* active connection mask */ | |
113 T_MFW_BT_REM_DEVICE *p_selected_rem_device; /* pointer to selected device */ | |
114 BD_ADDR peer_bdaddr; /* peer bdaddr stored for pin_reply etc*/ | |
115 UINT8 peer_name[MFW_BT_NAME_LENGTH]; /* bluetooth name of peer device for pin reply etc */ | |
116 T_MFW_BT_SERVICE_MASK peer_service; /* peer services stored for auth etc*/ | |
117 T_MFW_BT_SERVICE_MASK search_services; /* services to search for */ | |
118 BOOL is_discovery; /* remember if it's an inquiry or a discovery */ | |
119 T_MFW_BT_SERVICE_MASK established_linked; /* which services have an established link */ | |
120 BOOL is_name_requested; /* remember if we asked for the local name */ | |
121 BOOL is_started; /* if BT is not started, we will not call BTA APIs */ | |
122 } | |
123 T_MFW_BT_CB; | |
124 | |
125 extern T_MFW_BT_CB mfw_bt_cb; | |
126 | |
127 | |
128 | |
129 #define MFW_BT_NUM_REM_DEVICE 10 | |
130 | |
131 /* Inquiry results database */ | |
132 typedef struct | |
133 { | |
134 T_MFW_BT_REM_DEVICE remote_device[MFW_BT_NUM_REM_DEVICE]; | |
135 UINT8 rem_index; | |
136 } | |
137 tMFW_BT_INQ_DB; | |
138 | |
139 | |
140 | |
141 /* | |
142 ** The following Macros define the Device Manager Signals (BT -> Mfw) | |
143 */ | |
144 #define T_MFW_BT_DM_SEC_EVT tBTA_DM_SEC_EVT | |
145 #define T_MFW_BT_DM_SEC_SIG_DATA tBTA_DM_SEC | |
146 | |
147 #define T_MFW_BT_DM_SRCH_EVT tBTA_DM_SEARCH_EVT | |
148 #define T_MFW_BT_DM_SRCH_SIG_DATA tBTA_DM_SEARCH | |
149 | |
150 /* | |
151 ** Event Identifiers (Mfw -> BMI) | |
152 */ | |
153 #define E_BT_DM_LINK_UP (T_MFW_EVENT)0x00000010 | |
154 #define E_BT_DM_LINK_DOWN (T_MFW_EVENT)0x00000020 | |
155 #define E_BT_DM_INQ_RES (T_MFW_EVENT)0x00000030 | |
156 #define E_BT_DM_INQ_CMPL (T_MFW_EVENT)0x00000040 | |
157 #define E_BT_DM_DISC_RES (T_MFW_EVENT)0x00000050 | |
158 #define E_BT_DM_DISC_CMPL (T_MFW_EVENT)0x00000060 | |
159 #define E_BT_DM_PIN_REQ (T_MFW_EVENT)0x00000070 | |
160 #define E_BT_DM_AUTH_CMPL (T_MFW_EVENT)0x00000080 | |
161 #define E_BT_DM_AUTHORIZE_REQ (T_MFW_EVENT)0x00000090 | |
162 #define E_BT_DM_DEV_NAME_REQ (T_MFW_EVENT)0x000000A0 | |
163 #define E_BT_DM_ENABLE (T_MFW_EVENT)0x00000100 | |
164 | |
165 | |
166 #define E_BT_DM_SIG_STRENGTH_IND (T_MFW_EVENT)0x000000E0 | |
167 #define E_BT_ALL_DM_SERVICES (T_MFW_EVENT)0x000000F0 | |
168 | |
169 | |
170 | |
171 | |
172 | |
173 /******************************************************************************* | |
174 $Function: mfw_bt_dm_set_visibility | |
175 $Description: set visibility of local BT device | |
176 $Returns: T_MFW_BT_STATUS. Success or fail. | |
177 $Arguments: is_visible: new visibility setting. is_temp: define whether it is a temporary | |
178 modification ( TRUE ) or a permanent one ( FALSE ). | |
179 *******************************************************************************/ | |
180 T_MFW_BT_STATUS mfw_bt_dm_set_visibility( BOOL is_visible, BOOL is_temp); | |
181 | |
182 /******************************************************************************* | |
183 $Function: mfw_bt_dm_get_visibility | |
184 $Description: get visibility of local BT device | |
185 $Returns: TRUE if visible, FALSE if not. | |
186 $Arguments: none | |
187 *******************************************************************************/ | |
188 BOOL mfw_bt_dm_get_visibility( void ); | |
189 | |
190 /******************************************************************************* | |
191 $Function: mfw_bt_dm_get_local_name | |
192 $Description: read local BT device name | |
193 $Returns: a pointer to a string. NULL if no name available. One should make a copy of | |
194 string if he wants to use it/modify it. | |
195 $Arguments: none | |
196 *******************************************************************************/ | |
197 UINT8 * mfw_bt_dm_get_local_name( void ); | |
198 | |
199 /******************************************************************************* | |
200 $Function: mfw_bt_dm_set_local_name | |
201 $Description: set local BT device name | |
202 $Returns: T_MFW_BT_STATUS | |
203 $Arguments: new name. Pointer to a string. This string is copied locally. Buffer is not freed. | |
204 *******************************************************************************/ | |
205 T_MFW_BT_STATUS mfw_bt_dm_set_local_name( INT8 *name ); | |
206 | |
207 /******************************************************************************* | |
208 $Function: mfw_bt_dm_get_bt_status | |
209 $Description: get the status of the local Bluetooth system. Used at start-up to decide whether | |
210 or not we want BT to be started by default. | |
211 $Returns: MFW_BT_SUCCESS is BT is started. 0 if OFF | |
212 $Arguments: | |
213 *******************************************************************************/ | |
214 BOOL mfw_bt_dm_get_bt_status( void ); | |
215 | |
216 /******************************************************************************* | |
217 $Function: mfw_bt_dm_pin_code | |
218 $Description: used by BMI to send back a pin code | |
219 $Returns: T_MFW_BT_STATUS. MFW_BT_NOT_INITIALISED is BT is not started. | |
220 $Arguments: pin code and pin code length. This data is copied. | |
221 *******************************************************************************/ | |
222 T_MFW_BT_STATUS mfw_bt_dm_pin_code(UINT8* pin_code, UINT8 pin_len); | |
223 | |
224 /******************************************************************************* | |
225 $Function: mfw_bt_dm_bond | |
226 $Description: used by BMI to send a pin code in order to establish a bonding with a | |
227 remote device. | |
228 $Returns: T_MFW_BT_STATUS. MFW_BT_NOT_INITIALISED is BT is not started. | |
229 | |
230 $Arguments: BD_ADDR of the remote device, pin code and pin code length. Data is copied. | |
231 *******************************************************************************/ | |
232 T_MFW_BT_STATUS mfw_bt_dm_bond(BD_ADDR bd_addr, UINT8* pin_code, UINT8 pin_len ); | |
233 | |
234 /******************************************************************************* | |
235 $Function: mfw_bt_dm_authorize_resp | |
236 $Description: used to answer to an authorization request | |
237 $Returns: T_MFW_BT_STATUS. SUCCESS/FAIL, but also: | |
238 MFW_BT_NOT_INITIALISED is BT is not started. | |
239 MFW_BT_INVALID_DATA if auth value is not correct. | |
240 MFW_BT_UNKNOWN_DEVICE if BD_addr is not recognized. | |
241 MFW_BT_DATA_BASE_FULL if there are already too many devices in the DB. | |
242 $Arguments: MFW_BT_AUTH_FAIL to refuse, | |
243 MFW_BT_AUTH_ONCE to grant access temporarily, | |
244 MFW_BT_AUTH_ALWAYS to grant permanent access | |
245 *******************************************************************************/ | |
246 T_MFW_BT_STATUS mfw_bt_dm_authorize_resp( T_MFW_BT_AUTHORIZE auth); | |
247 | |
248 /******************************************************************************* | |
249 $Function: mfw_bt_dm_sig_strength | |
250 $Description: ask for the link quality | |
251 $Returns: T_MFW_BT_STATUS. MFW_BT_NOT_INITIALISED if BT is not started. | |
252 $Arguments: T_MFW_BT_DM_SIG_STRENGTH sig_strength, UINT16 period, BOOLEAN is_on | |
253 See BTA documentation for more details. | |
254 | |
255 *******************************************************************************/ | |
256 T_MFW_BT_STATUS mfw_bt_dm_sig_strength ( T_MFW_BT_DM_SIG_STRENGTH sig_strength, | |
257 UINT16 period, | |
258 BOOLEAN is_on ); | |
259 | |
260 /******************************************************************************* | |
261 $Function: mfw_bt_dm_get_known_devices | |
262 $Description: used by BMI to get the list of known devices for a specified condition: either a | |
263 service mask, either a bd address ( union ). | |
264 MFW will fill in the variables: pp_device => table of known devices | |
265 number_of_devices => number of devices. | |
266 MFW will allocate memory for each device found. It's up to BMI to free it! | |
267 $Returns: T_MFW_BT_STATUS. | |
268 If BD_ADDR is specified, might return MFW_BT_UNKNOWN_DEVICE. | |
269 The answers will be returned using BMI signals: | |
270 - E_BT_DM_INQ_CMPL with the number of devices | |
271 - E_BT_DM_DISC_RES for each device | |
272 - then E_BT_DM_DISC_CMPL when it's done. | |
273 $Arguments: BD_ADDR if looking for a particular device. services if looking for a | |
274 category of device. If bd_addr is specified, ignore services. If services set | |
275 to 0, will return all the known devices. | |
276 *******************************************************************************/ | |
277 void mfw_bt_dm_get_known_devices ( BD_ADDR bd_addr, | |
278 T_MFW_BT_SERVICE_MASK services); | |
279 | |
280 /******************************************************************************* | |
281 $Function: mfw_bt_dm_delete_device | |
282 $Description: remove a device from the local DB | |
283 $Returns: T_MFW_BT_STATUS ( MFW_BT_SUCCESS, MFW_BT_FAIL, MFW_BT_UNKNOWN_DEVICE ) | |
284 $Arguments: BD address | |
285 *******************************************************************************/ | |
286 T_MFW_BT_STATUS mfw_bt_dm_delete_device(BD_ADDR bd_addr); | |
287 | |
288 /******************************************************************************* | |
289 $Function: mfw_bt_dm_add_device | |
290 $Description: This will store permanently a device in Flash. | |
291 $Returns: T_MFW_BT_STATUS | |
292 errors: MFW_BT_UNKNOWN_DEVICE, MFW_BT_DATA_BASE_FULL, | |
293 $Arguments: new BD address | |
294 *******************************************************************************/ | |
295 T_MFW_BT_STATUS mfw_bt_dm_add_device(BD_ADDR bd_addr); | |
296 | |
297 /******************************************************************************* | |
298 $Function: mfw_bt_dm_rename_device | |
299 $Description: modify the friendly name of a known ( already stored ) remote device | |
300 $Returns: T_MFW_BT_STATUS. | |
301 MFW_BT_UNKNOWN_DEVICE, DATA_BASE_FULL, MFW_BT_INVALID_DATA... | |
302 $Arguments: bd address of the remote device and the new name associated | |
303 *******************************************************************************/ | |
304 T_MFW_BT_STATUS mfw_bt_dm_rename_device(BD_ADDR bd_addr, UINT8* new_name); | |
305 | |
306 | |
307 | |
308 | |
309 /* | |
310 ** Functions used to interact with the BT "search engine" | |
311 */ | |
312 | |
313 /******************************************************************************* | |
314 $Function: mfw_bt_dm_discover_device | |
315 $Description: Discovers services on a new device | |
316 $Returns: T_MFW_BT_STATUS. MFW_BT_NOT_INITIALISED if BT not started. | |
317 $Arguments: bd address of the remote device to discover | |
318 *******************************************************************************/ | |
319 T_MFW_BT_STATUS mfw_bt_dm_discover_device(BD_ADDR bd_addr); | |
320 | |
321 | |
322 /******************************************************************************* | |
323 $Function: mfw_bt_dm_is_discover | |
324 $Description: Checks if we are in discovering services process | |
325 $Returns: | |
326 $Arguments: None | |
327 *******************************************************************************/ | |
328 UINT8 mfw_bt_dm_is_discover(void); | |
329 | |
330 /******************************************************************************* | |
331 $Function: mfw_bt_dm_cancel_search | |
332 $Description: cancel an ongoing search | |
333 $Returns: MFW_BT_NOT_INITIALISED if BT not started. | |
334 $Arguments: | |
335 *******************************************************************************/ | |
336 T_MFW_BT_STATUS mfw_bt_dm_cancel_search( void ); | |
337 | |
338 /******************************************************************************* | |
339 $Function: mfw_bt_dm_search | |
340 $Description: Searches for devices supporting the services specified. If services = 0, will | |
341 return all the found devices regardless of their functionalities. | |
342 $Returns: MFW_BT_NOT_INITIALISED if BT not started. | |
343 $Arguments: services. If | |
344 *******************************************************************************/ | |
345 T_MFW_BT_STATUS mfw_bt_dm_search(T_MFW_BT_SERVICE_MASK services); | |
346 | |
347 | |
348 | |
349 | |
350 | |
351 | |
352 /* | |
353 ** Bluetooth Device Manager Profile Prototypes | |
354 */ | |
355 void mfw_bt_dm_security_cb(T_MFW_BT_DM_SEC_EVT event, T_MFW_BT_DM_SEC_SIG_DATA *data); | |
356 void mfw_bt_dm_search_cb(T_MFW_BT_DM_SRCH_EVT event, T_MFW_BT_DM_SRCH_SIG_DATA *data); | |
357 | |
358 T_MFW_BT_STATUS mfw_bt_dm_security_hndlr (T_MFW_BT_DM_SEC_EVT event, T_MFW_BT_DM_SEC_SIG_DATA *data); | |
359 T_MFW_BT_STATUS mfw_bt_dm_search_hndlr (T_MFW_BT_DM_SRCH_EVT event, T_MFW_BT_DM_SRCH_SIG_DATA *data); | |
360 | |
361 | |
362 | |
363 | |
364 | |
365 | |
366 | |
367 | |
368 #endif | |
369 |