• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2003-2012 Broadcom Corporation
4  *
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:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the implementation file for audio gateway call-in functions.
22  *
23  ******************************************************************************/
24 
25 #include <string.h>
26 #include "bta_api.h"
27 #include "bta_ag_api.h"
28 #include "bta_ag_int.h"
29 #include "bta_ag_ci.h"
30 #include "bt_common.h"
31 
32 /******************************************************************************
33 **
34 ** Function         bta_ag_ci_rx_write
35 **
36 ** Description      This function is called to send data to the AG when the AG
37 **                  is configured for AT command pass-through.  The function
38 **                  copies data to an event buffer and sends it.
39 **
40 ** Returns          void
41 **
42 ******************************************************************************/
bta_ag_ci_rx_write(UINT16 handle,char * p_data,UINT16 len)43 void bta_ag_ci_rx_write(UINT16 handle, char *p_data, UINT16 len)
44 {
45     UINT16 len_remaining = len;
46     char *p_data_area;
47 
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;
50 
51     while (len_remaining) {
52         if (len_remaining < len)
53             len = len_remaining;
54 
55         tBTA_AG_CI_RX_WRITE *p_buf =
56             (tBTA_AG_CI_RX_WRITE *)osi_malloc(sizeof(tBTA_AG_CI_RX_WRITE) + len + 1);
57         p_buf->hdr.event = BTA_AG_CI_RX_WRITE_EVT;
58         p_buf->hdr.layer_specific = handle;
59 
60         p_data_area = (char *)(p_buf+1);        /* Point to data area after header */
61         strncpy(p_data_area, p_data, len);
62         p_data_area[len] = 0;
63 
64         bta_sys_sendmsg(p_buf);
65 
66         len_remaining -= len;
67         p_data += len;
68     }
69 }
70 
71 /******************************************************************************
72 **
73 ** Function         bta_ag_ci_slc_ready
74 **
75 ** Description      This function is called to notify AG that SLC is up at
76 **                  the application. This funcion is only used when the app
77 **                  is running in pass-through mode.
78 **
79 ** Returns          void
80 **
81 ******************************************************************************/
bta_ag_ci_slc_ready(UINT16 handle)82 void bta_ag_ci_slc_ready(UINT16 handle)
83 {
84     tBTA_AG_DATA *p_buf = (tBTA_AG_DATA *)osi_malloc(sizeof(tBTA_AG_DATA));
85 
86     p_buf->hdr.event = BTA_AG_CI_SLC_READY_EVT;
87     p_buf->hdr.layer_specific = handle;
88 
89     bta_sys_sendmsg(p_buf);
90 }
91