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