1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef __APP_BT_FUNC_H__ 5 #define __APP_BT_FUNC_H__ 6 7 #include "cmsis_os.h" 8 #include "hal_trace.h" 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 #include "me_api.h" 14 #include "a2dp_api.h" 15 #include "hfp_api.h" 16 #include "dip_api.h" 17 18 typedef enum _bt_fn_req { 19 Me_switch_sco_req = 0, 20 ME_SwitchRole_req = 1, 21 ME_SetConnectionRole_req = 2, 22 MeDisconnectLink_req = 3, 23 ME_StopSniff_req = 4, 24 ME_SetAccessibleMode_req = 5, 25 Me_SetLinkPolicy_req = 6, 26 CMGR_SetSniffTimer_req = 7, 27 CMGR_SetSniffInofToAllHandlerByRemDev_req = 8, 28 A2DP_OpenStream_req = 9, 29 A2DP_CloseStream_req = 10, 30 A2DP_SetMasterRole_req = 11, 31 HF_CreateServiceLink_req = 12, 32 HF_DisconnectServiceLink_req = 13, 33 HF_CreateAudioLink_req = 14, 34 HF_DisconnectAudioLink_req = 15, 35 HF_EnableSniffMode_req = 16, 36 HF_SetMasterRole_req = 17, 37 #if defined (__HSP_ENABLE__) 38 HS_CreateServiceLink_req = 18, 39 HS_CreateAudioLink_req = 19, 40 HS_DisconnectAudioLink_req = 20, 41 HS_EnableSniffMode_req = 21, 42 HS_DisconnectServiceLink_req = 22, 43 #endif 44 BT_Control_SleepMode_req = 23, 45 BT_Custom_Func_req = 24, 46 ME_StartSniff_req = 25, 47 #ifdef BTIF_DIP_DEVICE 48 DIP_QuryService_req = 26, 49 #endif 50 A2DP_Force_OpenStream_req = 27, 51 HF_Force_CreateServiceLink_req = 28, 52 BT_Red_Ccmp_Client_Open = 29, 53 BT_Set_Access_Mode_Test = 30, 54 BT_Set_Adv_Mode_Test = 31, 55 56 57 58 }bt_fn_req; 59 typedef void (*APP_BT_REQ_CUSTOMER_CALl_CB_T)(void *, void *); 60 61 typedef union _bt_fn_param { 62 // BtStatus Me_switch_sco(uint16_t scohandle) 63 struct { 64 uint16_t scohandle; 65 } Me_switch_sco_param; 66 67 // BtStatus ME_SwitchRole(btif_remote_device_t *remDev) 68 struct { 69 btif_remote_device_t* remDev; 70 } ME_SwitchRole_param; 71 72 //BtConnectionRole ME_SetConnectionRole(BtConnectionRole role) 73 struct { 74 btif_connection_role_t role; 75 } BtConnectionRole_param; 76 77 // void MeDisconnectLink(btif_remote_device_t* remDev) 78 struct { 79 btif_remote_device_t* remDev; 80 } MeDisconnectLink_param; 81 82 //BtStatus ME_StopSniff(btif_remote_device_t *remDev) 83 struct { 84 btif_remote_device_t* remDev; 85 } ME_StopSniff_param; 86 87 struct { 88 btif_remote_device_t* remDev; 89 btif_sniff_info_t sniffInfo; 90 } ME_StartSniff_param; 91 92 struct { 93 bool isEnable; 94 } ME_BtControlSleepMode_param; 95 96 struct { 97 bool isEnable; 98 } ME_BtSetAdvMode_param; 99 100 //BtStatus ME_SetAccessibleMode(btif_accessible_mode_t mode, const btif_access_mode_info_t *info) 101 struct { 102 btif_accessible_mode_t mode; 103 btif_access_mode_info_t info; 104 } ME_SetAccessibleMode_param; 105 106 //BtStatus Me_SetLinkPolicy(btif_remote_device_t *remDev, btif_link_policy_t policy) 107 struct { 108 btif_remote_device_t *remDev; 109 btif_link_policy_t policy; 110 } Me_SetLinkPolicy_param; 111 112 /*BtStatus CMGR_SetSniffTimer(CmgrHandler *Handler, 113 btif_sniff_info_t* SniffInfo, 114 TimeT Time) 115 */ 116 struct { 117 btif_cmgr_handler_t *Handler; 118 btif_sniff_info_t SniffInfo; 119 TimeT Time; 120 } CMGR_SetSniffTimer_param; 121 122 /*BtStatus CMGR_SetSniffInofToAllHandlerByRemDev(btif_sniff_info_t* SniffInfo, 123 btif_remote_device_t *RemDev) 124 */ 125 struct { 126 btif_sniff_info_t SniffInfo; 127 btif_remote_device_t *RemDev; 128 } CMGR_SetSniffInofToAllHandlerByRemDev_param; 129 130 //BtStatus A2DP_OpenStream(a2dp_stream_t *Stream, bt_bdaddr_t *Addr) 131 struct { 132 a2dp_stream_t *Stream; 133 bt_bdaddr_t *Addr; 134 } A2DP_OpenStream_param; 135 136 //BtStatus A2DP_CloseStream(a2dp_stream_t *Stream); 137 struct { 138 a2dp_stream_t *Stream; 139 } A2DP_CloseStream_param; 140 141 //BtStatus A2DP_SetMasterRole(a2dp_stream_t *Stream, BOOL Flag); 142 struct { 143 a2dp_stream_t *Stream; 144 BOOL Flag; 145 } A2DP_SetMasterRole_param; 146 147 //BtStatus HF_CreateServiceLink(HfChannel *Chan, bt_bdaddr_t *Addr) 148 struct { 149 hf_chan_handle_t Chan; 150 bt_bdaddr_t *Addr; 151 } HF_CreateServiceLink_param; 152 153 //bt_status_t HF_DisconnectServiceLink(hf_chan_handle_t Chan) 154 struct { 155 hf_chan_handle_t Chan; 156 } HF_DisconnectServiceLink_param; 157 158 //bt_status_t HF_CreateAudioLink(hf_chan_handle_t Chan) 159 struct { 160 hf_chan_handle_t Chan; 161 } HF_CreateAudioLink_param; 162 163 //bt_status_t HF_DisconnectAudioLink(hf_chan_handle_t Chan) 164 struct { 165 hf_chan_handle_t Chan; 166 } HF_DisconnectAudioLink_param; 167 168 //bt_status_t HF_EnableSniffMode(hf_chan_handle_t Chan, BOOL Enable) 169 struct { 170 hf_chan_handle_t Chan; 171 BOOL Enable; 172 } HF_EnableSniffMode_param; 173 174 //bt_status_t HF_SetMasterRole(hf_chan_handle_t Chan, BOOL Flag); 175 struct { 176 hf_chan_handle_t Chan; 177 BOOL Flag; 178 } HF_SetMasterRole_param; 179 180 #ifdef BTIF_DIP_DEVICE 181 struct { 182 btif_remote_device_t* remDev; 183 btif_dip_client_t *dip_client; 184 } DIP_QuryService_param; 185 #endif 186 187 #if defined (__HSP_ENABLE__) 188 //bt_status_t HS_CreateServiceLink(HsChannel *Chan, bt_bdaddr_t *Addr) 189 struct { 190 HsChannel *Chan; 191 bt_bdaddr_t *Addr; 192 } HS_CreateServiceLink_param; 193 194 //BtStatus HS_CreateAudioLink(HsChannel *Chan) 195 struct { 196 HsChannel *Chan; 197 } HS_CreateAudioLink_param; 198 199 //BtStatus HS_DisconnectAudioLink(HsChannel *Chan) 200 struct { 201 HsChannel *Chan; 202 } HS_DisconnectAudioLink_param; 203 204 //BtStatus HS_DisconnectServiceLink(HsChannel *Chan) 205 struct { 206 HsChannel *Chan; 207 } HS_DisconnectServiceLink_param; 208 209 //BtStatus HS_EnableSniffMode(HsChannel *Chan, BOOL Enable) 210 struct { 211 HsChannel *Chan; 212 BOOL Enable; 213 } HS_EnableSniffMode_param; 214 #endif 215 216 struct { 217 uint32_t func_ptr; 218 uint32_t param0; 219 uint32_t param1; 220 } CustomFunc_param; 221 222 } bt_fn_param; 223 224 typedef struct { 225 uint32_t src_thread; 226 uint32_t request_id; 227 bt_fn_param param; 228 } APP_BT_MAIL; 229 230 typedef struct 231 { 232 btif_remote_device_t *remDev; 233 btif_link_policy_t policy; 234 } BT_SET_LINKPOLICY_REQ_T; 235 236 int app_bt_mail_init(void); 237 238 int app_bt_Me_switch_sco(uint16_t scohandle); 239 240 int app_bt_ME_SwitchRole(btif_remote_device_t* remDev); 241 242 int app_bt_ME_SetConnectionRole(btif_connection_role_t role); 243 244 int app_bt_MeDisconnectLink(btif_remote_device_t* remDev); 245 246 int app_bt_ME_StopSniff(btif_remote_device_t *remDev); 247 248 int app_bt_ME_SetAccessibleMode(btif_accessible_mode_t mode, const btif_access_mode_info_t *info); 249 250 int app_bt_Me_SetLinkPolicy(btif_remote_device_t *remDev, btif_link_policy_t policy); 251 252 int app_bt_CMGR_SetSniffTimer(btif_cmgr_handler_t *Handler, 253 btif_sniff_info_t* SniffInfo, 254 TimeT Time); 255 256 int app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(btif_sniff_info_t* SniffInfo, 257 btif_remote_device_t *RemDev); 258 259 int app_bt_A2DP_OpenStream(a2dp_stream_t *Stream, bt_bdaddr_t *Addr); 260 261 int app_bt_A2DP_CloseStream(a2dp_stream_t *Stream); 262 263 int app_bt_A2DP_SetMasterRole(a2dp_stream_t *Stream, BOOL Flag); 264 265 int app_bt_HF_CreateServiceLink(hf_chan_handle_t Chan, bt_bdaddr_t *Addr); 266 267 int app_bt_HF_DisconnectServiceLink(hf_chan_handle_t Chan); 268 269 int app_bt_HF_CreateAudioLink(hf_chan_handle_t Chan); 270 271 int app_bt_HF_DisconnectAudioLink(hf_chan_handle_t Chan); 272 273 int app_bt_HF_EnableSniffMode(hf_chan_handle_t Chan, BOOL Enable); 274 275 int app_bt_HF_SetMasterRole(hf_chan_handle_t Chan, BOOL Flag); 276 277 void app_bt_accessible_manager_process(const btif_event_t *Event); 278 void app_bt_role_manager_process(const btif_event_t* Event); 279 void app_bt_sniff_manager_process(const btif_event_t *Event); 280 //void app_bt_golbal_handle_hook(const btif_event_t *Event); 281 282 int app_bt_ME_ControlSleepMode(bool isEnabled); 283 284 #ifdef BTIF_DIP_DEVICE 285 int app_bt_dip_QuryService(btif_dip_client_t *client, btif_remote_device_t* rem); 286 #endif 287 288 #if defined (__HSP_ENABLE__) 289 int app_bt_HS_CreateServiceLink(HsChannel *Chan, bt_bdaddr_t *Addr); 290 291 int app_bt_HS_CreateAudioLink(HsChannel *Chan); 292 293 int app_bt_HS_DisconnectAudioLink(HsChannel *Chan); 294 295 int app_bt_HS_DisconnectServiceLink(HsChannel *Chan); 296 297 int app_bt_HS_EnableSniffMode(HsChannel *Chan, BOOL Enable); 298 299 #endif 300 bool app_is_access_mode_set_pending(void); 301 void app_set_pending_access_mode(void); 302 void app_bt_set_linkpolicy(btif_remote_device_t *remDev, btif_link_policy_t policy); 303 void app_check_pending_stop_sniff_op(void); 304 BT_SET_LINKPOLICY_REQ_T* app_bt_pop_pending_set_linkpolicy(void); 305 void app_retry_setting_access_mode(void); 306 void app_set_accessmode(btif_accessible_mode_t mode); 307 308 int app_bt_start_custom_function_in_bt_thread( 309 uint32_t param0, uint32_t param1, uint32_t funcPtr); 310 int app_bt_ME_StartSniff(btif_remote_device_t *remDev, btif_sniff_info_t* sniffInfo); 311 312 int app_bt_Force_A2DP_OpenStream(a2dp_stream_t *Stream, bt_bdaddr_t *Addr); 313 314 int app_bt_Force_HF_CreateServiceLink(hf_chan_handle_t Chan, bt_bdaddr_t *Addr); 315 316 317 #ifdef __cplusplus 318 } 319 #endif 320 #endif /* __APP_BT_FUNC_H__ */ 321 322