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