The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 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 API implementation file for the BTA device manager. |
| 22 | * |
| 23 | ******************************************************************************/ |
Myles Watson | f355ef5 | 2016-11-09 13:04:33 -0800 | [diff] [blame] | 24 | #include <string.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 25 | |
Pavlin Radoslavov | 258c253 | 2015-09-27 20:59:05 -0700 | [diff] [blame] | 26 | #include "bt_common.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 27 | #include "bta_api.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 28 | #include "bta_dm_ci.h" |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 29 | #include "bta_dm_int.h" |
| 30 | #include "bta_sys.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 31 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 32 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 33 | * |
| 34 | * Function bta_dm_ci_io_req |
| 35 | * |
| 36 | * Description This function must be called in response to function |
| 37 | * bta_dm_co_io_req(), if *p_oob_data to BTA_OOB_UNKNOWN |
| 38 | * by bta_dm_co_io_req(). |
| 39 | * |
| 40 | * Returns void |
| 41 | * |
| 42 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 43 | void bta_dm_ci_io_req(const bt_bdaddr_t& bd_addr, tBTA_IO_CAP io_cap, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 44 | tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 45 | |
| 46 | { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 47 | tBTA_DM_CI_IO_REQ* p_msg = |
| 48 | (tBTA_DM_CI_IO_REQ*)osi_malloc(sizeof(tBTA_DM_CI_IO_REQ)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 49 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 50 | p_msg->hdr.event = BTA_DM_CI_IO_REQ_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 51 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 52 | p_msg->io_cap = io_cap; |
| 53 | p_msg->oob_data = oob_data; |
| 54 | p_msg->auth_req = auth_req; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 55 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 56 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 60 | * |
| 61 | * Function bta_dm_ci_rmt_oob |
| 62 | * |
| 63 | * Description This function must be called in response to function |
| 64 | * bta_dm_co_rmt_oob() to provide the OOB data associated |
| 65 | * with the remote device. |
| 66 | * |
| 67 | * Returns void |
| 68 | * |
| 69 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 70 | void bta_dm_ci_rmt_oob(bool accept, const bt_bdaddr_t& bd_addr, BT_OCTET16 c, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 71 | BT_OCTET16 r) { |
| 72 | tBTA_DM_CI_RMT_OOB* p_msg = |
| 73 | (tBTA_DM_CI_RMT_OOB*)osi_malloc(sizeof(tBTA_DM_CI_RMT_OOB)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 74 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 75 | p_msg->hdr.event = BTA_DM_CI_RMT_OOB_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 76 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 77 | p_msg->accept = accept; |
| 78 | memcpy(p_msg->c, c, BT_OCTET16_LEN); |
| 79 | memcpy(p_msg->r, r, BT_OCTET16_LEN); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 80 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 81 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 82 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 83 | |
| 84 | #if (BTM_SCO_HCI_INCLUDED == TRUE) |
| 85 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 86 | * |
| 87 | * Function bta_dm_sco_ci_data_ready |
| 88 | * |
| 89 | * Description This function sends an event to indicating that the phone |
| 90 | * has SCO data ready. |
| 91 | * |
| 92 | * Parameters event: is obtained from bta_dm_sco_co_open() function, which |
| 93 | * is the BTA event we want to send back to BTA module |
| 94 | * when there is encoded data ready. |
| 95 | * sco_handle: is the BTA sco handle which indicate a specific |
| 96 | * SCO connection. |
| 97 | * Returns void |
| 98 | * |
| 99 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 100 | void bta_dm_sco_ci_data_ready(uint16_t event, uint16_t sco_handle) { |
| 101 | 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] | 102 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 103 | p_buf->event = event; |
| 104 | p_buf->layer_specific = sco_handle; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 105 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 106 | bta_sys_sendmsg(p_buf); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 107 | } |
| 108 | #endif |