Expand description
Zero-copy read and write structures for handling IEEE 802.15.4 MAC frames.
Each reader contains the following functions:
new: Create a new reader.check_len: Check if the buffer is long enough to contain a valid frame.new_unchecked: Create a new reader without checking the buffer length.
The most important reader is the Frame reader, which is used to read a
full IEEE 802.15.4 frame. The reader provides the following functions:
frame_control: returns aFrameControlreader.sequence_number: returns the sequence number if not suppressed.addressing: returns anAddressingFieldsreader.auxiliary_security_header: returns anAuxiliarySecurityHeaderreader.information_elements: returns anInformationElementsreader.payload: returns the payload of the frame.
§Reading a frame
For an incoming frame, use the Frame structure to read its content.
let frame = Frame::new(&frame).unwrap();
let fc = frame.frame_control();
let src_addr = frame.addressing().unwrap().src_address();
let dst_addr = frame.addressing().unwrap().dst_address();
assert_eq!(fc.frame_type(), FrameType::Beacon);
let Some(ie) = frame.information_elements() else { return; };
for payload in ie.payload_information_elements() {
if matches!(payload.group_id(), PayloadGroupId::Mlme) {
for nested in payload.nested_information_elements() {
match nested.sub_id() {
NestedSubId::Short(NestedSubIdShort::TschTimeslot) => {
let time_slot = TschTimeslot::new(nested.content()).unwrap();
assert_eq!(time_slot.id(), 0);
}
_ => (),
}
}
}
}§Writing a frame
Work in progress!
§Information Elements
The IEEE 802.15.4 standard defines a set of Information Elements (IEs) that
can be included in the frame. These IEs are used to provide additional
information about the frame, such as timestamping, channel hopping, and
more. The IEs are divided into two groups: Header IEs and Payload IEs.
Calling information_elements on a Frame reader returns an
InformationElements reader. The reader provides access to the Header and
Payload IEs, via the header_information_elements and
payload_information_elements functions.
§Header Information Elements
The Header IEs are located in the frame header, and are used to provide information about the frame itself. The following IEs are defined in the standard:
-
VendorSpecific -
Csl -
Rit -
DsmePanDescriptor -
RendezvousTime -
TimeCorrection -
ExtededDsmePanDescriptor -
FragmentSequencecontextDescription -
SimplifiedSuperframeSpecification -
SimplifiedGtsSpecification -
LecimCapabilities -
TrleDescriptor -
RccCapabilities -
RccnDescriptor -
GlobalTime -
Da -
HeaderTermination1 -
HeaderTermination2
§Payload Information Elements
The Payload IEs are located in the frame payload, and are used to provide information about the payload itself. The following IEs are defined in the standard:
-
Esdu -
Mlme: The MLME group contains a set of nested IEs. Callnested_information_elementsto get an iterator over the nested IEs. -
VendorSpecific -
PayloadTermination
§Nested Information Elements
Some IEs contain nested IEs. The NestedInformationElementsIterator
provides an iterator over the nested IEs. The iterator is used to parse the
nested IEs.
The Nested IEs are split into two groups: Short and Long. The following short IEs are defined in the standard:
-
TschSynchronization -
TschSlotframeAndLink -
TschTimeslot -
HoppingTiming -
EnhancedBeaconFilter -
MacMetrics -
AllMacMetrics -
CoexistenceSpecification -
SunDeviceCapabilities -
SunFskGenericPhy -
ModeSwitchParameter -
PhyParameterChange -
OQpskPhyMode -
PcaAllocation -
LecimDsssOperatingMode -
LecimFskOperatingMode -
TvwsPhyOperatingMode -
TvwsDeviceCapabilities -
TvwsDeviceCategory -
TvwsDeviceIdentification -
TvwsDeviceLocation -
TvwsChannelInformationQuery -
TvwsChannelInformationSource -
Ctm -
Timestamp -
TimestampDifference -
TmctpSpecification -
RccPhyOperatingMode -
LinkMargin -
RsGfskDeviceCapabilities -
MultiPhy -
VendorSpecific -
Srm
The following long IEs are defined in the standard:
-
VendorSpecificNested -
ChannelHopping
Structs§
- A reader/writer for the IEEE 802.15.4 Addressing Fields.
- A high-level representation of the IEEE 802.15.4 Addressing Fields.
- A reader/writer for the IEEE 802.15.4 Auxiliary Security Header.
- A reader/writer for the IEEE 802.15.4 CFP Specification Header Information Element.
- A reader/writer for the Channel Hopping IE.
- A high-level representation of a Channel Hopping Nested Information Element.
- Channel Hopping Specification Header Information Element.
- CSL Header Information Element.
- DSME Superframe Specification Header Information Element.
- An error that can occur when reading or writing an IEEE 802.15.4 frame.
- A reader/writer for an IEEE 802.15.4 frame.
- A helper for building IEEE 802.15.4 frames.
- A reader/writer for the IEEE 802.15.4 Frame Control field.
- A high-level representation of the IEEE 802.15.4 Frame Control field.
- A high-level representation of an IEEE 802.15.4 frame.
- Guaranteed Timeslot Descriptor
- An
Iteratorover GTS slots. - Guaranteed Time Slot specification.
- A reader/writer for the IEEE 802.15.4 Header Information Elements
- An
IteratoroverHeaderInformationElement. - IEEE 802.15.4 Information Element reader.
- A high-level representation of Information Elements.
- A Key Identifier Mode field.
- A reader/writer for the Link Descriptor.
- An
IteratoroverLinkDescriptor. - A reader/writer for the IEEE 802.15.4 Nested Information Elements.
- An
IteratoroverNestedInformationElement. - A reader/writer for the IEEE 802.15.4 Payload Information Elements.
- An
IteratoroverPayloadInformationElement. - Renzdevous Time Header Information Element.
- RIT Header Information Element.
- A reader/writer for the IEEE 802.15.4 Security Control field.
- A Security Level field.
- A reader/writer for the IEEE 802.15.4 Simplified Superframe Specification Header Information Element.
- A reader/writer for the Slotframe Descriptor.
- An
IteratoroverSlotframeDescriptor. - A reader/writer for the IEEE 802.15.4 Superframe Specification Header Information Element.
- Supported DSSS DPSK Modulation values.
- Supported Frequency Bands values.
- Supported Modulation values.
- A reader/writer for the IEEE 802.15.4 Time Correction Header Information Element.
- A high-level representation of a Time Correction Header Information Element.
- Time Synchronization Specification Header Information Element.
- TSCH link options bitfield.
- A reader/writer for the TSCH slotframe and link IE.
- A high-level representation of a TSCH Slotframe and Link Nested Information Element.
- A reader/writer for the TSCH synchronization IE.
- A high-level representation of a TSCH Synchronization Nested Information Element.
- A reader/writer for the TSCH timeslot IE.
- A high-level representation of a TSCH Timeslot Nested Information Element.
- A TSCH time slot timings (figure 6-30 in IEEE 802.15.4-2020).
- Vendor Specific Header Information Element.
Enums§
- An IEEE 802.15.4 address.
- IEEE 802.15.4 addressing mode.
- Indicates the frequency at which the beacon is transmitted.
- IEEE 802.15.4 frame type.
- IEEE 802.15.4 frame version.
- GTS direciton.
- Header Information Element ID.
- A high-level representation of a Header Information Element.
- A high-level representation of a MLME Payload Information Element.
- Nested Information Element ID.
- Long Nested Information Element ID.
- Short Nested Information Element ID.
- Payload Information Element ID.
- A high-level representation of a Payload Information Element.
- The lenght of the active portion of the superframe.
Type Aliases§
- A type alias for
Result<T, frame::Error>.