1 use crate::btif::{
2 BtAclState, BtBondState, BtConnectionDirection, BtDeviceType, BtHciErrorCode, BtState,
3 BtStatus, BtTransport, RawAddress,
4 };
5
6 #[cxx::bridge(namespace = bluetooth::topshim::rust)]
7 mod ffi {
8 unsafe extern "C++" {
9 include!("types/raw_address.h");
10 #[namespace = ""]
11 type RawAddress = crate::btif::RawAddress;
12 }
13
14 unsafe extern "C++" {
15 include!("metrics/metrics_shim.h");
16
adapter_state_changed(state: u32)17 fn adapter_state_changed(state: u32);
bond_create_attempt(bt_addr: RawAddress, device_type: u32)18 fn bond_create_attempt(bt_addr: RawAddress, device_type: u32);
bond_state_changed( bt_addr: RawAddress, device_type: u32, status: u32, bond_state: u32, fail_reason: i32, )19 fn bond_state_changed(
20 bt_addr: RawAddress,
21 device_type: u32,
22 status: u32,
23 bond_state: u32,
24 fail_reason: i32,
25 );
device_info_report( bt_addr: RawAddress, device_type: u32, class_of_device: u32, appearance: u32, vendor_id: u32, vendor_id_src: u32, product_id: u32, version: u32, )26 fn device_info_report(
27 bt_addr: RawAddress,
28 device_type: u32,
29 class_of_device: u32,
30 appearance: u32,
31 vendor_id: u32,
32 vendor_id_src: u32,
33 product_id: u32,
34 version: u32,
35 );
profile_connection_state_changed( bt_addr: RawAddress, profile: u32, status: u32, state: u32, )36 fn profile_connection_state_changed(
37 bt_addr: RawAddress,
38 profile: u32,
39 status: u32,
40 state: u32,
41 );
acl_connect_attempt(addr: RawAddress, acl_state: u32)42 fn acl_connect_attempt(addr: RawAddress, acl_state: u32);
acl_connection_state_changed( bt_addr: RawAddress, transport: u32, status: u32, acl_state: u32, direction: u32, hci_reason: u32, )43 fn acl_connection_state_changed(
44 bt_addr: RawAddress,
45 transport: u32,
46 status: u32,
47 acl_state: u32,
48 direction: u32,
49 hci_reason: u32,
50 );
suspend_complete_state(state: u32)51 fn suspend_complete_state(state: u32);
52 }
53 }
54
adapter_state_changed(state: BtState)55 pub fn adapter_state_changed(state: BtState) {
56 ffi::adapter_state_changed(state as u32);
57 }
58
bond_create_attempt(addr: RawAddress, device_type: BtDeviceType)59 pub fn bond_create_attempt(addr: RawAddress, device_type: BtDeviceType) {
60 ffi::bond_create_attempt(addr, device_type as u32);
61 }
62
bond_state_changed( addr: RawAddress, device_type: BtDeviceType, status: BtStatus, bond_state: BtBondState, fail_reason: i32, )63 pub fn bond_state_changed(
64 addr: RawAddress,
65 device_type: BtDeviceType,
66 status: BtStatus,
67 bond_state: BtBondState,
68 fail_reason: i32,
69 ) {
70 ffi::bond_state_changed(
71 addr,
72 device_type as u32,
73 status as u32,
74 bond_state as u32,
75 fail_reason as i32,
76 );
77 }
78
device_info_report( addr: RawAddress, device_type: BtDeviceType, class_of_device: u32, appearance: u16, vendor_id: u16, vendor_id_src: u8, product_id: u16, version: u16, )79 pub fn device_info_report(
80 addr: RawAddress,
81 device_type: BtDeviceType,
82 class_of_device: u32,
83 appearance: u16,
84 vendor_id: u16,
85 vendor_id_src: u8,
86 product_id: u16,
87 version: u16,
88 ) {
89 ffi::device_info_report(
90 addr,
91 device_type as u32,
92 class_of_device as u32,
93 appearance as u32,
94 vendor_id as u32,
95 vendor_id_src as u32,
96 product_id as u32,
97 version as u32,
98 );
99 }
100
profile_connection_state_changed( addr: RawAddress, profile: u32, status: BtStatus, state: u32, )101 pub fn profile_connection_state_changed(
102 addr: RawAddress,
103 profile: u32,
104 status: BtStatus,
105 state: u32,
106 ) {
107 ffi::profile_connection_state_changed(addr, profile, status as u32, state);
108 }
109
acl_connect_attempt(addr: RawAddress, acl_state: BtAclState)110 pub fn acl_connect_attempt(addr: RawAddress, acl_state: BtAclState) {
111 ffi::acl_connect_attempt(addr, acl_state as u32);
112 }
113
acl_connection_state_changed( addr: RawAddress, transport: BtTransport, status: BtStatus, acl_state: BtAclState, direction: BtConnectionDirection, hci_reason: BtHciErrorCode, )114 pub fn acl_connection_state_changed(
115 addr: RawAddress,
116 transport: BtTransport,
117 status: BtStatus,
118 acl_state: BtAclState,
119 direction: BtConnectionDirection,
120 hci_reason: BtHciErrorCode,
121 ) {
122 ffi::acl_connection_state_changed(
123 addr,
124 transport as u32,
125 status as u32,
126 acl_state as u32,
127 direction as u32,
128 hci_reason as u32,
129 );
130 }
131
suspend_complete_state(state: u32)132 pub fn suspend_complete_state(state: u32) {
133 ffi::suspend_complete_state(state);
134 }
135