Select one of the symbols to view example projects that use it.
 
Outline
#include <string.h>
#include "bta/bta_api.h"
#include "bta/bta_sys.h"
#include "bta/bta_ag_api.h"
#include "bta_ag_int.h"
#include "osi/allocator.h"
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
bt
common
controller
esp_ble_mesh
host
bluedroid
api
bta
ar
av
dm
gatt
hd
hf_ag
include
hf_client
hh
include
jv
sdp
sys
btc
common
config
device
external
hci
main
stack
nimble
include
porting
cmock
console
cxx
driver
efuse
esp_adc
esp_app_format
esp_bootloader_format
esp_coex
esp_common
esp_driver_ana_cmpr
esp_driver_cam
esp_driver_dac
esp_driver_gpio
esp_driver_gptimer
esp_driver_i2c
esp_driver_i2s
esp_driver_jpeg
esp_driver_ledc
esp_driver_mcpwm
esp_driver_parlio
esp_driver_pcnt
esp_driver_rmt
esp_driver_sdio
esp_driver_sdm
esp_driver_sdmmc
esp_driver_sdspi
esp_driver_spi
esp_driver_tsens
esp_driver_uart
esp_driver_usb_serial_jtag
esp_eth
esp_event
esp_gdbstub
esp_hid
esp_http_client
esp_http_server
esp_https_ota
esp_https_server
esp_hw_support
esp_lcd
esp_local_ctrl
esp_mm
esp_netif
esp_partition
esp_phy
esp_pm
esp_psram
esp_ringbuf
esp_rom
esp_security
esp_system
esp_timer
esp_vfs_console
esp_wifi
esp-tls
espcoredump
hal
heap
http_parser
ieee802154
log
mqtt
newlib
nvs_flash
nvs_sec_provider
openthread
perfmon
protobuf-c
protocomm
pthread
rt
sdmmc
soc
spi_flash
spiffs
tcp_transport
ulp
unity
vfs
wear_levelling
wifi_provisioning
wpa_supplicant
xtensa
examples
lwIP
FreeRTOS
cJSON
mbedTLS
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bt/host/bluedroid/bta/hf_ag/bta_ag_api.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/****************************************************************************** * * Copyright (C) 2003-2012 Broadcom Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************//* ... */ /****************************************************************************** * * This is the implementation of the API for the audio gateway (AG) * subsystem of BTA, Broadcom's Bluetooth application layer for mobile * phones. * ******************************************************************************//* ... */ #include <string.h> #include "bta/bta_api.h" #include "bta/bta_sys.h" #include "bta/bta_ag_api.h" #include "bta_ag_int.h" #include "osi/allocator.h"6 includes #if (BTA_AG_INCLUDED == TRUE) /***************************************************************************** ** Constants *****************************************************************************//* ... */ static const tBTA_SYS_REG bta_ag_reg = { bta_ag_hdl_event, BTA_AgDisable }{...}; /******************************************************************************* ** ** Function BTA_AgEnable ** ** Description Enable the audio gateway service. When the enable ** operation is complete the callback function will be ** called with a BTA_AG_ENABLE_EVT. This function must ** be called before other function in the AG API are ** called. ** ** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise. ** *******************************************************************************//* ... */ tBTA_STATUS BTA_AgEnable(tBTA_AG_PARSE_MODE parse_mode, tBTA_AG_CBACK *p_cback) { tBTA_AG_API_ENABLE *p_buf; UINT8 idx; /* Error if AG is already enabled, or AG is in the middle of disabling. */ for (idx = 0; idx < BTA_AG_NUM_SCB; idx++) { if (bta_ag_cb.scb[idx].in_use) { APPL_TRACE_ERROR ("BTA_AgEnable: FAILED, AG already enabled."); return BTA_FAILURE; }{...} }{...} /* register with BTA system manager */ bta_sys_register(BTA_ID_AG, &bta_ag_reg); if ((p_buf = (tBTA_AG_API_ENABLE *) osi_malloc(sizeof(tBTA_AG_API_ENABLE))) != NULL) { p_buf->hdr.event = BTA_AG_API_ENABLE_EVT; p_buf->parse_mode = parse_mode; p_buf->p_cback = p_cback; bta_sys_sendmsg(p_buf); }{...} return BTA_SUCCESS; }{...} /******************************************************************************* ** ** Function BTA_AgDisable ** ** Description Disable the audio gateway service ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgDisable(void) { BT_HDR *p_buf; if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) { p_buf->event = BTA_AG_API_DISABLE_EVT; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgRegister ** ** Description Register an Audio Gateway service. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgRegister(tBTA_SERVICE_MASK services, tBTA_SEC sec_mask,tBTA_AG_FEAT features, char * p_service_names[], UINT8 app_id) { tBTA_AG_API_REGISTER *p_buf; int i; if ((p_buf = (tBTA_AG_API_REGISTER *) osi_malloc(sizeof(tBTA_AG_API_REGISTER))) != NULL) { p_buf->hdr.event = BTA_AG_API_REGISTER_EVT; p_buf->features = features; p_buf->sec_mask = sec_mask; p_buf->services = services; p_buf->app_id = app_id; for (i = 0; i < BTA_AG_NUM_IDX; i++) { if(p_service_names[i]) { BCM_STRNCPY_S(p_buf->p_name[i], p_service_names[i], BTA_SERVICE_NAME_LEN); p_buf->p_name[i][BTA_SERVICE_NAME_LEN] = '\0'; }{...} else { p_buf->p_name[i][0] = '\0'; }{...} }{...} bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgDeregister ** ** Description Deregister an audio gateway service. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgDeregister(UINT16 handle) { BT_HDR *p_buf; if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) { p_buf->event = BTA_AG_API_DEREGISTER_EVT; p_buf->layer_specific = handle; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgOpen ** ** Description Opens a connection to a headset or hands-free device. ** When connection is open callback function is called ** with a BTA_AG_OPEN_EVT. Only the data connection is ** opened. The audio connection is not opened. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask, tBTA_SERVICE_MASK services) { tBTA_AG_API_OPEN *p_buf; if ((p_buf = (tBTA_AG_API_OPEN *) osi_malloc(sizeof(tBTA_AG_API_OPEN))) != NULL) { p_buf->hdr.event = BTA_AG_API_OPEN_EVT; p_buf->hdr.layer_specific = handle; bdcpy(p_buf->bd_addr, bd_addr); p_buf->services = services; p_buf->sec_mask = sec_mask; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgClose ** ** Description Close the current connection to a headset or a handsfree ** Any current audio connection will also be closed. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgClose(UINT16 handle) { BT_HDR *p_buf; if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) { p_buf->event = BTA_AG_API_CLOSE_EVT; p_buf->layer_specific = handle; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgAudioOpen ** ** Description Opens an audio connection to the currently connected ** headset or handsfree. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgAudioOpen(UINT16 handle) { BT_HDR *p_buf; if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) { p_buf->event = BTA_AG_API_AUDIO_OPEN_EVT; p_buf->layer_specific = handle; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgAudioClose ** ** Description Close the currently active audio connection to a headset ** or handsfree. The data connection remains open ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgAudioClose(UINT16 handle) { BT_HDR *p_buf; if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) { p_buf->event = BTA_AG_API_AUDIO_CLOSE_EVT; p_buf->layer_specific = handle; bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgResult ** ** Description Send an AT result code to a headset or hands-free device. ** This function is only used when the AG parse mode is set ** to BTA_AG_PARSE. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgResult(UINT16 handle, tBTA_AG_RES result, tBTA_AG_RES_DATA *p_data) { tBTA_AG_API_RESULT *p_buf; if ((p_buf = (tBTA_AG_API_RESULT *) osi_malloc(sizeof(tBTA_AG_API_RESULT))) != NULL) { p_buf->hdr.event = BTA_AG_API_RESULT_EVT; p_buf->hdr.layer_specific = handle; p_buf->result = result; if(p_data) { memcpy(&p_buf->data, p_data, sizeof(p_buf->data)); }{...} bta_sys_sendmsg(p_buf); }{...} }{...} /******************************************************************************* ** ** Function BTA_AgSetCodec ** ** Description Specify the codec type to be used for the subsequent ** audio connection. ** ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec) { tBTA_AG_API_SETCODEC *p_buf; if ((p_buf = (tBTA_AG_API_SETCODEC *) osi_malloc(sizeof(tBTA_AG_API_SETCODEC))) != NULL) { p_buf->hdr.event = BTA_AG_API_SETCODEC_EVT; p_buf->hdr.layer_specific = handle; p_buf->codec = codec; bta_sys_sendmsg(p_buf); }{...} }{...} #if (BTM_SCO_HCI_INCLUDED == TRUE) /******************************************************************************* ** ** Function BTA_AgPktStatsNumsGet ** ** Description Specify the sync_conn_handle to be used for the packet numbers ** received or send. ** ** ** Returns void ** *******************************************************************************//* ... */ void BTA_AgPktStatsNumsGet(UINT16 handle, UINT16 sync_conn_handle) { tBTA_AG_PKT_STAT_GET *p_buf; if ((p_buf = (tBTA_AG_PKT_STAT_GET *) osi_malloc(sizeof(tBTA_AG_PKT_STAT_GET))) != NULL) { p_buf->hdr.event = BTA_AG_PKT_STAT_NUMS_GET_EVT; p_buf->hdr.layer_specific = handle; p_buf->sync_conn_handle = sync_conn_handle; bta_sys_sendmsg(p_buf); }{...} }{...} /************************************************************************************************ * Function BTA_AgCiData * * Description Trigger the lower-layer to fetch and send audio data. This function is only * only used in the case that Voice Over HCI is enabled. Precondition is that * the HFP audio connection is connected. After this function is called, lower * layer will invoke esp_hf_client_outgoing_data_cb_t to fetch data * ***********************************************************************************************//* ... */ void BTA_AgCiData(UINT16 handle) { BT_HDR *p_buf; tBTA_AG_SCB *p_scb; if ((p_scb = bta_ag_scb_by_idx(handle)) != NULL && (p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) { p_buf->event = BTA_AG_CI_SCO_DATA_EVT; p_buf->layer_specific = handle; bta_sys_sendmsg(p_buf); }{...} }{...} /* ... */#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */ /* ... */ #endif /* #if (BTA_AG_INCLUDED == TRUE)*/
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.