final structs
unchecked
This commit is contained in:
parent
3f0c8bafb0
commit
68792bb918
@ -96,12 +96,31 @@ pub struct BeaconNotifyIndication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ParseableMacEvent for BeaconNotifyIndication {
|
impl ParseableMacEvent for BeaconNotifyIndication {
|
||||||
const SIZE: usize = 12;
|
const SIZE: usize = 88;
|
||||||
|
|
||||||
fn try_parse(buf: &[u8]) -> Result<Self, ()> {
|
fn try_parse(buf: &[u8]) -> Result<Self, ()> {
|
||||||
|
// TODO: this is unchecked
|
||||||
|
|
||||||
Self::validate(buf)?;
|
Self::validate(buf)?;
|
||||||
|
|
||||||
todo!()
|
let addr_list = [
|
||||||
|
MacAddress::try_from(&buf[26..34])?,
|
||||||
|
MacAddress::try_from(&buf[34..42])?,
|
||||||
|
MacAddress::try_from(&buf[42..50])?,
|
||||||
|
MacAddress::try_from(&buf[50..58])?,
|
||||||
|
MacAddress::try_from(&buf[58..66])?,
|
||||||
|
MacAddress::try_from(&buf[66..74])?,
|
||||||
|
MacAddress::try_from(&buf[74..82])?,
|
||||||
|
];
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
sdu_ptr: to_u32(&buf[0..4]) as *const u8,
|
||||||
|
pan_descriptor: PanDescriptor::try_from(&buf[4..26])?,
|
||||||
|
addr_list,
|
||||||
|
bsn: buf[82],
|
||||||
|
pend_addr_spec: buf[83],
|
||||||
|
sdu_length: buf[83],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,12 +199,39 @@ pub struct ScanConfirm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ParseableMacEvent for ScanConfirm {
|
impl ParseableMacEvent for ScanConfirm {
|
||||||
const SIZE: usize = 9;
|
const SIZE: usize = 185;
|
||||||
|
|
||||||
fn try_parse(buf: &[u8]) -> Result<Self, ()> {
|
fn try_parse(buf: &[u8]) -> Result<Self, ()> {
|
||||||
|
// TODO: this is unchecked
|
||||||
|
|
||||||
Self::validate(buf)?;
|
Self::validate(buf)?;
|
||||||
|
|
||||||
todo!()
|
let mut energy_detect_list = [0; MAX_ED_SCAN_RESULTS_SUPPORTED];
|
||||||
|
energy_detect_list.copy_from_slice(&buf[8..24]);
|
||||||
|
|
||||||
|
let pan_descriptor_list = [
|
||||||
|
PanDescriptor::try_from(&buf[24..46])?,
|
||||||
|
PanDescriptor::try_from(&buf[46..68])?,
|
||||||
|
PanDescriptor::try_from(&buf[68..90])?,
|
||||||
|
PanDescriptor::try_from(&buf[90..102])?,
|
||||||
|
PanDescriptor::try_from(&buf[102..124])?,
|
||||||
|
PanDescriptor::try_from(&buf[124..146])?,
|
||||||
|
];
|
||||||
|
|
||||||
|
let mut uwb_energy_detect_list = [0; MAX_ED_SCAN_RESULTS_SUPPORTED];
|
||||||
|
uwb_energy_detect_list.copy_from_slice(&buf[147..163]);
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
status: MacStatus::try_from(buf[0])?,
|
||||||
|
scan_type: ScanType::try_from(buf[1])?,
|
||||||
|
channel_page: buf[2],
|
||||||
|
unscanned_channels: [buf[3], buf[4], buf[5], buf[6]],
|
||||||
|
result_list_size: buf[7],
|
||||||
|
energy_detect_list,
|
||||||
|
pan_descriptor_list,
|
||||||
|
detected_category: buf[146],
|
||||||
|
uwb_energy_detect_list,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,21 @@ impl MacAddress {
|
|||||||
pub const BROADCAST: Self = Self { short: [0xFF, 0xFF] };
|
pub const BROADCAST: Self = Self { short: [0xFF, 0xFF] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&[u8]> for MacAddress {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(buf: &[u8]) -> Result<Self, Self::Error> {
|
||||||
|
const SIZE: usize = 8;
|
||||||
|
if buf.len() < SIZE {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
extended: [buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub struct GtsCharacteristics {
|
pub struct GtsCharacteristics {
|
||||||
pub fields: u8,
|
pub fields: u8,
|
||||||
@ -171,7 +186,7 @@ impl TryFrom<&[u8]> for PanDescriptor {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(buf: &[u8]) -> Result<Self, Self::Error> {
|
fn try_from(buf: &[u8]) -> Result<Self, Self::Error> {
|
||||||
const SIZE: usize = 24;
|
const SIZE: usize = 22;
|
||||||
if buf.len() < SIZE {
|
if buf.len() < SIZE {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user