Skip to content

Commit

Permalink
Merge pull request #34 from jeremydub/enhance-support-tsch-ies
Browse files Browse the repository at this point in the history
Enhance support for TSCH IEs
  • Loading branch information
thvdveld authored Jan 20, 2025
2 parents 7724693 + b17bbf6 commit 6017125
Show file tree
Hide file tree
Showing 5 changed files with 515 additions and 72 deletions.
22 changes: 22 additions & 0 deletions dot15d4-cat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ impl FrameParser {
NestedSubId::Short(NestedSubIdShort::TschTimeslot) => {
if let Ok(timeslot) = TschTimeslot::new(nested.content()) {
w.writeln(format!("{timeslot}"));
if timeslot.has_timeslot_timings() {
w.write(format!(
"{:indent$}",
timeslot.timeslot_timings(),
indent = w.indent
));
}
} else {
w.writeln("invalid".to_string());
}
Expand All @@ -272,6 +279,21 @@ impl FrameParser {
TschSlotframeAndLink::new(nested.content())
{
w.writeln(format!("{slotframe_and_link}"));
for slotframe_descriptor in
slotframe_and_link.slotframe_descriptors()
{
w.writeln(format!(
"{}",
format!("{slotframe_descriptor}").italic()
));
w.increase_indent();
for link_information in
slotframe_descriptor.link_informations()
{
w.writeln(format!("{link_information}"));
}
w.decrease_indent();
}
} else {
w.writeln("invalid".to_string());
}
Expand Down
53 changes: 53 additions & 0 deletions dot15d4-cat/tests/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,59 @@ Information Elements
);
}

#[test]
fn enhanced_beacon_with_slotframes() {
let input = "40ebcdabffff0100010001000100003f3788061a110000000000191c01080780004808fc032003e80398089001c0006009a010102701c8000f1b010011000200000100060100020007";
let output = String::from_utf8(strip(FrameParser::parse_hex(input).unwrap())).unwrap();
assert_eq!(
output,
"Frame Control
frame type: Enhanced Beacon
security: 0
frame pending: 0
ack request: 0
pan id compression: 1
sequence number suppression: 1
information elements present: 1
dst addressing mode: Short
src addressing mode: Extended
frame version: 2 (Ieee802154_2020)
Addressing
dst pan id: abcd
dst addr: ff:ff (broadcast)
src addr: 00:01:00:01:00:01:00:01
Information Elements
Header Information Elements
HeaderTermination1
Payload Information Elements
MLME
TschSynchronization
ASN: 17, join metric: 0
TschTimeslot
slot ID: 1
cca_offset: 1.80ms
cca: 0.13ms
tx offset: 2.12ms
rx offset: 1.02ms
tx ack delay: 1.00ms
rx ack delay: 0.80ms
rx wait: 2.20ms
ack wait: 0.40ms
rx/tx: 0.19ms
max ack: 2.40ms
max tx: 4.26ms
timeslot length: 10.00ms
ChannelHopping
sequence ID: 0
TschSlotframeAndLink
#slotframes: 1
Slotframe Handle: 0, #links: 2
Timeslot: 0, Channel Offset: 1, Link Options: Rx | Shared
Timeslot: 1, Channel Offset: 2, Link Options: Tx | Rx | Shared
"
);
}

#[test]
fn enhanced_ack() {
let input = "022e37cdab0200020002000200020fe18f";
Expand Down
Loading

0 comments on commit 6017125

Please sign in to comment.