1 /*
2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3 */
4 #ifndef __BT_IF_H_
5 #define __BT_IF_H_
6 #include <stdint.h>
7 #include "bluetooth.h"
8 #include "btif_sys_config.h"
9 #include "me_api.h"
10
11 //Application ID,indentify profle app context
12 #define BTIF_APP_INVALID_ID (0x00000000)
13 #define BTIF_APP_HFP_PROFILE_ID (0x00000001)
14 #define BTIF_APP_A2DP_PROFILE_ID (0x00000002)
15 #define BTIF_APP_AVRCP_PROFILE_ID (0x00000004)
16 #define BTIF_APP_MAP_PROFILE_ID (0X00000008)
17
18 #define BTIF_APP_SPP_SERVER_START_ID (0x00000010)
19 #define BTIF_APP_SPP_SERVER_ID_1 (BTIF_APP_SPP_SERVER_START_ID)
20 #define BTIF_APP_SPP_SERVER_ID_2 (BTIF_APP_SPP_SERVER_START_ID << 1)
21 #define BTIF_APP_SPP_SERVER_ID_3 (BTIF_APP_SPP_SERVER_START_ID << 2)
22 #define BTIF_APP_SPP_SERVER_ID_4 (BTIF_APP_SPP_SERVER_START_ID << 3)
23 #define BTIF_APP_SPP_SERVER_ID_5 (BTIF_APP_SPP_SERVER_START_ID << 4)
24 #define BTIF_APP_SPP_SERVER_ID_6 (BTIF_APP_SPP_SERVER_START_ID << 5)
25 #define BTIF_APP_SPP_SERVER_ID_7 (BTIF_APP_SPP_SERVER_START_ID << 6)
26 #define BTIF_APP_SPP_SERVER_ID_8 (BTIF_APP_SPP_SERVER_START_ID << 7)
27 #define BTIF_APP_SPP_SERVER_ID_9 (BTIF_APP_SPP_SERVER_START_ID << 8)
28 #define BTIF_APP_SPP_SERVER_ID_10 (BTIF_APP_SPP_SERVER_START_ID << 9)
29 #define BTIF_APP_SPP_SERVER_END_ID (BTIF_APP_SPP_SERVER_ID_10)
30 #define BTIF_APP_SPP_SERVER_OFFSET (4)
31 #define BTIF_APP_SPP_SERVER_NUM (10)
32 #define BTIF_APP_SPP_SERVER_MASK (0x000003FF<<BTIF_APP_SPP_SERVER_OFFSET)
33
34
35 #define BTIF_APP_SPP_CLIENT_START_ID (BTIF_APP_SPP_SERVER_END_ID)
36 #define BTIF_APP_SPP_CLIENT_ID_1 (BTIF_APP_SPP_CLIENT_START_ID)
37 #define BTIF_APP_SPP_CLIENT_ID_2 (BTIF_APP_SPP_CLIENT_START_ID << 1)
38 #define BTIF_APP_SPP_CLIENT_ID_3 (BTIF_APP_SPP_CLIENT_START_ID << 2)
39 #define BTIF_APP_SPP_CLIENT_END_ID (BTIF_APP_SPP_CLIENT_ID_3)
40 #define BTIF_APP_SPP_OFFSET (4)
41 #define BTIF_APP_SPP_NUM (13)
42 #define BTIF_APP_SPP_MASK (0x00001FFF<<BTIF_APP_SPP_OFFSET)
43
44 #define BTIF_TWS_LINK_CONNECTED (1 << 0)
45 #define BTIF_TWS_L2CAP_CONNECTED (1 << 1)
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif /* */
50
51 enum pair_event
52 {
53 PAIR_EVENT_NUMERIC_REQ,
54 PAIR_EVENT_COMPLETE,
55 PAIR_EVENT_FAILED,
56 };
57
58 typedef void (*pairing_callback_t) (enum pair_event evt, const btif_event_t *event);
59 typedef void (*authing_callback_t) (void);
60
61 typedef void (*stack_ready_callback_t) (int status);
62 int bt_stack_register_ready_callback(stack_ready_callback_t ready_cb);
63 int bt_stack_initilize(void);
64 int bt_pairing_init(pairing_callback_t pair_cb);
65 #ifdef BTIF_SECURITY
66 int bt_authing_init(authing_callback_t auth_cb);
67 #else
bt_authing_init(authing_callback_t auth_cb)68 static inline int bt_authing_init(authing_callback_t auth_cb)
69 {
70 return 0;
71 }
72 #endif
73 int a2dp_codec_init(void);
74 int bt_stack_config(const unsigned char *dev_name, uint8_t len);
75 int bt_set_local_dev_name(const unsigned char *dev_name, uint8_t len);
76 void bt_process_stack_events(void);
77 void bt_generate_ecdh_key_pair(void);
78 uint8_t bt_get_sco_number(void);
79 void bt_set_sco_number(uint8_t sco_num);
80 void bt_fast_init(uint8_t* bt_addr, uint8_t* ble_addr);
81
82 void btif_set_btstack_chip_config(void *config);
83
84 #if defined(IBRT)
85 uint32_t btif_save_app_bt_device_ctx(uint8_t *ctx_buffer,uint8_t psm_context_mask);
86 uint32_t btif_set_app_bt_device_ctx(uint8_t *ctx_buffer,uint8_t psm_context_mask,uint8_t bt_devices_idx, uint8_t rm_detbl_idx, uint8_t avd_ctx_device_idx);
87 #endif
88
89 bool btif_hf_service_link_is_up(void);
90 bool btif_hf_audio_link_is_up(void);
91
92 void btif_pts_av_create_channel(bt_bdaddr_t *btaddr);
93 void btif_pts_av_disc_channel(void);
94 void btif_pts_av_set_sink_delay(void);
95 void btif_pts_ar_connect(bt_bdaddr_t *btaddr);
96 void btif_pts_ar_disconnect(void);
97 void btif_pts_ar_panel_stop(void);
98 void btif_pts_ar_panel_play(void);
99 void btif_pts_ar_panel_pause(void);
100 void btif_pts_ar_panel_forward(void);
101 void btif_pts_ar_panel_backward(void);
102 void btif_pts_ar_volume_up(void);
103 void btif_pts_ar_volume_down(void);
104 void btif_pts_ar_volume_notify(void);
105 void btif_pts_ar_volume_change(void);
106 void btif_pts_ar_set_absolute_volume(void);
107 void btif_pts_hf_create_service_link(bt_bdaddr_t *btaddr);
108 void btif_pts_hf_disc_service_link(void);
109 void btif_pts_hf_create_audio_link(void);
110 void btif_pts_hf_disc_audio_link(void);
111 void btif_pts_hf_redial_call(void);
112 void btif_pts_hf_answer_call(void);
113 void btif_pts_hf_hangup_call(void);
114 void btif_pts_hf_vr_enable(void);
115 void btif_pts_hf_vr_disable(void);
116 void btif_pts_hf_list_current_calls(void);
117 void btif_pts_hf_release_active_call_2(void);
118 void btif_pts_hf_hold_active_call_2(void);
119 void btif_pts_hf_release_active_call(void);
120 void btif_pts_hf_send_ind_1(void);
121 void btif_pts_hf_send_ind_2(void);
122 void btif_pts_hf_send_ind_3(void);
123 void btif_pts_hf_update_ind_value(void);
124 void btif_pts_rfc_register_channel(void);
125 void btif_pts_rfc_close(void);
126 void btif_pts_rfc_close_dlci_0(void);
127 void btif_pts_rfc_send_data(void);
128 void btif_pts_av_send_discover(void);
129 void btif_pts_av_send_getcap(void);
130 void btif_pts_av_send_setconf(void);
131 void btif_pts_av_send_getconf(void);
132 void btif_pts_av_send_reconf(void);
133 void btif_pts_av_send_open(void);
134 void btif_pts_av_send_close(void);
135 void btif_pts_av_send_abort(void);
136 void btif_pts_av_send_getallcap(void);
137 void btif_pts_av_send_suspend(void);
138 void btif_pts_av_send_start(void);
139 void btif_pts_av_create_media_channel(void);
140 void btif_pts_l2c_disc_channel(void);
141 void btif_pts_l2c_send_data(void);
142
143 #ifdef __cplusplus
144 }
145 #endif /* */
146
147 #endif /*__BT_IF_H_*/
148