Skip to content

Commit

Permalink
add APSEM
Browse files Browse the repository at this point in the history
  • Loading branch information
thebino committed Oct 7, 2024
1 parent 2b74fef commit fdbcb09
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 71 deletions.
67 changes: 67 additions & 0 deletions src/aps/apsde.rs
Original file line number Diff line number Diff line change
@@ -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,
}

90 changes: 90 additions & 0 deletions src/aps/apsme.rs
Original file line number Diff line number Diff line change
@@ -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,
}

75 changes: 4 additions & 71 deletions src/aps/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit fdbcb09

Please sign in to comment.