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 #pragma once 18 19 #include <cstdint> 20 21 #include "stack/include/bt_hdr.h" 22 #include "stack/include/bt_types.h" 23 #include "stack/include/gatt_api.h" 24 #include "stack/include/hci_error_code.h" 25 #include "stack/include/hci_mode.h" 26 #include "stack/include/hcidefs.h" 27 #include "types/ble_address_with_type.h" 28 #include "types/class_of_device.h" 29 #include "types/hci_role.h" 30 #include "types/raw_address.h" 31 32 namespace bluetooth { 33 namespace shim { 34 namespace legacy { 35 36 typedef struct { 37 void (*on_connected)(const RawAddress& bda, uint16_t handle, 38 uint8_t enc_mode); 39 void (*on_failed)(const RawAddress& bda, tHCI_STATUS status); 40 void (*on_disconnected)(tHCI_STATUS status, uint16_t handle, 41 tHCI_STATUS reason); 42 } acl_classic_connection_interface_t; 43 44 typedef struct { 45 void (*on_connected)(const tBLE_BD_ADDR& address_with_type, uint16_t handle, 46 tHCI_ROLE role, uint16_t conn_interval, 47 uint16_t conn_latency, uint16_t conn_timeout, 48 const RawAddress& local_rpa, const RawAddress& peer_rpa, 49 tBLE_ADDR_TYPE peer_addr_type); 50 void (*on_failed)(const tBLE_BD_ADDR& address_with_type, uint16_t handle, 51 bool enhanced, tHCI_STATUS status); 52 void (*on_disconnected)(tHCI_STATUS status, uint16_t handle, 53 tHCI_STATUS reason); 54 void (*on_iso_disconnected)(uint16_t handle, tHCI_STATUS reason); 55 } acl_le_connection_interface_t; 56 57 typedef struct { 58 void (*on_esco_connect_request)(const RawAddress&, 59 const types::ClassOfDevice&); 60 void (*on_sco_connect_request)(const RawAddress&, 61 const types::ClassOfDevice&); 62 void (*on_disconnected)(uint16_t handle, tHCI_REASON reason); 63 } acl_sco_connection_interface_t; 64 65 typedef struct { 66 void (*on_authentication_complete)(uint16_t handle, tHCI_STATUS status); 67 void (*on_change_connection_link_key_complete)(); 68 void (*on_encryption_change)(bool enabled); 69 void (*on_flow_specification_complete)(uint16_t flow_direction, 70 uint16_t service_type, 71 uint32_t token_rate, 72 uint32_t token_bucket_size, 73 uint32_t peak_bandwidth, 74 uint32_t access_latency); 75 void (*on_flush_occurred)(); 76 void (*on_central_link_key_complete)(uint8_t key_flag); 77 void (*on_mode_change)(tHCI_STATUS status, uint16_t handle, 78 tHCI_MODE current_mode, uint16_t interval); 79 void (*on_sniff_subrating)(tHCI_STATUS status, uint16_t handle, 80 uint16_t maximum_transmit_latency, 81 uint16_t maximum_receive_latency, 82 uint16_t minimum_remote_timeout, 83 uint16_t minimum_local_timeout); 84 void (*on_packet_type_changed)(uint16_t packet_type); 85 void (*on_qos_setup_complete)(uint16_t service_type, uint32_t token_rate, 86 uint32_t peak_bandwidth, uint32_t latency, 87 uint32_t delay_variation); 88 void (*on_read_afh_channel_map_complete)(uint8_t afh_mode, 89 uint8_t afh_channel_map[]); 90 void (*on_read_automatic_flush_timeout_complete)(uint16_t flush_timeout); 91 void (*on_read_clock_complete)(uint32_t clock, uint16_t accuracy); 92 void (*on_read_clock_offset_complete)(uint16_t clock_offset); 93 void (*on_read_failed_contact_counter_complete)( 94 uint16_t failed_contact_counter); 95 void (*on_read_link_policy_settings_complete)(uint16_t link_policy_settings); 96 void (*on_read_link_quality_complete)(uint8_t link_quality); 97 void (*on_read_link_supervision_timeout_complete)( 98 uint16_t link_supervision_timeout); 99 void (*on_read_remote_supported_features_complete)(uint16_t handle, 100 uint64_t features); 101 void (*on_read_remote_extended_features_complete)(uint16_t handle, 102 uint8_t current_page_number, 103 uint8_t max_page_number, 104 uint64_t features); 105 void (*on_read_remote_version_information_complete)( 106 tHCI_STATUS status, uint16_t handle, uint8_t lmp_version, 107 uint16_t manufacturer_name, uint16_t sub_version); 108 void (*on_read_rssi_complete)(uint8_t rssi); 109 void (*on_read_transmit_power_level_complete)(uint8_t transmit_power_level); 110 void (*on_role_change)(tHCI_STATUS status, const RawAddress& bd_addr, 111 tHCI_ROLE new_role); 112 void (*on_role_discovery_complete)(tHCI_ROLE current_role); 113 } acl_classic_link_interface_t; 114 115 typedef struct { 116 void (*on_connection_update)(tHCI_STATUS status, uint16_t handle, 117 uint16_t connection_interval, 118 uint16_t connection_latency, 119 uint16_t supervision_timeout); 120 void (*on_data_length_change)(uint16_t handle, uint16_t max_tx_octets, 121 uint16_t max_tx_time, uint16_t max_rx_octets, 122 uint16_t max_rx_time); 123 void (*on_read_remote_version_information_complete)( 124 tHCI_STATUS status, uint16_t handle, uint8_t lmp_version, 125 uint16_t manufacturer_name, uint16_t sub_version); 126 void (*on_phy_update)(tGATT_STATUS status, uint16_t handle, uint8_t tx_phy, 127 uint8_t rx_phy); 128 } acl_le_link_interface_t; 129 130 typedef struct { 131 acl_classic_connection_interface_t classic; 132 acl_le_connection_interface_t le; 133 acl_sco_connection_interface_t sco; 134 } acl_connection_interface_t; 135 136 typedef struct { 137 acl_classic_link_interface_t classic; 138 acl_le_link_interface_t le; 139 } acl_link_interface_t; 140 141 typedef struct { 142 void (*on_send_data_upwards)(BT_HDR*); 143 void (*on_packets_completed)(uint16_t handle, uint16_t num_packets); 144 acl_connection_interface_t connection; 145 acl_link_interface_t link; 146 } acl_interface_t; 147 148 const acl_interface_t GetAclInterface(); 149 150 } // namespace legacy 151 } // namespace shim 152 } // namespace bluetooth 153