blob: bd3f348e4c1d1f402b936d3abdcaa83466766cf0 [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
2 *
3 * Copyright (C) 2004-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 data gateway call-in functions.
22 *
23 ******************************************************************************/
24
25#include "bt_target.h"
26
The Android Open Source Project5738f832012-12-12 16:00:35 -080027#include <string.h>
28
Pavlin Radoslavov258c2532015-09-27 20:59:05 -070029#include "bt_common.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080030#include "pan_api.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080031#include "bta_api.h"
32#include "bta_pan_api.h"
33#include "bta_pan_ci.h"
34#include "bta_pan_int.h"
Mike J. Chen3576c562014-04-01 12:54:27 -070035#include "bt_utils.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080036
Marie Janssene9e58ce2016-06-17 14:12:17 -070037#if (BTA_PAN_INCLUDED == TRUE)
The Android Open Source Project5738f832012-12-12 16:00:35 -080038
39/*******************************************************************************
40**
41** Function bta_pan_ci_tx_ready
42**
43** Description This function sends an event to PAN indicating the phone is
44** ready for more data and PAN should call bta_pan_co_tx_path().
45** This function is used when the TX data path is configured
46** to use a pull interface.
47**
48**
49** Returns void
50**
51*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -070052void bta_pan_ci_tx_ready(uint16_t handle)
The Android Open Source Project5738f832012-12-12 16:00:35 -080053{
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -080054 BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR));
The Android Open Source Project5738f832012-12-12 16:00:35 -080055
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -080056 p_buf->layer_specific = handle;
57 p_buf->event = BTA_PAN_CI_TX_READY_EVT;
58
59 bta_sys_sendmsg(p_buf);
The Android Open Source Project5738f832012-12-12 16:00:35 -080060}
61
62/*******************************************************************************
63**
64** Function bta_pan_ci_rx_ready
65**
66** Description This function sends an event to PAN indicating the phone
67** has data available to send to PAN and PAN should call
68** bta_pan_co_rx_path(). This function is used when the RX
69** data path is configured to use a pull interface.
70**
71**
72** Returns void
73**
74*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -070075void bta_pan_ci_rx_ready(uint16_t handle)
The Android Open Source Project5738f832012-12-12 16:00:35 -080076{
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -080077 BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR));
The Android Open Source Project5738f832012-12-12 16:00:35 -080078
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -080079 p_buf->layer_specific = handle;
80 p_buf->event = BTA_PAN_CI_RX_READY_EVT;
81
82 bta_sys_sendmsg(p_buf);
The Android Open Source Project5738f832012-12-12 16:00:35 -080083}
84
85/*******************************************************************************
86**
87** Function bta_pan_ci_tx_flow
88**
89** Description This function is called to enable or disable data flow on
90** the TX path. The phone should call this function to
91** disable data flow when it is congested and cannot handle
92** any more data sent by bta_pan_co_tx_write() or
93** bta_pan_co_tx_writebuf(). This function is used when the
94** TX data path is configured to use a push interface.
95**
96**
97** Returns void
98**
99*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -0700100void bta_pan_ci_tx_flow(uint16_t handle, bool enable)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800101{
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800102 tBTA_PAN_CI_TX_FLOW *p_buf =
103 (tBTA_PAN_CI_TX_FLOW *)osi_malloc(sizeof(tBTA_PAN_CI_TX_FLOW));
The Android Open Source Project5738f832012-12-12 16:00:35 -0800104
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800105 p_buf->hdr.layer_specific = handle;
106 p_buf->hdr.event = BTA_PAN_CI_TX_FLOW_EVT;
107 p_buf->enable = enable;
108
109 bta_sys_sendmsg(p_buf);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800110}
111
112/*******************************************************************************
113**
114** Function bta_pan_ci_rx_write
115**
116** Description This function is called to send data to PAN when the RX path
117** is configured to use a push interface. The function copies
118** data to an event buffer and sends it to PAN.
119**
120**
121** Returns void
122**
123*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -0700124void bta_pan_ci_rx_write(uint16_t handle, BD_ADDR dst, BD_ADDR src, uint16_t protocol,
125 uint8_t *p_data, uint16_t len, bool ext)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800126{
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800127 BT_HDR *p_buf = (BT_HDR *)osi_malloc(PAN_BUF_SIZE);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800128
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800129 p_buf->offset = PAN_MINIMUM_OFFSET;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800130
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800131 /* copy all other params before the data */
132 bdcpy(((tBTA_PAN_DATA_PARAMS *)p_buf)->src, src);
133 bdcpy(((tBTA_PAN_DATA_PARAMS *)p_buf)->dst, dst);
134 ((tBTA_PAN_DATA_PARAMS *)p_buf)->protocol = protocol;
135 ((tBTA_PAN_DATA_PARAMS *)p_buf)->ext = ext;
136 p_buf->len=len;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800137
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800138 /* copy data */
Marie Janssene9e58ce2016-06-17 14:12:17 -0700139 memcpy((uint8_t *)(p_buf + 1) + p_buf->offset, p_data, len);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800140
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800141 p_buf->layer_specific = handle;
142 p_buf->event = BTA_PAN_CI_RX_WRITEBUF_EVT;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800143
Pavlin Radoslavov717a4a92016-02-06 08:36:06 -0800144 bta_sys_sendmsg(p_buf);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800145}
146
147/*******************************************************************************
148**
149** Function bta_pan_ci_rx_writebuf
150**
151** Description This function is called to send data to the phone when
152** the RX path is configured to use a push interface with
153** zero copy. The function sends an event to PAN containing
Pavlin Radoslavovcceb4302016-02-05 13:54:43 -0800154** the data buffer. The buffer will be freed by BTA; the
155** phone must not free the buffer.
The Android Open Source Project5738f832012-12-12 16:00:35 -0800156**
157**
158** Returns void
159**
160*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -0700161void bta_pan_ci_rx_writebuf(uint16_t handle, BD_ADDR dst, BD_ADDR src, uint16_t protocol,
162 BT_HDR *p_buf, bool ext)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800163{
164
165 /* copy all other params before the data */
166 bdcpy(((tBTA_PAN_DATA_PARAMS *)p_buf)->src, src);
167 bdcpy(((tBTA_PAN_DATA_PARAMS *)p_buf)->dst, dst);
168 ((tBTA_PAN_DATA_PARAMS *)p_buf)->protocol = protocol;
169 ((tBTA_PAN_DATA_PARAMS *)p_buf)->ext = ext;
170
171 p_buf->layer_specific = handle;
172 p_buf->event = BTA_PAN_CI_RX_WRITEBUF_EVT;
173 bta_sys_sendmsg(p_buf);
174}
175
176
177
178
179/*******************************************************************************
180**
181** Function bta_pan_ci_readbuf
182**
183** Description
184**
185**
186** Returns void
187**
188*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -0700189BT_HDR * bta_pan_ci_readbuf(uint16_t handle, BD_ADDR src, BD_ADDR dst, uint16_t* p_protocol,
190 bool* p_ext, bool* p_forward)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800191{
192 tBTA_PAN_SCB * p_scb;
193 BT_HDR * p_buf;
194
195 p_scb = bta_pan_scb_by_handle(handle);
196
Pavlin Radoslavov1a3844f2015-09-25 11:21:15 -0700197 p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue);
198 if (p_buf != NULL)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800199 {
200 bdcpy(src,((tBTA_PAN_DATA_PARAMS *)p_buf)->src);
201 bdcpy(dst,((tBTA_PAN_DATA_PARAMS *)p_buf)->dst);
202 *p_protocol = ((tBTA_PAN_DATA_PARAMS *)p_buf)->protocol;
203 *p_ext = ((tBTA_PAN_DATA_PARAMS *)p_buf)->ext;
204 *p_forward = ((tBTA_PAN_DATA_PARAMS *)p_buf)->forward;
205 }
206
207 return p_buf;
208}
209
210
211/*******************************************************************************
212**
213** Function bta_pan_ci_set_mfilters
214**
215** Description This function is called to set multicast filters
216**
217**
218** Returns void
219**
220*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -0700221void bta_pan_ci_set_mfilters(uint16_t handle, uint16_t num_mcast_filters, uint8_t *p_start_array,
222 uint8_t *p_end_array)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800223{
224
225 PAN_SetMulticastFilters(handle, num_mcast_filters, p_start_array, p_end_array);
226
227}
228
229
230/*******************************************************************************
231**
232** Function bta_pan_ci_set_mfilters
233**
234** Description This function is called to set protocol filters
235**
236**
237** Returns void
238**
239*******************************************************************************/
Marie Janssene9e58ce2016-06-17 14:12:17 -0700240void bta_pan_ci_set_pfilters(uint16_t handle, uint16_t num_filters, uint16_t *p_start_array, uint16_t *p_end_array)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800241{
242
243 PAN_SetProtocolFilters(handle, num_filters, p_start_array, p_end_array );
244
245}
Mike J. Chen3576c562014-04-01 12:54:27 -0700246#else
247
Marie Janssene9e58ce2016-06-17 14:12:17 -0700248void bta_pan_ci_tx_ready(uint16_t handle)
Mike J. Chen3576c562014-04-01 12:54:27 -0700249{
250 UNUSED(handle);
251}
252
Marie Janssene9e58ce2016-06-17 14:12:17 -0700253void bta_pan_ci_rx_ready(uint16_t handle)
Mike J. Chen3576c562014-04-01 12:54:27 -0700254{
255 UNUSED(handle);
256}
257
Marie Janssene9e58ce2016-06-17 14:12:17 -0700258void bta_pan_ci_tx_flow(uint16_t handle, bool enable)
Mike J. Chen3576c562014-04-01 12:54:27 -0700259{
260 UNUSED(handle);
261 UNUSED(enable);
262}
263
Marie Janssene9e58ce2016-06-17 14:12:17 -0700264void bta_pan_ci_rx_writebuf(uint16_t handle, BD_ADDR src, BD_ADDR dst, uint16_t protocol, BT_HDR *p_buf, bool ext)
Mike J. Chen3576c562014-04-01 12:54:27 -0700265{
266 UNUSED(handle);
267 UNUSED(src);
268 UNUSED(dst);
269 UNUSED(protocol);
270 UNUSED(p_buf);
271 UNUSED(ext);
272}
273
Marie Janssene9e58ce2016-06-17 14:12:17 -0700274BT_HDR * bta_pan_ci_readbuf(uint16_t handle, BD_ADDR src, BD_ADDR dst, uint16_t *p_protocol,
275 bool* p_ext, bool* p_forward)
Mike J. Chen3576c562014-04-01 12:54:27 -0700276{
277 UNUSED(handle);
278 UNUSED(src);
279 UNUSED(dst);
280 UNUSED(p_protocol);
281 UNUSED(p_ext);
282 UNUSED(p_forward);
283 return NULL;
284}
285
Marie Janssene9e58ce2016-06-17 14:12:17 -0700286void bta_pan_ci_set_pfilters(uint16_t handle, uint16_t num_filters, uint16_t *p_start_array, uint16_t *p_end_array)
Mike J. Chen3576c562014-04-01 12:54:27 -0700287{
288 UNUSED(handle);
289 UNUSED(num_filters);
290 UNUSED(p_start_array);
291 UNUSED(p_end_array);
292}
293
Marie Janssene9e58ce2016-06-17 14:12:17 -0700294void bta_pan_ci_set_mfilters(uint16_t handle, uint16_t num_mcast_filters, uint8_t *p_start_array,
295 uint8_t *p_end_array)
Mike J. Chen3576c562014-04-01 12:54:27 -0700296{
297 UNUSED(handle);
298 UNUSED(num_mcast_filters);
299 UNUSED(p_start_array);
300 UNUSED(p_end_array);
301}
The Android Open Source Project5738f832012-12-12 16:00:35 -0800302
303#endif /* BTA_PAN_API */