The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 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 public interface file for the BTA system manager. |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | #ifndef BTA_SYS_H |
| 25 | #define BTA_SYS_H |
| 26 | |
| 27 | #include "bt_target.h" |
Pavlin Radoslavov | 78bcff7 | 2015-12-04 17:36:34 -0800 | [diff] [blame] | 28 | #include "osi/include/alarm.h" |
Pavlin Radoslavov | 258c253 | 2015-09-27 20:59:05 -0700 | [diff] [blame] | 29 | #include "bt_common.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | |
Bryce Lee | 3d6accf | 2016-05-10 17:10:09 -0700 | [diff] [blame] | 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 35 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame^] | 36 | * Constants and data types |
| 37 | ****************************************************************************/ |
Andre Eisenbach | b203d47 | 2013-11-20 17:23:06 -0800 | [diff] [blame] | 38 | |
| 39 | /* vendor specific event handler function type */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 40 | typedef bool (tBTA_SYS_VS_EVT_HDLR)(uint16_t evt, void *p); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 41 | |
| 42 | /* event handler function type */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 43 | typedef bool (tBTA_SYS_EVT_HDLR)(BT_HDR *p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 44 | |
| 45 | /* disable function type */ |
| 46 | typedef void (tBTA_SYS_DISABLE)(void); |
| 47 | |
| 48 | |
| 49 | /* HW modules */ |
| 50 | enum |
| 51 | { |
| 52 | BTA_SYS_HW_BLUETOOTH, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 53 | BTA_SYS_HW_RT, |
| 54 | |
| 55 | BTA_SYS_MAX_HW_MODULES |
| 56 | }; |
| 57 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 58 | typedef uint16_t tBTA_SYS_HW_MODULE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 59 | |
| 60 | #ifndef BTA_DM_NUM_JV_ID |
| 61 | #define BTA_DM_NUM_JV_ID 2 |
| 62 | #endif |
| 63 | |
| 64 | /* SW sub-systems */ |
| 65 | #define BTA_ID_SYS 0 /* system manager */ |
| 66 | /* BLUETOOTH PART - from 0 to BTA_ID_BLUETOOTH_MAX */ |
| 67 | #define BTA_ID_DM 1 /* device manager */ |
| 68 | #define BTA_ID_DM_SEARCH 2 /* device manager search */ |
| 69 | #define BTA_ID_DM_SEC 3 /* device manager security */ |
| 70 | #define BTA_ID_DG 4 /* data gateway */ |
| 71 | #define BTA_ID_AG 5 /* audio gateway */ |
| 72 | #define BTA_ID_OPC 6 /* object push client */ |
| 73 | #define BTA_ID_OPS 7 /* object push server */ |
| 74 | #define BTA_ID_FTS 8 /* file transfer server */ |
| 75 | #define BTA_ID_CT 9 /* cordless telephony terminal */ |
| 76 | #define BTA_ID_FTC 10 /* file transfer client */ |
| 77 | #define BTA_ID_SS 11 /* synchronization server */ |
| 78 | #define BTA_ID_PR 12 /* Printer client */ |
| 79 | #define BTA_ID_BIC 13 /* Basic Imaging Client */ |
| 80 | #define BTA_ID_PAN 14 /* Personal Area Networking */ |
| 81 | #define BTA_ID_BIS 15 /* Basic Imaging Server */ |
| 82 | #define BTA_ID_ACC 16 /* Advanced Camera Client */ |
| 83 | #define BTA_ID_SC 17 /* SIM Card Access server */ |
| 84 | #define BTA_ID_AV 18 /* Advanced audio/video */ |
| 85 | #define BTA_ID_AVK 19 /* Audio/video sink */ |
| 86 | #define BTA_ID_HD 20 /* HID Device */ |
| 87 | #define BTA_ID_CG 21 /* Cordless Gateway */ |
| 88 | #define BTA_ID_BP 22 /* Basic Printing Client */ |
| 89 | #define BTA_ID_HH 23 /* Human Interface Device Host */ |
| 90 | #define BTA_ID_PBS 24 /* Phone Book Access Server */ |
| 91 | #define BTA_ID_PBC 25 /* Phone Book Access Client */ |
| 92 | #define BTA_ID_JV 26 /* Java */ |
| 93 | #define BTA_ID_HS 27 /* Headset */ |
| 94 | #define BTA_ID_MSE 28 /* Message Server Equipment */ |
| 95 | #define BTA_ID_MCE 29 /* Message Client Equipment */ |
| 96 | #define BTA_ID_HL 30 /* Health Device Profile*/ |
| 97 | #define BTA_ID_GATTC 31 /* GATT Client */ |
| 98 | #define BTA_ID_GATTS 32 /* GATT Client */ |
Kim Schulz | 8372aa5 | 2015-03-25 10:39:40 +0100 | [diff] [blame] | 99 | #define BTA_ID_SDP 33 /* SDP Client */ |
| 100 | #define BTA_ID_BLUETOOTH_MAX 34 /* last BT profile */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 101 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 102 | /* GENERIC */ |
| 103 | #define BTA_ID_PRM 38 |
| 104 | #define BTA_ID_SYSTEM 39 /* platform-specific */ |
| 105 | #define BTA_ID_SWRAP 40 /* Insight script wrapper */ |
| 106 | #define BTA_ID_MIP 41 /* Multicase Individual Polling */ |
| 107 | #define BTA_ID_RT 42 /* Audio Routing module: This module is always on. */ |
Jakub Pawlowski | e5c7895 | 2016-08-10 09:07:44 -0700 | [diff] [blame] | 108 | #define BTA_ID_CLOSURE 43 /* Generic C++ closure */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 109 | |
| 110 | /* JV */ |
Kim Schulz | 8372aa5 | 2015-03-25 10:39:40 +0100 | [diff] [blame] | 111 | #define BTA_ID_JV1 44 /* JV1 */ |
| 112 | #define BTA_ID_JV2 45 /* JV2 */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 113 | |
Kim Schulz | 8372aa5 | 2015-03-25 10:39:40 +0100 | [diff] [blame] | 114 | #define BTA_ID_MAX (44 + BTA_DM_NUM_JV_ID) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 115 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 116 | typedef uint8_t tBTA_SYS_ID; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 117 | |
| 118 | |
| 119 | #define BTA_SYS_CONN_OPEN 0x00 |
| 120 | #define BTA_SYS_CONN_CLOSE 0x01 |
| 121 | #define BTA_SYS_APP_OPEN 0x02 |
| 122 | #define BTA_SYS_APP_CLOSE 0x03 |
| 123 | #define BTA_SYS_SCO_OPEN 0x04 |
| 124 | #define BTA_SYS_SCO_CLOSE 0x05 |
| 125 | #define BTA_SYS_CONN_IDLE 0x06 |
| 126 | #define BTA_SYS_CONN_BUSY 0x07 |
| 127 | |
| 128 | /* for link policy */ |
| 129 | #define BTA_SYS_PLCY_SET 0x10 /* set the link policy to the given addr */ |
| 130 | #define BTA_SYS_PLCY_CLR 0x11 /* clear the link policy to the given addr */ |
| 131 | #define BTA_SYS_PLCY_DEF_SET 0x12 /* set the default link policy */ |
| 132 | #define BTA_SYS_PLCY_DEF_CLR 0x13 /* clear the default link policy */ |
| 133 | #define BTA_SYS_ROLE_CHANGE 0x14 /* role change */ |
| 134 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 135 | typedef uint8_t tBTA_SYS_CONN_STATUS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 136 | |
| 137 | /* Bitmask of sys features */ |
| 138 | #define BTA_SYS_FEAT_PCM2 0x0001 |
| 139 | #define BTA_SYS_FEAT_PCM2_MASTER 0x0002 |
| 140 | |
| 141 | /* tBTA_PREF_ROLES */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 142 | typedef uint8_t tBTA_SYS_PREF_ROLES; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 143 | |
| 144 | /* conn callback for role / low power manager*/ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 145 | typedef void (tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status,uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 146 | |
| 147 | /* conn callback for role / low power manager*/ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 148 | typedef void (tBTA_SYS_SSR_CFG_CBACK)(uint8_t id, uint8_t app_id, uint16_t latency, uint16_t tout); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 149 | |
Chris Manton | 1e61ce1 | 2014-10-24 09:12:41 -0700 | [diff] [blame] | 150 | #if (BTA_EIR_CANNED_UUID_LIST != TRUE) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 151 | /* eir callback for adding/removeing UUID */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 152 | typedef void (tBTA_SYS_EIR_CBACK)(uint16_t uuid16, bool adding); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 153 | #endif |
| 154 | |
| 155 | /* registration structure */ |
| 156 | typedef struct |
| 157 | { |
| 158 | tBTA_SYS_EVT_HDLR *evt_hdlr; |
| 159 | tBTA_SYS_DISABLE *disable; |
| 160 | } tBTA_SYS_REG; |
| 161 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 162 | /* data type to send events to BTA SYS HW manager */ |
| 163 | typedef struct |
| 164 | { |
| 165 | BT_HDR hdr; |
| 166 | tBTA_SYS_HW_MODULE hw_module; |
| 167 | } tBTA_SYS_HW_MSG; |
| 168 | |
Jakub Pawlowski | e5c7895 | 2016-08-10 09:07:44 -0700 | [diff] [blame] | 169 | typedef void (*tBTA_SYS_REGISTER)(uint8_t id, const tBTA_SYS_REG *p_reg); |
| 170 | typedef void (*tBTA_SYS_SENDMSG)(void *p_msg); |
| 171 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 172 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame^] | 173 | * Global data |
| 174 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 175 | |
| 176 | /* trace level */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 177 | extern uint8_t appl_trace_level; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 178 | |
| 179 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame^] | 180 | * Macros |
| 181 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 182 | |
| 183 | /* Calculate start of event enumeration; id is top 8 bits of event */ |
| 184 | #define BTA_SYS_EVT_START(id) ((id) << 8) |
| 185 | |
| 186 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame^] | 187 | * events for BTA SYS HW manager |
| 188 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 189 | |
Pavlin Radoslavov | b2a292b | 2016-10-14 19:34:48 -0700 | [diff] [blame] | 190 | /* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.cc */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 191 | enum |
| 192 | { |
| 193 | /* device manager local device API events */ |
| 194 | BTA_SYS_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SYS), |
| 195 | BTA_SYS_EVT_ENABLED_EVT, |
| 196 | BTA_SYS_EVT_STACK_ENABLED_EVT, |
| 197 | BTA_SYS_API_DISABLE_EVT, |
| 198 | BTA_SYS_EVT_DISABLED_EVT, |
| 199 | BTA_SYS_ERROR_EVT, |
| 200 | |
| 201 | BTA_SYS_MAX_EVT |
| 202 | }; |
| 203 | |
| 204 | |
| 205 | |
| 206 | /* SYS HW status events - returned by SYS HW manager to other modules. */ |
| 207 | enum |
| 208 | { |
| 209 | BTA_SYS_HW_OFF_EVT, |
| 210 | BTA_SYS_HW_ON_EVT, |
| 211 | BTA_SYS_HW_STARTING_EVT, |
| 212 | BTA_SYS_HW_STOPPING_EVT, |
| 213 | BTA_SYS_HW_ERROR_EVT |
| 214 | |
| 215 | }; |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 216 | typedef uint8_t tBTA_SYS_HW_EVT; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 217 | |
| 218 | /* HW enable callback type */ |
| 219 | typedef void (tBTA_SYS_HW_CBACK)(tBTA_SYS_HW_EVT status); |
| 220 | |
| 221 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame^] | 222 | * Function declarations |
| 223 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 224 | |
June R. Tate-Gans | 24933b5 | 2014-09-24 15:25:02 -0700 | [diff] [blame] | 225 | extern void bta_sys_init(void); |
| 226 | extern void bta_sys_free(void); |
| 227 | extern void bta_sys_event(BT_HDR *p_msg); |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 228 | extern void bta_sys_set_trace_level(uint8_t level); |
| 229 | extern void bta_sys_register(uint8_t id, const tBTA_SYS_REG *p_reg); |
| 230 | extern void bta_sys_deregister(uint8_t id); |
| 231 | extern bool bta_sys_is_register(uint8_t id); |
| 232 | extern uint16_t bta_sys_get_sys_features(void); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 233 | extern void bta_sys_sendmsg(void *p_msg); |
Pavlin Radoslavov | 78bcff7 | 2015-12-04 17:36:34 -0800 | [diff] [blame] | 234 | extern void bta_sys_start_timer(alarm_t *alarm, period_ms_t interval, |
| 235 | uint16_t event, uint16_t layer_specific); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 236 | extern void bta_sys_disable(tBTA_SYS_HW_MODULE module); |
| 237 | |
| 238 | extern void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback); |
| 239 | extern void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module ); |
| 240 | |
| 241 | |
| 242 | extern void bta_sys_rm_register(tBTA_SYS_CONN_CBACK * p_cback); |
| 243 | extern void bta_sys_pm_register(tBTA_SYS_CONN_CBACK * p_cback); |
| 244 | |
| 245 | extern void bta_sys_policy_register(tBTA_SYS_CONN_CBACK * p_cback); |
| 246 | extern void bta_sys_sco_register(tBTA_SYS_CONN_CBACK * p_cback); |
| 247 | |
| 248 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 249 | extern void bta_sys_conn_open(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 250 | extern void bta_sys_conn_close(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 251 | extern void bta_sys_app_open(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 252 | extern void bta_sys_app_close(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 253 | extern void bta_sys_sco_open(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 254 | extern void bta_sys_sco_close(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 255 | extern void bta_sys_sco_use(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 256 | extern void bta_sys_sco_unuse(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 257 | extern void bta_sys_idle(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
| 258 | extern void bta_sys_busy(uint8_t id, uint8_t app_id, BD_ADDR peer_addr); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 259 | |
| 260 | #if (BTM_SSR_INCLUDED == TRUE) |
| 261 | extern void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK * p_cback); |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 262 | extern void bta_sys_chg_ssr_config (uint8_t id, uint8_t app_id, uint16_t max_latency, uint16_t min_tout); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 263 | #endif |
| 264 | |
| 265 | extern void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK * p_cback); |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 266 | extern void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, uint8_t new_role, uint8_t hci_status); |
| 267 | extern void bta_sys_collision_register(uint8_t bta_id, tBTA_SYS_CONN_CBACK *p_cback); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 268 | extern void bta_sys_notify_collision (BD_ADDR_PTR p_bda); |
| 269 | |
Chris Manton | 1e61ce1 | 2014-10-24 09:12:41 -0700 | [diff] [blame] | 270 | #if (BTA_EIR_CANNED_UUID_LIST != TRUE) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 271 | extern void bta_sys_eir_register(tBTA_SYS_EIR_CBACK * p_cback); |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 272 | extern void bta_sys_add_uuid(uint16_t uuid16); |
| 273 | extern void bta_sys_remove_uuid(uint16_t uuid16); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 274 | #else |
| 275 | #define bta_sys_eir_register(ut) |
| 276 | #define bta_sys_add_uuid(ut) |
| 277 | #define bta_sys_remove_uuid(ut) |
| 278 | #endif |
| 279 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 280 | extern void bta_sys_set_policy (uint8_t id, uint8_t policy, BD_ADDR peer_addr); |
| 281 | extern void bta_sys_clear_policy (uint8_t id, uint8_t policy, BD_ADDR peer_addr); |
| 282 | extern void bta_sys_set_default_policy (uint8_t id, uint8_t policy); |
| 283 | extern void bta_sys_clear_default_policy (uint8_t id, uint8_t policy); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 284 | |
| 285 | #ifdef __cplusplus |
| 286 | } |
| 287 | #endif |
| 288 | |
| 289 | #endif /* BTA_SYS_H */ |