• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(clippy::all)]
2 #![allow(unused)]
3 #![allow(missing_docs)]
4 
5 pub mod l2cap {
6     include!(concat!(env!("OUT_DIR"), "/l2cap_packets.rs"));
7 }
8 
9 pub mod hci {
10     include!(concat!(env!("OUT_DIR"), "/hci_packets.rs"));
11 
12     pub const EMPTY_ADDRESS: Address = Address(0x000000000000);
13 
14     impl fmt::Display for Address {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result15         fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16             let bytes = u64::to_le_bytes(self.0);
17             write!(
18                 f,
19                 "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}",
20                 bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0],
21             )
22         }
23     }
24 
25     impl From<&[u8; 6]> for Address {
from(bytes: &[u8; 6]) -> Self26         fn from(bytes: &[u8; 6]) -> Self {
27             Self(u64::from_le_bytes([
28                 bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], 0, 0,
29             ]))
30         }
31     }
32 
33     impl From<Address> for [u8; 6] {
from(Address(addr): Address) -> Self34         fn from(Address(addr): Address) -> Self {
35             let bytes = u64::to_le_bytes(addr);
36             bytes[0..6].try_into().unwrap()
37         }
38     }
39 }
40