Skip to content

Commit

Permalink
Merge pull request #67 from blueluna/byte-upgrade
Browse files Browse the repository at this point in the history
Upgrade byte
  • Loading branch information
ryankurte authored Feb 13, 2024
2 parents 52115ef + e997fdb commit c57fb7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ keywords = ["WPAN"]
[dependencies]
hash32 = "0.2.1"
hash32-derive = "0.1"
byte = "0.2.4"
byte = "0.2.7"
defmt = { version = ">=0.2.0,<0.4", optional = true }

[dependencies.ccm]
Expand Down
20 changes: 19 additions & 1 deletion src/mac/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ impl<'a> TryRead<'a, FooterMode> for Frame<'a> {
if header.has_security() {
return Err(DecodeError::SecurityEnabled)?;
}

let (payload, footer) = match mode {
FooterMode::None => (
bytes.read_with(offset, Bytes::Len(bytes.len() - *offset))?,
Expand Down Expand Up @@ -561,6 +560,24 @@ mod tests {
Address, ExtendedAddress, FrameVersion, PanId, ShortAddress,
};

#[test]
fn decode_ver0_ack() {
let data = [0x02, 0x00, 0x04];

let frame: Frame = data.read_with(&mut 0, FooterMode::None).unwrap();
let hdr = frame.header;
assert_eq!(hdr.frame_type, FrameType::Acknowledgement);
assert_eq!(hdr.has_security(), false);
assert_eq!(hdr.frame_pending, false);
assert_eq!(hdr.ack_request, false);
assert_eq!(hdr.pan_id_compress, false);
assert_eq!(hdr.version, FrameVersion::Ieee802154_2003);
assert_eq!(frame.header.destination, None);
assert_eq!(frame.header.source, None);
assert_eq!(frame.header.seq, 4);
assert_eq!(frame.payload.len(), 0);
}

#[test]
fn decode_ver0_pan_id_compression() {
let data = [
Expand Down Expand Up @@ -624,6 +641,7 @@ mod tests {
))
);
assert_eq!(frame.header.seq, 139);
assert_eq!(frame.payload.len(), 3);
}

#[test]
Expand Down

0 comments on commit c57fb7e

Please sign in to comment.