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/sec_hci_link_interface.h"
22 
23 struct tBTM_ESCO_DATA;
24 void gatt_notify_phy_updated(tHCI_STATUS status, uint16_t handle,
25                              uint8_t tx_phy, uint8_t rx_phy);
26 void gatt_notify_subrate_change(uint16_t handle, uint16_t subrate_factor,
27                                 uint16_t latency, uint16_t cont_num,
28                                 uint16_t timeout, uint8_t status);
29 void l2cble_process_subrate_change_evt(uint16_t handle, uint8_t status,
30                                        uint16_t subrate_factor,
31                                        uint16_t peripheral_latency,
32                                        uint16_t cont_num, uint16_t timeout);
33 
on_le_subrate_change(uint16_t handle,uint16_t subrate_factor,uint16_t latency,uint16_t cont_num,uint16_t timeout,uint8_t status)34 static void on_le_subrate_change(uint16_t handle, uint16_t subrate_factor,
35                                  uint16_t latency, uint16_t cont_num,
36                                  uint16_t timeout, uint8_t status) {
37   l2cble_process_subrate_change_evt(handle, status, subrate_factor, latency,
38                                     cont_num, timeout);
39   gatt_notify_subrate_change(handle & 0x0FFF, subrate_factor, latency, cont_num,
40                              timeout, status);
41 }
42 
43 namespace bluetooth {
44 namespace shim {
45 namespace legacy {
46 
GetAclInterface()47 const acl_interface_t& GetAclInterface() {
48   static acl_interface_t acl_interface{
49       .on_send_data_upwards = acl_rcv_acl_data,
50       .on_packets_completed = acl_packets_completed,
51 
52       .connection.classic.on_connected = on_acl_br_edr_connected,
53       .connection.classic.on_connect_request = btm_connection_request,
54       .connection.classic.on_failed = on_acl_br_edr_failed,
55       .connection.classic.on_disconnected = btm_acl_disconnected,
56 
57       .connection.le.on_connected =
58           acl_ble_enhanced_connection_complete_from_shim,
59       .connection.le.on_failed = acl_ble_connection_fail,
60       .connection.le.on_disconnected = btm_acl_disconnected,
61 
62       .link.classic.on_authentication_complete = btm_sec_auth_complete,
63       .link.classic.on_central_link_key_complete = nullptr,
64       .link.classic.on_change_connection_link_key_complete = nullptr,
65       .link.classic.on_encryption_change = nullptr,
66       .link.classic.on_flow_specification_complete = nullptr,
67       .link.classic.on_flush_occurred = nullptr,
68       .link.classic.on_mode_change = btm_pm_on_mode_change,
69       .link.classic.on_packet_type_changed = nullptr,
70       .link.classic.on_qos_setup_complete = nullptr,
71       .link.classic.on_read_afh_channel_map_complete = nullptr,
72       .link.classic.on_read_automatic_flush_timeout_complete = nullptr,
73       .link.classic.on_sniff_subrating = btm_pm_on_sniff_subrating,
74       .link.classic.on_read_clock_complete = nullptr,
75       .link.classic.on_read_clock_offset_complete = nullptr,
76       .link.classic.on_read_failed_contact_counter_complete = nullptr,
77       .link.classic.on_read_link_policy_settings_complete = nullptr,
78       .link.classic.on_read_link_quality_complete = nullptr,
79       .link.classic.on_read_link_supervision_timeout_complete = nullptr,
80       .link.classic.on_read_remote_version_information_complete =
81           btm_read_remote_version_complete,
82       .link.classic.on_read_remote_supported_features_complete =
83           acl_process_supported_features,
84       .link.classic.on_read_remote_extended_features_complete =
85           acl_process_extended_features,
86       .link.classic.on_read_rssi_complete = nullptr,
87       .link.classic.on_read_transmit_power_level_complete = nullptr,
88       .link.classic.on_role_change = btm_acl_role_changed,
89       .link.classic.on_role_discovery_complete = nullptr,
90 
91       .link.le.on_connection_update = acl_ble_update_event_received,
92       .link.le.on_data_length_change = acl_ble_data_length_change_event,
93       .link.le.on_read_remote_version_information_complete =
94           btm_read_remote_version_complete,
95       .link.le.on_phy_update = gatt_notify_phy_updated,
96       .link.le.on_le_subrate_change = on_le_subrate_change,
97   };
98   return acl_interface;
99 }
100 
101 }  // namespace legacy
102 }  // namespace shim
103 }  // namespace bluetooth
104