From fdbcb096458eb8dacc4a2a071b67a99d24179644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Mon, 7 Oct 2024 05:55:05 +0200 Subject: [PATCH] add APSEM --- src/aps/apsde.rs | 67 +++++++++++++++++++++++++++++++++++ src/aps/apsme.rs | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ src/aps/mod.rs | 75 +++------------------------------------- 3 files changed, 161 insertions(+), 71 deletions(-) create mode 100644 src/aps/apsde.rs create mode 100644 src/aps/apsme.rs diff --git a/src/aps/apsde.rs b/src/aps/apsde.rs new file mode 100644 index 0000000..573458a --- /dev/null +++ b/src/aps/apsde.rs @@ -0,0 +1,67 @@ +#![allow(dead_code)] +use crate::aps::types; + +type DstAddrMode = u8; +// 2.2.4.1.1 +struct ApsdeSapRequest { + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, + profile_id: u16, + cluster_id: u16, + src_endpoint: types::SrcEndpoint, + asdulength: u8, + asdu: u8, + tx_options: bitmaps::Bitmap<8>, + use_alias: bool, + alias_src_addr: u16, + alias_seq_number: u8, + radius_counter: u8 +} + +enum ApsdeSapConfirmStatus { + Success, + NoShortAddress, + NoBoundDevice, + SecurityFail, + NoAck, + AsduTooLong +} +// 2.2.4.1.2 +struct ApsdeSapConfirm { + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, + src_endpoint: types::SrcEndpoint, + status: ApsdeSapConfirmStatus, + tx_time: u8, +} + +enum ApsdeSapIndicationStatus { + Success, + DefragUnsupported, + DefragDeferred +} +enum SecurityStatus { + Unsecured, + SecuredNwkKey, + SecuredLinkKey +} + +// 2.2.4.1.3 +struct ApsdeSapIndication { + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, + src_addr_mode: u8, + src_address: u64, + src_endpoint: types::SrcEndpoint, + profile_id: u16, + cluster_id: u16, + asdulength: u8, + status: ApsdeSapIndicationStatus, + security_status: SecurityStatus, + link_quality: u8, + rx_time: u8, +} + diff --git a/src/aps/apsme.rs b/src/aps/apsme.rs new file mode 100644 index 0000000..54b540a --- /dev/null +++ b/src/aps/apsme.rs @@ -0,0 +1,90 @@ +#![allow(dead_code)] +use crate::aps::types; + +type DstAddrMode = u8; +// 2.2.4.3.1 APSME-BIND.request +struct ApsmeBindRequest { + src_address: u64, + src_endpoint: types::SrcEndpoint, + cluster_id: u16, + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, +} + +enum ApsmeBindRequestStatus { + Success, + IllegalRequest, + TableFull, + NotSupported +} + +// 2.2.4.3.2 APSME-BIND.confirm +struct ApsmeBindConfirm { + status: ApsmeBindRequestStatus, + src_address: u64, + src_endpoint: types::SrcEndpoint, + cluster_id: u16, + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, +} + +// 2.2.4.3.3 APSME-UNBIND.request +struct ApsmeUnbindRequest { + src_address: u64, + src_endpoint: types::SrcEndpoint, + cluster_id: u16, + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, +} + +enum ApsmeUnbindRequestStatus { + Success, + IllegalRequest, + InvalidBinding +} +// 2.2.4.3.4 APSME-UNBIND.confirm +struct ApsmeUnbindConfirm { + status: ApsmeUnbindRequestStatus, + src_address: u64, + src_endpoint: types::SrcEndpoint, + cluster_id: u16, + dst_addr_mode: DstAddrMode, + dst_address: u8, + dst_endpoint: u8, +} + +enum AIBAttribute { + IapsBindingTable = 0xc1, + ApsDesignatedCoordinator = 0xc2, + ApsChannelMaskList = 0xc3, + ApsUseExtendedPANID = 0xc4, + ApsGroupTable = 0xc5, + ApsNonmemberRadius = 0xc6, + ApsUseInsecureJoin = 0xc8, + ApsInterframeDelay = 0xc9, + ApsLastChannelEnergy = 0xca, + ApsLastChannelFailureRate = 0xcb, + ApsChannelTimer = 0xcc, + ApsMaxWindowSize = 0xcd, + ApsParentAnnounceTimer = 0xce, +} + +// 2.2.4.4.1 APSME-GET.request +struct ApsmeGetRequest { + attribute: AIBAttribute +} + +struct AIBAttributeValue { + +} + +struct ApsmeGetConfirm { + status: u8, + attribute: AIBAttribute, + attribute_length: u8, + attribute_value: AIBAttributeValue, +} + diff --git a/src/aps/mod.rs b/src/aps/mod.rs index f792b39..50327b4 100644 --- a/src/aps/mod.rs +++ b/src/aps/mod.rs @@ -1,73 +1,6 @@ -#![allow(dead_code)] +pub(crate) mod types; +pub(crate) mod error; -mod error; -mod types; - -trait ApsdeSap { - -} - -type DstAddrMode = u8; -// 2.2.4.1.1 -struct ApsdeSapRequest { - dst_addr_mode: DstAddrMode, - dst_address: u8, - dst_endpoint: u8, - profile_id: u16, - cluster_id: u16, - src_endpoint: types::SrcEndpoint, - asdulength: u8, - asdu: u8, - tx_options: bitmaps::Bitmap<8>, - use_alias: bool, - alias_src_addr: u16, - alias_seq_number: u8, - radius_counter: u8 -} - -enum ApsdeSapConfirmStatus { - Success, - NoShortAddress, - NoBoundDevice, - SecurityFail, - NoAck, - AsduTooLong -} -// 2.2.4.1.2 -struct ApsdeSapConfirm { - dst_addr_mode: DstAddrMode, - dst_address: u8, - dst_endpoint: u8, - src_endpoint: types::SrcEndpoint, - status: ApsdeSapConfirmStatus, - tx_time: u8, -} - -enum ApsdeSapIndicationStatus { - Success, - DefragUnsupported, - DefragDeferred -} -enum SecurityStatus { - Unsecured, - SecuredNwkKey, - SecuredLinkKey -} - -// 2.2.4.1.3 -struct ApsdeSapIndication { - dst_addr_mode: DstAddrMode, - dst_address: u8, - dst_endpoint: u8, - src_addr_mode: u8, - src_address: u64, - src_endpoint: types::SrcEndpoint, - profile_id: u16, - cluster_id: u16, - asdulength: u8, - status: ApsdeSapIndicationStatus, - security_status: SecurityStatus, - link_quality: u8, - rx_time: u8, -} +pub(crate) mod apsde; +pub(crate) mod apsme;