diff --git a/Cargo.toml b/Cargo.toml index 534ccff..6b159d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/mac/frame/mod.rs b/src/mac/frame/mod.rs index bd2ae9d..e290f8c 100644 --- a/src/mac/frame/mod.rs +++ b/src/mac/frame/mod.rs @@ -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))?, @@ -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 = [ @@ -624,6 +641,7 @@ mod tests { )) ); assert_eq!(frame.header.seq, 139); + assert_eq!(frame.payload.len(), 3); } #[test]