blob: df5001df3b72ba8d5d561a183d9ec473abcbc92d [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
2 *
3 * Copyright (C) 2003-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 * This is the main implementation file for the BTA device manager.
22 *
23 ******************************************************************************/
24
25#include "bta_api.h"
26#include "bta_sys.h"
27#include "bta_dm_int.h"
28
29
30/*****************************************************************************
31** Constants and types
32*****************************************************************************/
33
34#if BTA_DYNAMIC_MEMORY == FALSE
35tBTA_DM_CB bta_dm_cb;
36tBTA_DM_SEARCH_CB bta_dm_search_cb;
37tBTA_DM_DI_CB bta_dm_di_cb;
38#endif
39
40
41#define BTA_DM_NUM_ACTIONS (BTA_DM_MAX_EVT & 0x00ff)
42
43/* type for action functions */
44typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
45
46/* action function list */
47const tBTA_DM_ACTION bta_dm_action[] =
48{
49
50 /* device manager local device API events */
51 bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
52 bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
53 bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
54 bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
55 bta_dm_set_afhchannels, /* 4 BTA_DM_API_SET_AFH_CHANNELS_EVT */
56 bta_dm_signal_strength, /* 5 BTA_API_DM_SIG_STRENGTH_EVT */
57 bta_dm_vendor_spec_command,/* 6 BTA_DM_API_VENDOR_SPECIFIC_COMMAND_EVT */
58 bta_dm_tx_inqpower, /* 7 BTA_DM_API_SIG_STRENGTH_EVT */
59 bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
60 bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080061 bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
The Android Open Source Project5738f832012-12-12 16:00:35 -080062
63 /* security API events */
Andre Eisenbach6975b4d2013-08-05 16:55:38 -070064 bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
65 bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
66 bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
67 bta_dm_link_policy, /* 14 BTA_DM_API_LINK_POLICY_EVT */
68 bta_dm_auth_reply, /* 15 BTA_DM_API_AUTH_REPLY_EVT */
The Android Open Source Project5738f832012-12-12 16:00:35 -080069
70 /* power manger events */
Andre Eisenbach6975b4d2013-08-05 16:55:38 -070071 bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
72 bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
The Android Open Source Project5738f832012-12-12 16:00:35 -080073
74 /* simple pairing events */
Andre Eisenbach6975b4d2013-08-05 16:55:38 -070075 bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
The Android Open Source Project5738f832012-12-12 16:00:35 -080076
77 bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
78
79#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
80 bta_dm_passkey_cancel, /* 19 BTA_DM_API_PASKY_CANCEL_EVT */
81#endif
82#if (BTM_OOB_INCLUDED == TRUE)
83 bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
84 bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
85 bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
86#endif /* BTM_OOB_INCLUDED */
87
88 bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
89
90#if BLE_INCLUDED == TRUE
91 bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
92 bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
93 bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
94 bta_dm_security_grant,
95 bta_dm_ble_set_bg_conn_type,
96 bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
97 bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080098 bta_dm_ble_observe,
Ganesh Ganapathi Batta8fe58872014-04-16 16:50:09 -070099 bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
100#if BLE_PRIVACY_SPT == TRUE
101 bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
102#endif
Andre Eisenbach5c44e452013-08-06 18:19:37 -0700103 bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
104 bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
Andre Eisenbacheeeac992013-11-08 10:23:52 -0800105 bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
106 bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
Andre Eisenbach2d754412013-11-20 17:23:06 -0800107#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
108 bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
Satya Calloji1a9247a2014-06-05 13:15:15 -0700109 bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
110 bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
Andre Eisenbach2d754412013-11-20 17:23:06 -0800111#endif
Satya Callojiffb39602014-04-30 15:55:39 -0700112 bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
113 bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
114 bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
115 btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
Satya Callojic4e25962014-05-10 23:46:24 -0700116 bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
117 bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
118 bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
119 bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800120#endif
121
122#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
123 bta_dm_update_eir_uuid, /* BTA_DM_API_UPDATE_EIR_UUID_EVT */
124#endif
125#if (BTM_EIR_SERVER_INCLUDED == TRUE)
126 bta_dm_set_eir_config, /* BTA_DM_API_SET_EIR_CONFIG_EVT */
127#endif
128
129 bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
130 bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
131 bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
132 bta_dm_set_afh_channel_assesment /* BTA_DM_API_SET_AFH_CHANNEL_ASSESMENT_EVT */
133};
134
135
136
137/* state machine action enumeration list */
138enum
139{
140 BTA_DM_API_SEARCH, /* 0 bta_dm_search_start */
141 BTA_DM_API_SEARCH_CANCEL, /* 1 bta_dm_search_cancel */
142 BTA_DM_API_DISCOVER, /* 2 bta_dm_discover */
143 BTA_DM_INQUIRY_CMPL, /* 3 bta_dm_inq_cmpl */
144 BTA_DM_REMT_NAME, /* 4 bta_dm_rmt_name */
145 BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */
146 BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/
147 BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */
148 BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */
149 BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */
150 BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */
151 BTA_DM_QUEUE_DISC, /* 11 bta_dm_queue_disc */
152 BTA_DM_SEARCH_CLEAR_QUEUE, /* 12 bta_dm_search_clear_queue */
153 BTA_DM_SEARCH_CANCEL_CMPL, /* 13 bta_dm_search_cancel_cmpl */
154 BTA_DM_SEARCH_CANCEL_NOTIFY, /* 14 bta_dm_search_cancel_notify */
155 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, /* 15 bta_dm_search_cancel_transac_cmpl */
156 BTA_DM_DISC_RMT_NAME, /* 16 bta_dm_disc_rmt_name */
157 BTA_DM_API_DI_DISCOVER, /* 17 bta_dm_di_disc */
Andre Eisenbach6975b4d2013-08-05 16:55:38 -0700158#if BLE_INCLUDED == TRUE
159 BTA_DM_CLOSE_GATT_CONN, /* 18 bta_dm_close_gatt_conn */
160#endif
161 BTA_DM_SEARCH_NUM_ACTIONS /* 19 */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800162};
163
164
165/* action function list */
166const tBTA_DM_ACTION bta_dm_search_action[] =
167{
168
169 bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
170 bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
171 bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
172 bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
173 bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
174 bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
175 bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
176 bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
177 bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
178 bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
179 bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
180 bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
181 bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
182 bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
183 bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
184 bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
185 bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
186 bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
Andre Eisenbach6975b4d2013-08-05 16:55:38 -0700187#if BLE_INCLUDED == TRUE
188 ,bta_dm_close_gatt_conn
189#endif
The Android Open Source Project5738f832012-12-12 16:00:35 -0800190};
191
192#define BTA_DM_SEARCH_IGNORE BTA_DM_SEARCH_NUM_ACTIONS
193/* state table information */
194#define BTA_DM_SEARCH_ACTIONS 2 /* number of actions */
195#define BTA_DM_SEARCH_NEXT_STATE 2 /* position of next state */
196#define BTA_DM_SEARCH_NUM_COLS 3 /* number of columns in state tables */
197
198
199
200/* state table for listen state */
201const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] =
202{
203
204/* Event Action 1 Action 2 Next State */
205/* API_SEARCH */ {BTA_DM_API_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
206/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
207/* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
208/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
209/* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
210/* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
211/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
212/* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
213/* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
Andre Eisenbach6975b4d2013-08-05 16:55:38 -0700214#if BLE_INCLUDED == TRUE
215/* DISC_CLOSE_TOUT_EVT */ ,{BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}
216#endif
The Android Open Source Project5738f832012-12-12 16:00:35 -0800217
218};
219const UINT8 bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] =
220{
221
222/* Event Action 1 Action 2 Next State */
223/* API_SEARCH */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
224/* API_SEARCH_CANCEL */ {BTA_DM_API_SEARCH_CANCEL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
225/* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
226/* INQUIRY_CMPL */ {BTA_DM_INQUIRY_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
227/* REMT_NAME_EVT */ {BTA_DM_REMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
228/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
229/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
230/* DISCV_RES_EVT */ {BTA_DM_SEARCH_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
231/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
232
Andre Eisenbach6975b4d2013-08-05 16:55:38 -0700233#if BLE_INCLUDED == TRUE
234/* DISC_CLOSE_TOUT_EVT */ ,{BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
235#endif
The Android Open Source Project5738f832012-12-12 16:00:35 -0800236
237};
238
239const UINT8 bta_dm_search_search_cancelling_st_table[][BTA_DM_SEARCH_NUM_COLS] =
240{
241
242/* Event Action 1 Action 2 Next State */
243/* API_SEARCH */ {BTA_DM_QUEUE_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
244/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CLEAR_QUEUE, BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_CANCELLING},
245/* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
246/* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
247/* REMT_NAME_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
248/* SDP_RESULT_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800249/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
250/* DISCV_RES_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
The Android Open Source Project5738f832012-12-12 16:00:35 -0800251/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
252
Andre Eisenbach6975b4d2013-08-05 16:55:38 -0700253#if BLE_INCLUDED == TRUE
254/* DISC_CLOSE_TOUT_EVT */ ,{BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
255#endif
The Android Open Source Project5738f832012-12-12 16:00:35 -0800256
257};
258
259const UINT8 bta_dm_search_disc_active_st_table[][BTA_DM_SEARCH_NUM_COLS] =
260{
261
262/* Event Action 1 Action 2 Next State */
263/* API_SEARCH */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
264/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
265/* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
266/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
267/* REMT_NAME_EVT */ {BTA_DM_DISC_RMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
268/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
269/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
270/* DISCV_RES_EVT */ {BTA_DM_DISC_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
271/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}
272
Andre Eisenbach6975b4d2013-08-05 16:55:38 -0700273#if BLE_INCLUDED == TRUE
274/* DISC_CLOSE_TOUT_EVT */ ,{BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}
275#endif
276
The Android Open Source Project5738f832012-12-12 16:00:35 -0800277};
278
279typedef const UINT8 (*tBTA_DM_ST_TBL)[BTA_DM_SEARCH_NUM_COLS];
280
281/* state table */
282const tBTA_DM_ST_TBL bta_dm_search_st_tbl[] = {
283 bta_dm_search_idle_st_table,
284 bta_dm_search_search_active_st_table,
285 bta_dm_search_search_cancelling_st_table,
286 bta_dm_search_disc_active_st_table
287};
288
289
290/*******************************************************************************
291**
292** Function bta_dm_sm_disable
293**
294** Description unregister BTA DM
295**
296**
297** Returns void
298**
299*******************************************************************************/
300void bta_dm_sm_disable( )
301{
302 bta_sys_deregister( BTA_ID_DM );
303}
304
305
306/*******************************************************************************
307**
308** Function bta_dm_sm_execute
309**
310** Description State machine event handling function for DM
311**
312**
313** Returns void
314**
315*******************************************************************************/
316BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg)
317{
318 UINT16 event = p_msg->event & 0x00ff;
319
Sharvil Nanavatie8c3d752014-05-04 10:12:26 -0700320 APPL_TRACE_EVENT("bta_dm_sm_execute event:0x%x", event);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800321
322 /* execute action functions */
323 if(event < BTA_DM_NUM_ACTIONS)
324 {
325 (*bta_dm_action[event])( (tBTA_DM_MSG*) p_msg);
326 }
327
328 return TRUE;
329}
330
331/*******************************************************************************
332**
333** Function bta_dm_sm_search_disable
334**
335** Description unregister BTA SEARCH DM
336**
337**
338** Returns void
339**
340*******************************************************************************/
341void bta_dm_search_sm_disable( )
342{
343 bta_sys_deregister( BTA_ID_DM_SEARCH );
344
345}
346
347
348/*******************************************************************************
349**
350** Function bta_dm_search_sm_execute
351**
352** Description State machine event handling function for DM
353**
354**
355** Returns void
356**
357*******************************************************************************/
358BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg)
359{
360 tBTA_DM_ST_TBL state_table;
361 UINT8 action;
362 int i;
363
Sharvil Nanavatie8c3d752014-05-04 10:12:26 -0700364 APPL_TRACE_EVENT("bta_dm_search_sm_execute state:%d, event:0x%x",
The Android Open Source Project5738f832012-12-12 16:00:35 -0800365 bta_dm_search_cb.state, p_msg->event);
366
367 /* look up the state table for the current state */
368 state_table = bta_dm_search_st_tbl[bta_dm_search_cb.state];
369
370 bta_dm_search_cb.state = state_table[p_msg->event & 0x00ff][BTA_DM_SEARCH_NEXT_STATE];
371
372
373 /* execute action functions */
374 for (i = 0; i < BTA_DM_SEARCH_ACTIONS; i++)
375 {
376 if ((action = state_table[p_msg->event & 0x00ff][i]) != BTA_DM_SEARCH_IGNORE)
377 {
378 (*bta_dm_search_action[action])( (tBTA_DM_MSG*) p_msg);
379 }
380 else
381 {
382 break;
383 }
384 }
385 return TRUE;
386}
387