• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[cxx::bridge(namespace = bluetooth::topshim::rust)]
2 mod ffi {
3     unsafe extern "C++" {
4         include!("gd/rust/topshim/common/type_alias.h");
5         type RawAddress = crate::btif::RawAddress;
6     }
7 
8     unsafe extern "C++" {
9         include!("controller/controller_shim.h");
10 
11         type ControllerIntf;
12 
GetControllerInterface() -> UniquePtr<ControllerIntf>13         fn GetControllerInterface() -> UniquePtr<ControllerIntf>;
read_local_addr(self: &ControllerIntf) -> RawAddress14         fn read_local_addr(self: &ControllerIntf) -> RawAddress;
15     }
16 }
17 
18 pub struct Controller {
19     internal: cxx::UniquePtr<ffi::ControllerIntf>,
20 }
21 
22 unsafe impl Send for Controller {}
23 
24 impl Controller {
new() -> Controller25     pub fn new() -> Controller {
26         let intf = ffi::GetControllerInterface();
27         Controller { internal: intf }
28     }
29 
read_local_addr(&mut self) -> [u8; 6]30     pub fn read_local_addr(&mut self) -> [u8; 6] {
31         self.internal.read_local_addr().address
32     }
33 }
34