Skip to content

Commit abaf2ae

Browse files
committed
adding 2015 support
1 parent 817ad8e commit abaf2ae

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/mac/frame.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ pub struct Header {
241241
/// PAN ID Compress
242242
pub pan_id_compress: bool,
243243

244+
/// Suppress sequence number
245+
pub seq_no_suppress: bool,
246+
247+
/// Information element present
248+
pub ie_present: bool,
249+
244250
/// Frame version
245251
pub version: FrameVersion,
246252

@@ -325,6 +331,8 @@ impl Header {
325331
let frame_pending = (buf[0] >> 4) & 0x1;
326332
let ack_request = (buf[0] >> 5) & 0x1;
327333
let pan_id_compress = (buf[0] >> 6) & 0x1;
334+
let seq_no_suppress = (buf[1] & 0x1) != 0;
335+
let ie_present = (buf[1] & 0x2) != 0;
328336
let dest_addr_mode = (buf[1] >> 2) & 0x3;
329337
let frame_version = (buf[1] >> 4) & 0x3;
330338
let source_addr_mode = (buf[1] >> 6) & 0x3;
@@ -339,7 +347,7 @@ impl Header {
339347
let dest_addr_mode = AddressMode::from_bits(dest_addr_mode)?;
340348
let source_addr_mode = AddressMode::from_bits(source_addr_mode)?;
341349

342-
if frame_version > 0b01 {
350+
if frame_version > FrameVersion::Ieee802154 as u8 {
343351
return Err(DecodeError::InvalidFrameVersion(frame_version));
344352
}
345353
let version = FrameVersion::from_bits(frame_version)
@@ -374,6 +382,8 @@ impl Header {
374382
frame_pending,
375383
ack_request,
376384
pan_id_compress,
385+
ie_present,
386+
seq_no_suppress,
377387
version,
378388
destination,
379389
source,
@@ -487,6 +497,15 @@ pub enum FrameType {
487497

488498
/// MAC command
489499
MacCommand = 0b011,
500+
501+
/// Multipurpose
502+
Multipurpose = 0b101,
503+
504+
/// Fragment of Fragment Ack
505+
FragOrFragAck = 0b110,
506+
507+
/// Extended
508+
Extended = 0b111,
490509
}
491510

492511
impl FrameType {
@@ -974,7 +993,9 @@ impl FrameContent {
974993
FrameType::MacCommand => {
975994
let (command, used) = Command::decode(buf)?;
976995
Ok((FrameContent::Command(command), used))
977-
}
996+
},
997+
// TODO: implement 802.15.4-2015 frame types
998+
_ => unimplemented!(),
978999
}
9791000
}
9801001
/// Encode frame content into byte buffer

0 commit comments

Comments
 (0)