Loading floss/hcidoc/Cargo.toml +0 −1 Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" edition = "2021" [dependencies] [dependencies] bt_packets = { path = "../../system/gd/rust/packets" } hcidoc_packets = { path = "packets" } hcidoc_packets = { path = "packets" } clap = "4.0" clap = "4.0" chrono = "0.4" chrono = "0.4" Loading floss/hcidoc/packets/build.rs +18 −0 Original line number Original line Diff line number Diff line Loading @@ -42,4 +42,22 @@ fn generate_packets() { output.status, output.status, String::from_utf8_lossy(output.stderr.as_slice()) String::from_utf8_lossy(output.stderr.as_slice()) ); ); let out_file = File::create(out_dir.join("hci_packets.rs")).unwrap(); let in_file = PathBuf::from("../../../system/pdl/hci/hci_packets.pdl"); println!("cargo:rerun-if-changed={}", in_file.display()); let output = Command::new("pdlc") .arg("--output-format") .arg("rust") .arg(in_file) .stdout(Stdio::from(out_file)) .output() .unwrap(); println!( "Status: {}, stderr: {}", output.status, String::from_utf8_lossy(output.stderr.as_slice()) ); } } floss/hcidoc/packets/lib.rs +32 −0 Original line number Original line Diff line number Diff line Loading @@ -5,3 +5,35 @@ pub mod l2cap { pub mod l2cap { include!(concat!(env!("OUT_DIR"), "/l2cap_packets.rs")); include!(concat!(env!("OUT_DIR"), "/l2cap_packets.rs")); } } pub mod hci { include!(concat!(env!("OUT_DIR"), "/hci_packets.rs")); pub const EMPTY_ADDRESS: Address = Address(0x000000000000); impl fmt::Display for Address { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bytes = u64::to_le_bytes(self.0); write!( f, "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}", bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0], ) } } impl From<&[u8; 6]> for Address { fn from(bytes: &[u8; 6]) -> Self { Self(u64::from_le_bytes([ bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], 0, 0, ])) } } impl From<Address> for [u8; 6] { fn from(Address(addr): Address) -> Self { let bytes = u64::to_le_bytes(addr); bytes[0..6].try_into().unwrap() } } } floss/hcidoc/src/groups/collisions.rs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,7 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use crate::parser::{Packet, PacketChild}; use bt_packets::hci::{ErrorCode, EventChild, OpCode}; use hcidoc_packets::hci::{ErrorCode, EventChild, OpCode}; enum CollisionSignal { enum CollisionSignal { RnrAndInquiry, RnrAndInquiry, Loading floss/hcidoc/src/groups/connections.rs +3 −2 Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ use std::slice::Iter; use crate::engine::{Rule, RuleGroup, Signal}; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use crate::parser::{Packet, PacketChild}; use bt_packets::hci::{ use hcidoc_packets::hci::{ Acl, AclCommandChild, Address, AuthenticatedPayloadTimeoutExpired, CommandChild, Acl, AclCommandChild, Address, AuthenticatedPayloadTimeoutExpired, CommandChild, ConnectionManagementCommandChild, DisconnectReason, Enable, ErrorCode, EventChild, ConnectionManagementCommandChild, DisconnectReason, Enable, ErrorCode, EventChild, InitiatorFilterPolicy, LeConnectionManagementCommandChild, LeMetaEventChild, InitiatorFilterPolicy, LeConnectionManagementCommandChild, LeMetaEventChild, Loading Loading @@ -483,7 +483,8 @@ impl OddDisconnectionsRule { let use_accept_list = self let use_accept_list = self .last_le_connection_filter_policy .last_le_connection_filter_policy .map_or(false, |policy| policy == InitiatorFilterPolicy::UseFilterAcceptList); .map_or(false, |policy| policy == InitiatorFilterPolicy::UseFilterAcceptList); let addr_to_remove = if use_accept_list { bt_packets::hci::EMPTY_ADDRESS } else { address }; let addr_to_remove = if use_accept_list { hcidoc_packets::hci::EMPTY_ADDRESS } else { address }; if let Some(_) = self.le_connection_attempt.remove(&addr_to_remove) { if let Some(_) = self.le_connection_attempt.remove(&addr_to_remove) { if status == ErrorCode::Success { if status == ErrorCode::Success { Loading Loading
floss/hcidoc/Cargo.toml +0 −1 Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" edition = "2021" [dependencies] [dependencies] bt_packets = { path = "../../system/gd/rust/packets" } hcidoc_packets = { path = "packets" } hcidoc_packets = { path = "packets" } clap = "4.0" clap = "4.0" chrono = "0.4" chrono = "0.4" Loading
floss/hcidoc/packets/build.rs +18 −0 Original line number Original line Diff line number Diff line Loading @@ -42,4 +42,22 @@ fn generate_packets() { output.status, output.status, String::from_utf8_lossy(output.stderr.as_slice()) String::from_utf8_lossy(output.stderr.as_slice()) ); ); let out_file = File::create(out_dir.join("hci_packets.rs")).unwrap(); let in_file = PathBuf::from("../../../system/pdl/hci/hci_packets.pdl"); println!("cargo:rerun-if-changed={}", in_file.display()); let output = Command::new("pdlc") .arg("--output-format") .arg("rust") .arg(in_file) .stdout(Stdio::from(out_file)) .output() .unwrap(); println!( "Status: {}, stderr: {}", output.status, String::from_utf8_lossy(output.stderr.as_slice()) ); } }
floss/hcidoc/packets/lib.rs +32 −0 Original line number Original line Diff line number Diff line Loading @@ -5,3 +5,35 @@ pub mod l2cap { pub mod l2cap { include!(concat!(env!("OUT_DIR"), "/l2cap_packets.rs")); include!(concat!(env!("OUT_DIR"), "/l2cap_packets.rs")); } } pub mod hci { include!(concat!(env!("OUT_DIR"), "/hci_packets.rs")); pub const EMPTY_ADDRESS: Address = Address(0x000000000000); impl fmt::Display for Address { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bytes = u64::to_le_bytes(self.0); write!( f, "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}", bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0], ) } } impl From<&[u8; 6]> for Address { fn from(bytes: &[u8; 6]) -> Self { Self(u64::from_le_bytes([ bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], 0, 0, ])) } } impl From<Address> for [u8; 6] { fn from(Address(addr): Address) -> Self { let bytes = u64::to_le_bytes(addr); bytes[0..6].try_into().unwrap() } } }
floss/hcidoc/src/groups/collisions.rs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -5,7 +5,7 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use crate::parser::{Packet, PacketChild}; use bt_packets::hci::{ErrorCode, EventChild, OpCode}; use hcidoc_packets::hci::{ErrorCode, EventChild, OpCode}; enum CollisionSignal { enum CollisionSignal { RnrAndInquiry, RnrAndInquiry, Loading
floss/hcidoc/src/groups/connections.rs +3 −2 Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ use std::slice::Iter; use crate::engine::{Rule, RuleGroup, Signal}; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use crate::parser::{Packet, PacketChild}; use bt_packets::hci::{ use hcidoc_packets::hci::{ Acl, AclCommandChild, Address, AuthenticatedPayloadTimeoutExpired, CommandChild, Acl, AclCommandChild, Address, AuthenticatedPayloadTimeoutExpired, CommandChild, ConnectionManagementCommandChild, DisconnectReason, Enable, ErrorCode, EventChild, ConnectionManagementCommandChild, DisconnectReason, Enable, ErrorCode, EventChild, InitiatorFilterPolicy, LeConnectionManagementCommandChild, LeMetaEventChild, InitiatorFilterPolicy, LeConnectionManagementCommandChild, LeMetaEventChild, Loading Loading @@ -483,7 +483,8 @@ impl OddDisconnectionsRule { let use_accept_list = self let use_accept_list = self .last_le_connection_filter_policy .last_le_connection_filter_policy .map_or(false, |policy| policy == InitiatorFilterPolicy::UseFilterAcceptList); .map_or(false, |policy| policy == InitiatorFilterPolicy::UseFilterAcceptList); let addr_to_remove = if use_accept_list { bt_packets::hci::EMPTY_ADDRESS } else { address }; let addr_to_remove = if use_accept_list { hcidoc_packets::hci::EMPTY_ADDRESS } else { address }; if let Some(_) = self.le_connection_attempt.remove(&addr_to_remove) { if let Some(_) = self.le_connection_attempt.remove(&addr_to_remove) { if status == ErrorCode::Success { if status == ErrorCode::Success { Loading