1 /******************************************************************************
3 * Copyright (C) 2003-2012 Broadcom Corporation
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************************/
19 /******************************************************************************
21 * This is the implementation file for audio gateway call-in functions.
23 ******************************************************************************/
27 #include "bt_common.h"
28 #include "bta_ag_api.h"
29 #include "bta_ag_ci.h"
30 #include "bta_ag_int.h"
33 /******************************************************************************
35 * Function bta_ag_ci_rx_write
37 * Description This function is called to send data to the AG when the AG
38 * is configured for AT command pass-through. The function
39 * copies data to an event buffer and sends it.
43 *****************************************************************************/
44 void bta_ag_ci_rx_write(uint16_t handle, char* p_data, uint16_t len) {
45 uint16_t len_remaining = len;
48 if (len > (RFCOMM_DATA_BUF_SIZE - sizeof(tBTA_AG_CI_RX_WRITE) - 1))
49 len = RFCOMM_DATA_BUF_SIZE - sizeof(tBTA_AG_CI_RX_WRITE) - 1;
51 while (len_remaining) {
52 if (len_remaining < len) len = len_remaining;
54 tBTA_AG_CI_RX_WRITE* p_buf =
55 (tBTA_AG_CI_RX_WRITE*)osi_malloc(sizeof(tBTA_AG_CI_RX_WRITE) + len + 1);
56 p_buf->hdr.event = BTA_AG_CI_RX_WRITE_EVT;
57 p_buf->hdr.layer_specific = handle;
59 p_data_area = (char*)(p_buf + 1); /* Point to data area after header */
60 strncpy(p_data_area, p_data, len);
63 bta_sys_sendmsg(p_buf);
70 /******************************************************************************
72 * Function bta_ag_ci_slc_ready
74 * Description This function is called to notify AG that SLC is up at
75 * the application. This funcion is only used when the app
76 * is running in pass-through mode.
80 *****************************************************************************/
81 void bta_ag_ci_slc_ready(uint16_t handle) {
82 tBTA_AG_DATA* p_buf = (tBTA_AG_DATA*)osi_malloc(sizeof(tBTA_AG_DATA));
84 p_buf->hdr.event = BTA_AG_CI_SLC_READY_EVT;
85 p_buf->hdr.layer_specific = handle;
87 bta_sys_sendmsg(p_buf);