• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Bluetooth common library
2 #[macro_use]
3 extern crate lazy_static;
4 
5 /// Provides waking timer abstractions
6 pub mod time;
7 
8 #[macro_use]
9 mod ready;
10 
11 #[cfg(test)]
12 #[macro_use]
13 mod asserts;
14 
15 /// Provides runtime configured-at-startup flags
16 pub mod init_flags;
17 
18 /// Provides runtime configured system properties. Stubbed for non-Android.
19 pub mod sys_prop;
20 
21 /// Inits logging for Android
22 #[cfg(target_os = "android")]
init_logging()23 pub fn init_logging() {
24     android_logger::init_once(
25         android_logger::Config::default().with_tag("bt").with_min_level(log::Level::Debug),
26     );
27 }
28 
29 /// Inits logging for host
30 #[cfg(not(target_os = "android"))]
init_logging()31 pub fn init_logging() {
32     env_logger::Builder::new()
33         .filter(None, log::LevelFilter::Debug)
34         .parse_default_env()
35         .try_init()
36         .ok();
37 }
38 
39 /// Indicates the object can be converted to a GRPC service
40 pub trait GrpcFacade {
41     /// Convert the object into the service
into_grpc(self) -> grpcio::Service42     fn into_grpc(self) -> grpcio::Service;
43 }
44 
45 /// Useful for distinguishing between BT classic & LE in functions that support both
46 #[derive(Debug, Clone, Copy)]
47 pub enum Bluetooth {
48     /// Classic BT we all know and love, started in the 90s.
49     Classic,
50     /// Bluetooth low energy from the 2010s. Also known as BLE, BTLE, etc.
51     Le,
52 }
53