1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use std::ffi::CString;
use std::fmt::{Display, Formatter};
use bytes::Bytes;
use enumflags2::BitFlags;
use crate::interface::class::{DeviceClass, ServiceClasses};
use crate::Address;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct Controller(pub(crate) u16);
impl Display for Controller {
fn fmt(&self, f: &mut Formatter) -> Result<(), ::std::fmt::Error> {
write!(f, "hci{}", self.0)
}
}
impl Into<u16> for Controller {
fn into(self) -> u16 {
return self.0;
}
}
impl Controller {
pub fn none() -> Controller {
Controller(0xFFFF)
}
}
#[derive(Debug)]
pub struct ControllerInfo {
pub address: Address,
pub bluetooth_version: u8,
pub manufacturer: u16,
pub supported_settings: ControllerSettings,
pub current_settings: ControllerSettings,
pub class_of_device: (DeviceClass, ServiceClasses),
pub name: CString,
pub short_name: CString,
}
pub struct ControllerInfoExt {
pub address: Address,
pub bluetooth_version: u8,
pub manufacturer: u16,
pub supported_settings: ControllerSettings,
pub current_settings: ControllerSettings,
pub eir_data: Bytes,
}
#[derive(BitFlags, Copy, Clone, Debug, PartialEq)]
#[repr(u32)]
pub enum ControllerSetting {
Powered = 1 << 0,
Connectable = 1 << 1,
FastConnectable = 1 << 2,
Discoverable = 1 << 3,
Pairable = 1 << 4,
LinkLevelSecurity = 1 << 5,
SecureSimplePairing = 1 << 6,
BREDR = 1 << 7,
HighSpeed = 1 << 8,
LE = 1 << 9,
Advertising = 1 << 10,
SecureConnection = 1 << 11,
DebugKeys = 1 << 12,
Privacy = 1 << 13,
Configuration = 1 << 14,
StaticAddress = 1 << 15,
}
pub type ControllerSettings = BitFlags<ControllerSetting>;