The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 2003-2012 Broadcom Corporation |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 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" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 26 | #include "bta_dm_int.h" |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 27 | #include "bta_sys.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 28 | |
| 29 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 30 | * Constants and types |
| 31 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 32 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 33 | tBTA_DM_CB bta_dm_cb; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 34 | tBTA_DM_SEARCH_CB bta_dm_search_cb; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 35 | tBTA_DM_DI_CB bta_dm_di_cb; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 36 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 37 | #define BTA_DM_NUM_ACTIONS (BTA_DM_MAX_EVT & 0x00ff) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 38 | |
| 39 | /* type for action functions */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 40 | typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG* p_data); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 41 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 42 | /* state machine action enumeration list */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 43 | enum { |
| 44 | BTA_DM_API_SEARCH, /* 0 bta_dm_search_start */ |
| 45 | BTA_DM_API_SEARCH_CANCEL, /* 1 bta_dm_search_cancel */ |
| 46 | BTA_DM_API_DISCOVER, /* 2 bta_dm_discover */ |
| 47 | BTA_DM_INQUIRY_CMPL, /* 3 bta_dm_inq_cmpl */ |
| 48 | BTA_DM_REMT_NAME, /* 4 bta_dm_rmt_name */ |
| 49 | BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */ |
| 50 | BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/ |
| 51 | BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */ |
| 52 | BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */ |
| 53 | BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */ |
| 54 | BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */ |
| 55 | BTA_DM_QUEUE_DISC, /* 11 bta_dm_queue_disc */ |
| 56 | BTA_DM_SEARCH_CLEAR_QUEUE, /* 12 bta_dm_search_clear_queue */ |
| 57 | BTA_DM_SEARCH_CANCEL_CMPL, /* 13 bta_dm_search_cancel_cmpl */ |
| 58 | BTA_DM_SEARCH_CANCEL_NOTIFY, /* 14 bta_dm_search_cancel_notify */ |
| 59 | BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, /* 15 bta_dm_search_cancel_transac_cmpl */ |
| 60 | BTA_DM_DISC_RMT_NAME, /* 16 bta_dm_disc_rmt_name */ |
| 61 | BTA_DM_API_DI_DISCOVER, /* 17 bta_dm_di_disc */ |
Myles Watson | 9008888 | 2016-11-15 16:33:22 -0800 | [diff] [blame] | 62 | BTA_DM_CLOSE_GATT_CONN, /* 18 bta_dm_close_gatt_conn */ |
| 63 | BTA_DM_SEARCH_NUM_ACTIONS /* 19 */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 66 | /* action function list */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 67 | const tBTA_DM_ACTION bta_dm_search_action[] = { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 68 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 69 | bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */ |
| 70 | bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */ |
| 71 | bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */ |
| 72 | bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */ |
| 73 | bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */ |
| 74 | bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */ |
| 75 | bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */ |
| 76 | bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */ |
| 77 | bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */ |
| 78 | bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */ |
| 79 | bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */ |
| 80 | bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */ |
| 81 | bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */ |
| 82 | bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */ |
| 83 | bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */ |
| 84 | bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL |
| 85 | */ |
| 86 | bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */ |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 87 | bta_dm_di_disc, /* 17 BTA_DM_API_DI_DISCOVER */ |
Myles Watson | 9008888 | 2016-11-15 16:33:22 -0800 | [diff] [blame] | 88 | bta_dm_close_gatt_conn}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 89 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 90 | #define BTA_DM_SEARCH_IGNORE BTA_DM_SEARCH_NUM_ACTIONS |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 91 | /* state table information */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 92 | #define BTA_DM_SEARCH_ACTIONS 2 /* number of actions */ |
| 93 | #define BTA_DM_SEARCH_NEXT_STATE 2 /* position of next state */ |
| 94 | #define BTA_DM_SEARCH_NUM_COLS 3 /* number of columns in state tables */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 95 | |
| 96 | /* state table for listen state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 97 | const uint8_t bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] = { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 98 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 99 | /* Event Action 1 |
| 100 | Action 2 Next State */ |
| 101 | /* API_SEARCH */ {BTA_DM_API_SEARCH, BTA_DM_SEARCH_IGNORE, |
| 102 | BTA_DM_SEARCH_ACTIVE}, |
| 103 | /* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, |
| 104 | BTA_DM_SEARCH_IDLE}, |
| 105 | /* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, |
| 106 | BTA_DM_DISCOVER_ACTIVE}, |
| 107 | /* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 108 | BTA_DM_SEARCH_IDLE}, |
| 109 | /* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 110 | BTA_DM_SEARCH_IDLE}, |
| 111 | /* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, |
| 112 | BTA_DM_SEARCH_IDLE}, |
| 113 | /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 114 | BTA_DM_SEARCH_IDLE}, |
| 115 | /* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 116 | BTA_DM_SEARCH_IDLE}, |
| 117 | /* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 118 | BTA_DM_SEARCH_ACTIVE}, |
| 119 | /* DISC_CLOSE_TOUT_EVT */ |
Myles Watson | 9008888 | 2016-11-15 16:33:22 -0800 | [diff] [blame] | 120 | {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}}; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 121 | const uint8_t bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 122 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 123 | /* Event Action 1 |
| 124 | Action 2 Next State */ |
| 125 | /* API_SEARCH */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 126 | BTA_DM_SEARCH_ACTIVE}, |
| 127 | /* API_SEARCH_CANCEL */ {BTA_DM_API_SEARCH_CANCEL, BTA_DM_SEARCH_IGNORE, |
| 128 | BTA_DM_SEARCH_CANCELLING}, |
| 129 | /* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 130 | BTA_DM_SEARCH_ACTIVE}, |
| 131 | /* INQUIRY_CMPL */ {BTA_DM_INQUIRY_CMPL, BTA_DM_SEARCH_IGNORE, |
| 132 | BTA_DM_SEARCH_ACTIVE}, |
| 133 | /* REMT_NAME_EVT */ {BTA_DM_REMT_NAME, BTA_DM_SEARCH_IGNORE, |
| 134 | BTA_DM_SEARCH_ACTIVE}, |
| 135 | /* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, |
| 136 | BTA_DM_SEARCH_ACTIVE}, |
| 137 | /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, |
| 138 | BTA_DM_SEARCH_IDLE}, |
| 139 | /* DISCV_RES_EVT */ {BTA_DM_SEARCH_RESULT, BTA_DM_SEARCH_IGNORE, |
| 140 | BTA_DM_SEARCH_ACTIVE}, |
| 141 | /* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 142 | BTA_DM_SEARCH_ACTIVE}, |
| 143 | /* DISC_CLOSE_TOUT_EVT */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 144 | {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE} |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 145 | |
| 146 | }; |
| 147 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 148 | const uint8_t |
| 149 | bta_dm_search_search_cancelling_st_table[][BTA_DM_SEARCH_NUM_COLS] = { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 150 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 151 | /* Event Action 1 |
| 152 | Action 2 Next State */ |
| 153 | /* API_SEARCH */ {BTA_DM_QUEUE_SEARCH, BTA_DM_SEARCH_IGNORE, |
| 154 | BTA_DM_SEARCH_CANCELLING}, |
| 155 | /* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CLEAR_QUEUE, |
| 156 | BTA_DM_SEARCH_CANCEL_NOTIFY, |
| 157 | BTA_DM_SEARCH_CANCELLING}, |
| 158 | /* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, |
| 159 | BTA_DM_SEARCH_CANCELLING}, |
| 160 | /* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, |
| 161 | BTA_DM_SEARCH_IDLE}, |
| 162 | /* REMT_NAME_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, |
| 163 | BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, |
| 164 | /* SDP_RESULT_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, |
| 165 | BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, |
| 166 | /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, |
| 167 | BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, |
| 168 | /* DISCV_RES_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, |
| 169 | BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE}, |
| 170 | /* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 171 | BTA_DM_SEARCH_CANCELLING}, |
| 172 | /* DISC_CLOSE_TOUT_EVT */ |
Myles Watson | 9008888 | 2016-11-15 16:33:22 -0800 | [diff] [blame] | 173 | {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 174 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 175 | const uint8_t bta_dm_search_disc_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 176 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 177 | /* Event Action 1 |
| 178 | Action 2 Next State */ |
| 179 | /* API_SEARCH */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 180 | BTA_DM_DISCOVER_ACTIVE}, |
| 181 | /* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, |
| 182 | BTA_DM_SEARCH_CANCELLING}, |
| 183 | /* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 184 | BTA_DM_DISCOVER_ACTIVE}, |
| 185 | /* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
| 186 | BTA_DM_DISCOVER_ACTIVE}, |
| 187 | /* REMT_NAME_EVT */ {BTA_DM_DISC_RMT_NAME, BTA_DM_SEARCH_IGNORE, |
| 188 | BTA_DM_DISCOVER_ACTIVE}, |
| 189 | /* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, |
| 190 | BTA_DM_DISCOVER_ACTIVE}, |
| 191 | /* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, |
| 192 | BTA_DM_SEARCH_IDLE}, |
| 193 | /* DISCV_RES_EVT */ {BTA_DM_DISC_RESULT, BTA_DM_SEARCH_IGNORE, |
| 194 | BTA_DM_DISCOVER_ACTIVE}, |
| 195 | /* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 196 | BTA_DM_DISCOVER_ACTIVE}, |
| 197 | /* DISC_CLOSE_TOUT_EVT */ |
Myles Watson | 9008888 | 2016-11-15 16:33:22 -0800 | [diff] [blame] | 198 | {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 199 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 200 | typedef const uint8_t (*tBTA_DM_ST_TBL)[BTA_DM_SEARCH_NUM_COLS]; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 201 | |
| 202 | /* state table */ |
| 203 | const tBTA_DM_ST_TBL bta_dm_search_st_tbl[] = { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 204 | bta_dm_search_idle_st_table, bta_dm_search_search_active_st_table, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 205 | bta_dm_search_search_cancelling_st_table, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 206 | bta_dm_search_disc_active_st_table}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 207 | |
| 208 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 209 | * |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 210 | * Function bta_dm_sm_search_disable |
| 211 | * |
| 212 | * Description unregister BTA SEARCH DM |
| 213 | * |
| 214 | * |
| 215 | * Returns void |
| 216 | * |
| 217 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 218 | void bta_dm_search_sm_disable() { bta_sys_deregister(BTA_ID_DM_SEARCH); } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 219 | |
| 220 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 221 | * |
| 222 | * Function bta_dm_search_sm_execute |
| 223 | * |
| 224 | * Description State machine event handling function for DM |
| 225 | * |
| 226 | * |
| 227 | * Returns void |
| 228 | * |
| 229 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 230 | bool bta_dm_search_sm_execute(BT_HDR* p_msg) { |
| 231 | tBTA_DM_ST_TBL state_table; |
| 232 | uint8_t action; |
| 233 | int i; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 234 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 235 | APPL_TRACE_EVENT("bta_dm_search_sm_execute state:%d, event:0x%x", |
| 236 | bta_dm_search_cb.state, p_msg->event); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 237 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 238 | /* look up the state table for the current state */ |
| 239 | state_table = bta_dm_search_st_tbl[bta_dm_search_cb.state]; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 240 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 241 | bta_dm_search_cb.state = |
| 242 | state_table[p_msg->event & 0x00ff][BTA_DM_SEARCH_NEXT_STATE]; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 243 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 244 | /* execute action functions */ |
| 245 | for (i = 0; i < BTA_DM_SEARCH_ACTIONS; i++) { |
Marie Janssen | f33b6f4 | 2016-11-22 15:01:42 -0800 | [diff] [blame] | 246 | action = state_table[p_msg->event & 0x00ff][i]; |
| 247 | if (action != BTA_DM_SEARCH_IGNORE) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 248 | (*bta_dm_search_action[action])((tBTA_DM_MSG*)p_msg); |
| 249 | } else { |
| 250 | break; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 251 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 252 | } |
| 253 | return true; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 254 | } |