The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 27 | #include <string.h> |
| 28 | |
Pavlin Radoslavov | 258c253 | 2015-09-27 20:59:05 -0700 | [diff] [blame] | 29 | #include "bt_common.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | #include "pan_api.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 31 | #include "bta_api.h" |
| 32 | #include "bta_pan_api.h" |
| 33 | #include "bta_pan_ci.h" |
| 34 | #include "bta_pan_int.h" |
Mike J. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 35 | #include "bt_utils.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 36 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 37 | #if (BTA_PAN_INCLUDED == TRUE) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 38 | |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 52 | void bta_pan_ci_tx_ready(uint16_t handle) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 53 | { |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 54 | BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 55 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 56 | 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 60 | } |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 75 | void bta_pan_ci_rx_ready(uint16_t handle) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 76 | { |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 77 | BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 78 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 79 | 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 83 | } |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 100 | void bta_pan_ci_tx_flow(uint16_t handle, bool enable) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 101 | { |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 102 | 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 104 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 105 | 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 110 | } |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 124 | void 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 126 | { |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 127 | BT_HDR *p_buf = (BT_HDR *)osi_malloc(PAN_BUF_SIZE); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 128 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 129 | p_buf->offset = PAN_MINIMUM_OFFSET; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 130 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 131 | /* 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 137 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 138 | /* copy data */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 139 | memcpy((uint8_t *)(p_buf + 1) + p_buf->offset, p_data, len); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 140 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 141 | p_buf->layer_specific = handle; |
| 142 | p_buf->event = BTA_PAN_CI_RX_WRITEBUF_EVT; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 143 | |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 144 | bta_sys_sendmsg(p_buf); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 145 | } |
| 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 Radoslavov | cceb430 | 2016-02-05 13:54:43 -0800 | [diff] [blame] | 154 | ** the data buffer. The buffer will be freed by BTA; the |
| 155 | ** phone must not free the buffer. |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 156 | ** |
| 157 | ** |
| 158 | ** Returns void |
| 159 | ** |
| 160 | *******************************************************************************/ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 161 | void 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 163 | { |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 189 | BT_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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 191 | { |
| 192 | tBTA_PAN_SCB * p_scb; |
| 193 | BT_HDR * p_buf; |
| 194 | |
| 195 | p_scb = bta_pan_scb_by_handle(handle); |
| 196 | |
Pavlin Radoslavov | 1a3844f | 2015-09-25 11:21:15 -0700 | [diff] [blame] | 197 | p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue); |
| 198 | if (p_buf != NULL) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 199 | { |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 221 | void 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 223 | { |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 240 | void 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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 241 | { |
| 242 | |
| 243 | PAN_SetProtocolFilters(handle, num_filters, p_start_array, p_end_array ); |
| 244 | |
| 245 | } |
Mike J. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 246 | #else |
| 247 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 248 | void bta_pan_ci_tx_ready(uint16_t handle) |
Mike J. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 249 | { |
| 250 | UNUSED(handle); |
| 251 | } |
| 252 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 253 | void bta_pan_ci_rx_ready(uint16_t handle) |
Mike J. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 254 | { |
| 255 | UNUSED(handle); |
| 256 | } |
| 257 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 258 | void bta_pan_ci_tx_flow(uint16_t handle, bool enable) |
Mike J. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 259 | { |
| 260 | UNUSED(handle); |
| 261 | UNUSED(enable); |
| 262 | } |
| 263 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 264 | void 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. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 265 | { |
| 266 | UNUSED(handle); |
| 267 | UNUSED(src); |
| 268 | UNUSED(dst); |
| 269 | UNUSED(protocol); |
| 270 | UNUSED(p_buf); |
| 271 | UNUSED(ext); |
| 272 | } |
| 273 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 274 | BT_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. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 276 | { |
| 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 Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 286 | void bta_pan_ci_set_pfilters(uint16_t handle, uint16_t num_filters, uint16_t *p_start_array, uint16_t *p_end_array) |
Mike J. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 287 | { |
| 288 | UNUSED(handle); |
| 289 | UNUSED(num_filters); |
| 290 | UNUSED(p_start_array); |
| 291 | UNUSED(p_end_array); |
| 292 | } |
| 293 | |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 294 | void 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. Chen | 3576c56 | 2014-04-01 12:54:27 -0700 | [diff] [blame] | 296 | { |
| 297 | UNUSED(handle); |
| 298 | UNUSED(num_mcast_filters); |
| 299 | UNUSED(p_start_array); |
| 300 | UNUSED(p_end_array); |
| 301 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 302 | |
| 303 | #endif /* BTA_PAN_API */ |