Skip to main content

zigbee_core/aps/apsde/
mod.rs

1//! Application Support Sub-Layer Data Entity
2//!
3//! The APSDE provides the data transmission service for application objects
4//! and the ZDO. It generates the APS PDU and hands it to the NWK layer for
5//! encryption and routing.
6//!
7//! See Zigbee R22 2.2.4.1.
8#![allow(dead_code)]
9
10use super::types::Address;
11use super::types::DstAddrMode;
12use super::types::SrcAddrMode;
13use super::types::TxOptions;
14use crate::aps::types;
15
16// 2.2.4.1.1
17#[derive(Debug, Clone, PartialEq)]
18pub struct ApsdeSapRequest<'a> {
19    pub dst_addr_mode: DstAddrMode,
20    pub dst_address: Address,
21    pub dst_endpoint: u8,
22    pub profile_id: u16,
23    pub cluster_id: u16,
24    pub src_endpoint: types::SrcEndpoint,
25    pub asdu: &'a [u8],
26    pub tx_options: TxOptions,
27    pub use_alias: bool,
28    pub alias_src_addr: u16,
29    pub alias_seq_number: u8,
30    pub radius_counter: u8,
31}
32
33impl Default for ApsdeSapRequest<'_> {
34    fn default() -> Self {
35        Self {
36            dst_addr_mode: DstAddrMode::default(),
37            dst_address: Address::default(),
38            dst_endpoint: 0,
39            profile_id: 0,
40            cluster_id: 0,
41            src_endpoint: types::SrcEndpoint::default(),
42            asdu: &[],
43            tx_options: TxOptions::default(),
44            use_alias: false,
45            alias_src_addr: 0,
46            alias_seq_number: 0,
47            radius_counter: 0,
48        }
49    }
50}
51
52/// The status of the corresponding request.
53#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
54pub enum ApsdeSapConfirmStatus {
55    /// indicating that the request to transmit was successful
56    #[default]
57    Success,
58    /// No corresponding 16-bit NKW address found
59    NoShortAddress,
60    /// No binding table entries found with the respectively SrcEndpoint and
61    /// ClusterId parameter
62    NoBoundDevice,
63    /// the security processing failed
64    SecurityFail,
65    /// one or more APS acknowledgements were not correctly received
66    NoAck,
67    /// ASDU to be transmitted is larger than will fit in a single frame and
68    /// fragmentation is not possible
69    AsduTooLong,
70    /// addressing mode not implemented (MVP: only Network/Short is supported)
71    Unsupported,
72}
73
74// 2.2.4.1.2
75#[derive(Debug, Clone, Copy, Default, PartialEq)]
76pub struct ApsdeSapConfirm {
77    pub dst_addr_mode: DstAddrMode,
78    pub dst_address: Address,
79    pub dst_endpoint: u8,
80    pub src_endpoint: types::SrcEndpoint,
81    pub status: ApsdeSapConfirmStatus,
82    pub tx_time: u8,
83}
84
85#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
86pub enum ApsdeSapIndicationStatus {
87    #[default]
88    Success,
89    DefragUnsupported,
90    DefragDeferred,
91}
92
93#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
94pub enum SecurityStatus {
95    #[default]
96    Unsecured,
97    SecuredNwkKey,
98    SecuredLinkKey,
99}
100
101// 2.2.4.1.3
102#[derive(Debug, Clone, PartialEq)]
103pub struct ApsdeSapIndication<'a> {
104    pub dst_addr_mode: DstAddrMode,
105    pub dst_address: Address,
106    pub dst_endpoint: u8,
107    pub src_addr_mode: SrcAddrMode,
108    pub src_address: Address,
109    pub src_endpoint: types::SrcEndpoint,
110    pub profile_id: u16,
111    pub cluster_id: u16,
112    pub asdu: &'a [u8],
113    pub status: ApsdeSapIndicationStatus,
114    pub security_status: SecurityStatus,
115    pub link_quality: u8,
116    pub rx_time: u8,
117}