Skip to main content

zigbee_core/aps/frame/
header.rs

1//! APS Frame Header
2use zigbee_macros::impl_byte;
3use zigbee_types::ShortAddress;
4
5use super::frame_control::DeliveryMode;
6use super::frame_control::FrameControl;
7use crate::aps::frame::frame_control::ExtendedFrameControlField;
8
9impl_byte! {
10    /// 2.2.5.1 General APDU Frame Format
11    #[derive(Clone, Debug, Eq, PartialEq)]
12    pub struct Header {
13        pub frame_control: FrameControl,
14        /// 2.2.5.1.2 — present for unicast or broadcast delivery
15        #[parse_if = frame_control.has_destination_endpoint()]
16        pub destination_endpoint: Option<u8>,
17        /// 2.2.5.1.3 — present only for group addressing
18        #[parse_if = frame_control.delivery_mode() == DeliveryMode::GroubAddressing]
19        pub group_address: Option<ShortAddress>,
20        /// 2.2.5.1.4 — present for data and ack frames
21        #[parse_if = frame_control.has_data_fields()]
22        pub cluster_id: Option<u16>,
23        /// 2.2.5.1.5 — present for data and ack frames
24        #[parse_if = frame_control.has_data_fields()]
25        pub profile_id: Option<u16>,
26        /// 2.2.5.1.6 — present for data and ack frames
27        #[parse_if = frame_control.has_data_fields()]
28        pub source_endpoint: Option<u8>,
29        pub counter: u8,
30        #[parse_if = frame_control.extended_header()]
31        pub extended_header: Option<ExtendedFrameControlField>,
32    }
33}