1 #[cxx::bridge(namespace = bluetooth::topshim::rust)]
2 mod ffi {
3     unsafe extern "C++" {
4         include!("types/raw_address.h");
5         #[namespace = ""]
6         type RawAddress = crate::btif::RawAddress;
7     }
8 
9     unsafe extern "C++" {
10         include!("controller/controller_shim.h");
11 
12         type ControllerIntf;
13 
GetControllerInterface() -> UniquePtr<ControllerIntf>14         fn GetControllerInterface() -> UniquePtr<ControllerIntf>;
read_local_addr(self: &ControllerIntf) -> RawAddress15         fn read_local_addr(self: &ControllerIntf) -> RawAddress;
get_ble_supported_states(self: &ControllerIntf) -> u6416         fn get_ble_supported_states(self: &ControllerIntf) -> u64;
get_ble_local_supported_features(self: &ControllerIntf) -> u6417         fn get_ble_local_supported_features(self: &ControllerIntf) -> u64;
18     }
19 }
20 
21 pub struct Controller {
22     internal: cxx::UniquePtr<ffi::ControllerIntf>,
23 }
24 
25 unsafe impl Send for Controller {}
26 
27 impl Controller {
new() -> Controller28     pub fn new() -> Controller {
29         let intf = ffi::GetControllerInterface();
30         Controller { internal: intf }
31     }
32 
read_local_addr(&mut self) -> [u8; 6]33     pub fn read_local_addr(&mut self) -> [u8; 6] {
34         self.internal.read_local_addr().address
35     }
36 
get_ble_supported_states(&mut self) -> u6437     pub fn get_ble_supported_states(&mut self) -> u64 {
38         self.internal.get_ble_supported_states()
39     }
40 
get_ble_local_supported_features(&mut self) -> u6441     pub fn get_ble_local_supported_features(&mut self) -> u64 {
42         self.internal.get_ble_local_supported_features()
43     }
44 }
45