1/******************************************************************************
2 *
3 *  Copyright (C) 2009-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 the HeaLth device profile (HL)
22 *  subsystem call-in functions.
23 *
24 ******************************************************************************/
25
26#include <stddef.h>
27
28#include "bta_api.h"
29#include "bta_hl_api.h"
30#include "bta_hl_ci.h"
31#include "bta_hl_co.h"
32#include "bta_hl_int.h"
33#include "bta_sys.h"
34#include "btm_api.h"
35
36/*******************************************************************************
37 *
38 * Function         bta_hl_ci_get_tx_data
39 *
40 * Description      This function is called in response to the
41 *                  bta_hl_co_get_tx_data call-out function.
42 *
43 * Parameters       mdl_handle -MDL handle
44 *                  status - BTA_MA_STATUS_OK if operation is successful
45 *                           BTA_MA_STATUS_FAIL if any errors have occurred.
46 *                  evt    - evt from the call-out function
47 *
48 * Returns          void
49 *
50 ******************************************************************************/
51void bta_hl_ci_get_tx_data(tBTA_HL_MDL_HANDLE mdl_handle, tBTA_HL_STATUS status,
52                           uint16_t evt) {
53  tBTA_HL_CI_GET_PUT_DATA* p_evt =
54      (tBTA_HL_CI_GET_PUT_DATA*)osi_malloc(sizeof(tBTA_HL_CI_GET_PUT_DATA));
55
56#if (BTA_HL_DEBUG == TRUE)
57  APPL_TRACE_DEBUG("%s mdl_handle=%d status=%d evt=%d\n", __func__, mdl_handle,
58                   status, evt);
59#endif
60
61  p_evt->hdr.event = evt;
62  p_evt->mdl_handle = mdl_handle;
63  p_evt->status = status;
64
65  bta_sys_sendmsg(p_evt);
66}
67
68/*******************************************************************************
69 *
70 * Function         bta_hl_ci_put_rx_data
71 *
72 * Description      This function is called in response to the
73 *                  bta_hl_co_put_rx_data call-out function.
74 *
75 * Parameters       mdl_handle -MDL handle
76 *                  status - BTA_MA_STATUS_OK if operation is successful
77 *                           BTA_MA_STATUS_FAIL if any errors have occurred.
78 *                  evt    - evt from the call-out function
79 *
80 * Returns          void
81 *
82 ******************************************************************************/
83extern void bta_hl_ci_put_rx_data(tBTA_HL_MDL_HANDLE mdl_handle,
84                                  tBTA_HL_STATUS status, uint16_t evt) {
85  tBTA_HL_CI_GET_PUT_DATA* p_evt =
86      (tBTA_HL_CI_GET_PUT_DATA*)osi_malloc(sizeof(tBTA_HL_CI_GET_PUT_DATA));
87
88#if (BTA_HL_DEBUG == TRUE)
89  APPL_TRACE_DEBUG("%s mdl_handle=%d status=%d evt=%d\n", __func__, mdl_handle,
90                   status, evt);
91#endif
92
93  p_evt->hdr.event = evt;
94  p_evt->mdl_handle = mdl_handle;
95  p_evt->status = status;
96
97  bta_sys_sendmsg(p_evt);
98}
99
100/*******************************************************************************
101 *
102 * Function         bta_hl_ci_get_echo_data
103 *
104 * Description      This function is called in response to the
105 *                  bta_hl_co_get_echo_data call-out function.
106 *
107 * Parameters       mcl_handle -MCL handle
108 *                  status - BTA_MA_STATUS_OK if operation is successful
109 *                           BTA_MA_STATUS_FAIL if any errors have occurred.
110 *                  evt    - evt from the call-out function
111 *
112 * Returns          void
113 *
114 ******************************************************************************/
115extern void bta_hl_ci_get_echo_data(tBTA_HL_MCL_HANDLE mcl_handle,
116                                    tBTA_HL_STATUS status, uint16_t evt) {
117  tBTA_HL_CI_ECHO_DATA* p_evt =
118      (tBTA_HL_CI_ECHO_DATA*)osi_malloc(sizeof(tBTA_HL_CI_ECHO_DATA));
119
120#if (BTA_HL_DEBUG == TRUE)
121  APPL_TRACE_DEBUG("%s mcl_handle=%d status=%d evt=%d\n", __func__, mcl_handle,
122                   status, evt);
123#endif
124
125  p_evt->hdr.event = evt;
126  p_evt->mcl_handle = mcl_handle;
127  p_evt->status = status;
128
129  bta_sys_sendmsg(p_evt);
130}
131
132/*******************************************************************************
133 *
134 * Function         bta_hl_ci_put_echo_data
135 *
136 * Description      This function is called in response to the
137 *                  bta_hl_co_put_echo_data call-out function.
138 *
139 * Parameters       mcl_handle -MCL handle
140 *                  status - BTA_MA_STATUS_OK if operation is successful
141 *                           BTA_MA_STATUS_FAIL if any errors have occurred.
142 *                  evt    - evt from the call-out function
143 *
144 * Returns          void
145 *
146 ******************************************************************************/
147extern void bta_hl_ci_put_echo_data(tBTA_HL_MCL_HANDLE mcl_handle,
148                                    tBTA_HL_STATUS status, uint16_t evt) {
149  tBTA_HL_CI_ECHO_DATA* p_evt =
150      (tBTA_HL_CI_ECHO_DATA*)osi_malloc(sizeof(tBTA_HL_CI_ECHO_DATA));
151
152#if (BTA_HL_DEBUG == TRUE)
153  APPL_TRACE_DEBUG("%s mcl_handle=%d status=%d evt=%d\n", __func__, mcl_handle,
154                   status, evt);
155#endif
156
157  p_evt->hdr.event = evt;
158  p_evt->mcl_handle = mcl_handle;
159  p_evt->status = status;
160
161  bta_sys_sendmsg(p_evt);
162}
163