• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "main/shim/acl_legacy_interface.h"
18 
19 #include "stack/include/acl_hci_link_interface.h"
20 #include "stack/include/ble_acl_interface.h"
21 #include "stack/include/gatt_api.h"
22 #include "stack/include/sco_hci_link_interface.h"
23 #include "stack/include/sec_hci_link_interface.h"
24 
25 struct tBTM_ESCO_DATA;
26 void gatt_notify_phy_updated(tGATT_STATUS status, uint16_t handle,
27                              uint8_t tx_phy, uint8_t rx_phy);
28 void gatt_notify_subrate_change(uint16_t handle, uint16_t subrate_factor,
29                                 uint16_t latency, uint16_t cont_num,
30                                 uint16_t timeout, uint8_t status);
31 void l2cble_process_subrate_change_evt(uint16_t handle, uint8_t status,
32                                        uint16_t subrate_factor,
33                                        uint16_t peripheral_latency,
34                                        uint16_t cont_num, uint16_t timeout);
35 
on_le_subrate_change(uint16_t handle,uint16_t subrate_factor,uint16_t latency,uint16_t cont_num,uint16_t timeout,uint8_t status)36 static void on_le_subrate_change(uint16_t handle, uint16_t subrate_factor,
37                                  uint16_t latency, uint16_t cont_num,
38                                  uint16_t timeout, uint8_t status) {
39   l2cble_process_subrate_change_evt(handle, status, subrate_factor, latency,
40                                     cont_num, timeout);
41   gatt_notify_subrate_change(handle & 0x0FFF, subrate_factor, latency, cont_num,
42                              timeout, status);
43 }
44 
45 namespace bluetooth {
46 namespace shim {
47 namespace legacy {
48 
GetAclInterface()49 const acl_interface_t& GetAclInterface() {
50   static acl_interface_t acl_interface{
51       .on_send_data_upwards = acl_rcv_acl_data,
52       .on_packets_completed = acl_packets_completed,
53 
54       .connection.classic.on_connected = on_acl_br_edr_connected,
55       .connection.classic.on_connect_request = btm_connection_request,
56       .connection.classic.on_failed = on_acl_br_edr_failed,
57       .connection.classic.on_disconnected = btm_acl_disconnected,
58 
59       .connection.le.on_connected =
60           acl_ble_enhanced_connection_complete_from_shim,
61       .connection.le.on_failed = acl_ble_connection_fail,
62       .connection.le.on_disconnected = btm_acl_disconnected,
63       .connection.le.on_iso_disconnected = btm_acl_iso_disconnected,
64 
65       .connection.sco.on_esco_connect_request = btm_sco_on_esco_connect_request,
66       .connection.sco.on_sco_connect_request = btm_sco_on_sco_connect_request,
67       .connection.sco.on_disconnected = btm_sco_on_disconnected,
68 
69       .link.classic.on_authentication_complete = btm_sec_auth_complete,
70       .link.classic.on_central_link_key_complete = nullptr,
71       .link.classic.on_change_connection_link_key_complete = nullptr,
72       .link.classic.on_encryption_change = nullptr,
73       .link.classic.on_flow_specification_complete = nullptr,
74       .link.classic.on_flush_occurred = nullptr,
75       .link.classic.on_mode_change = btm_pm_on_mode_change,
76       .link.classic.on_packet_type_changed = nullptr,
77       .link.classic.on_qos_setup_complete = nullptr,
78       .link.classic.on_read_afh_channel_map_complete = nullptr,
79       .link.classic.on_read_automatic_flush_timeout_complete = nullptr,
80       .link.classic.on_sniff_subrating = btm_pm_on_sniff_subrating,
81       .link.classic.on_read_clock_complete = nullptr,
82       .link.classic.on_read_clock_offset_complete = nullptr,
83       .link.classic.on_read_failed_contact_counter_complete = nullptr,
84       .link.classic.on_read_link_policy_settings_complete = nullptr,
85       .link.classic.on_read_link_quality_complete = nullptr,
86       .link.classic.on_read_link_supervision_timeout_complete = nullptr,
87       .link.classic.on_read_remote_version_information_complete =
88           btm_read_remote_version_complete,
89       .link.classic.on_read_remote_supported_features_complete =
90           acl_process_supported_features,
91       .link.classic.on_read_remote_extended_features_complete =
92           acl_process_extended_features,
93       .link.classic.on_read_rssi_complete = nullptr,
94       .link.classic.on_read_transmit_power_level_complete = nullptr,
95       .link.classic.on_role_change = btm_acl_role_changed,
96       .link.classic.on_role_discovery_complete = nullptr,
97 
98       .link.le.on_connection_update = acl_ble_update_event_received,
99       .link.le.on_data_length_change = acl_ble_data_length_change_event,
100       .link.le.on_read_remote_version_information_complete =
101           btm_read_remote_version_complete,
102       .link.le.on_phy_update = gatt_notify_phy_updated,
103       .link.le.on_le_subrate_change = on_le_subrate_change,
104   };
105   return acl_interface;
106 }
107 
108 }  // namespace legacy
109 }  // namespace shim
110 }  // namespace bluetooth
111