1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
26
27
28
29
30
31
32
33
34
35
36
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
92
93
94
95
96
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
124
125
126
127
128
129
130
131
132
133
134
135
136
153
154
155
156
157
158
159
160
161
162
163
164
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
200
201
202
203
204
205
206
207
208
209
210
211
212
222
223
224
225
226
227
228
229
230
231
232
233
234
244
245
246
247
248
249
250
251
252
253
254
255
256
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
324
325
333
334
335
339
/* ... */
/* ... */
#include <string.h>
#include "bta/bta_hf_client_api.h"
#include "bta_hf_client_int.h"
#include "osi/allocator.h"
#if (BTA_HF_INCLUDED == TRUE)
/* ... */
static const tBTA_SYS_REG bta_hf_client_reg = {
bta_hf_client_hdl_event,
BTA_HfClientDisable
}{...};
static const uint8_t bta_hf_client_cb_data_size[] = {
0,
sizeof(tBTA_HF_CLIENT_REGISTER),
sizeof(tBTA_HF_CLIENT_OPEN),
0,
sizeof(tBTA_HF_CLIENT_CONN),
sizeof(tBTA_HF_CLIENT_HDR),
sizeof(tBTA_HF_CLIENT_HDR),
sizeof(tBTA_HF_CLIENT_HDR),
sizeof(tBTA_HF_CLIENT_VAL),
sizeof(tBTA_HF_CLIENT_VAL),
sizeof(tBTA_HF_CLIENT_IND),
sizeof(tBTA_HF_CLIENT_VAL),
sizeof(tBTA_HF_CLIENT_OPERATOR_NAME),
sizeof(tBTA_HF_CLIENT_NUMBER),
sizeof(tBTA_HF_CLIENT_NUMBER),
sizeof(tBTA_HF_CLIENT_AT_RESULT),
sizeof(tBTA_HF_CLIENT_CLCC),
sizeof(tBTA_HF_CLIENT_CNUM),
sizeof(tBTA_HF_CLIENT_VAL),
sizeof(tBTA_HF_CLIENT_VAL),
sizeof(tBTA_HF_CLIENT_NUMBER),
sizeof(tBTA_HF_CLIENT_VAL),
0,
sizeof(tBTA_SCO_PKT_STAT_NUMS),
}{...};
/* ... */
/* ... */
tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback)
{
tBTA_HF_CLIENT_API_ENABLE *p_buf;
if (bta_sys_is_register (BTA_ID_HS)) {
APPL_TRACE_ERROR("BTA HF Client is already enabled, ignoring ...");
return BTA_FAILURE;
}{...}
bta_sys_register(BTA_ID_HS, &bta_hf_client_reg);
if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) osi_malloc(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL) {
p_buf->hdr.event = BTA_HF_CLIENT_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
bta_sys_sendmsg(p_buf);
}{...}
return BTA_SUCCESS;
}{...}
/* ... */
void BTA_HfClientDisable(void)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HF_CLIENT_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
char *p_service_name)
{
tBTA_HF_CLIENT_API_REGISTER *p_buf;
if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) osi_malloc(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL) {
p_buf->hdr.event = BTA_HF_CLIENT_API_REGISTER_EVT;
p_buf->features = features;
p_buf->sec_mask = sec_mask;
if (p_service_name) {
BCM_STRNCPY_S(p_buf->name, p_service_name, BTA_SERVICE_NAME_LEN);
p_buf->name[BTA_SERVICE_NAME_LEN] = '\0';
}{...} else {
p_buf->name[0] = '\0';
}{...}
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientDeregister(UINT16 handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HF_CLIENT_API_DEREGISTER_EVT;
p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask)
{
tBTA_HF_CLIENT_API_OPEN *p_buf;
if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) osi_malloc(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL) {
p_buf->hdr.event = BTA_HF_CLIENT_API_OPEN_EVT;
p_buf->hdr.layer_specific = handle;
bdcpy(p_buf->bd_addr, bd_addr);
p_buf->sec_mask = sec_mask;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientClose(UINT16 handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HF_CLIENT_API_CLOSE_EVT;
p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientAudioOpen(UINT16 handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HF_CLIENT_API_AUDIO_OPEN_EVT;
p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientAudioClose(UINT16 handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT;
p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str)
{
tBTA_HF_CLIENT_DATA_VAL *p_buf;
if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) osi_malloc(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL) {
p_buf->hdr.event = BTA_HF_CLIENT_SEND_AT_CMD_EVT;
p_buf->uint8_val = at;
p_buf->uint32_val1 = val1;
p_buf->uint32_val2 = val2;
if (str) {
UINT32 str_len = strlen(str);
if (str_len > BTA_HF_CLIENT_MAX_LEN) {
APPL_TRACE_WARNING("%s, str length(%d) is more than %d, truncate it.", __FUNCTION__, str_len, BTA_HF_CLIENT_MAX_LEN);
str_len = BTA_HF_CLIENT_MAX_LEN;
}{...}
strlcpy(p_buf->str, str, str_len + 1);
}{...} else {
p_buf->str[0] = '\0';
}{...}
p_buf->hdr.layer_specific = handle;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
#if (BTM_SCO_HCI_INCLUDED == TRUE)
/* ... */
void BTA_HfClientPktStatsNumsGet(UINT16 sync_conn_handle)
{
tBTA_HF_CLIENT_PKT_STAT_GET *p_buf;
if ((p_buf = (tBTA_HF_CLIENT_PKT_STAT_GET *) osi_malloc(sizeof(tBTA_HF_CLIENT_PKT_STAT_GET))) != NULL) {
p_buf->hdr.event = BTA_HF_CLIENT_PKT_NUMS_GET_EVT;
p_buf->sync_conn_handle = sync_conn_handle;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
void BTA_HfClientCiData(void)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HF_CLIENT_CI_SCO_DATA_EVT;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */#endif
int BTA_HfClientGetCbDataSize(tBTA_HF_CLIENT_EVT event)
{
return bta_hf_client_cb_data_size[event];
}{...}
/* ... */#endif