Skip to content

Commit

Permalink
Merge branch 'main' into feature/APSDE-SAP
Browse files Browse the repository at this point in the history
  • Loading branch information
thebino committed Oct 21, 2024
2 parents 8e20626 + dfac273 commit e0327a5
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "zigbee-rs"
version = "0.1.0"
name = "zigbee"
version = "0.1.0-alpha.1"
authors = ["Stürmer, Benjamin <[email protected]>"]
edition = "2018"
rust-version = "1.31"

description = "ZigBee protocol stack based on the [ZigBee specification 22 1.0](https://csa-iot.org/wp-content/uploads/2022/01/docs-05-3474-22-0csg-zigbee-specification-1.pdf)"
documentation = "https://docs.rs/zigbee-rs"
homepage = "https://github.com/thebino/zigbee-rs"
description = "ZigBee protocol stack in `no-std` based on the [ZigBee specification 22 1.0](https://csa-iot.org/wp-content/uploads/2022/01/docs-05-3474-22-0csg-zigbee-specification-1.pdf)"
documentation = "https://docs.rs/zigbee"
repository = "https://github.com/thebino/zigbee-rs"
readme = "README.md"
keywords = ["zigbee", "208.15.4"]
categories = ["network-programming", "no-std", "embedded"]
license = "MIT OR Apache-2.0"

[features]

[dependencies]
bitmaps = { version = "3.2.1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# zigbee-rs
# zigbee

[![License](https://img.shields.io/github/license/thebino/zigbee-rs?style=for-the-badge)](./LICENSE-APACHE)
[![GitHub contributors](https://img.shields.io/github/contributors/thebino/zigbee-rs?color=success&style=for-the-badge)](https://github.com/thebino/zigbee-rs/graphs/contributors)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/thebino/zigbee-rs/ci.yaml?style=for-the-badge)
[![GitHub contributors](https://img.shields.io/github/contributors/thebino/zigbee-rs?color=success&style=for-the-badge)](https://github.com/thebino/zigbee-rs/graphs/contributors)
[![License](https://img.shields.io/github/license/thebino/zigbee-rs?style=for-the-badge)](./LICENSE.md)
![ZigBee](https://img.shields.io/badge/zigbee-22.1.0-blue?color=4285F4&logo=zigbee&style=for-the-badge)
![Rust](https://img.shields.io/badge/rust-2021-orange?color=E45928&logo=rust&style=for-the-badge)

The ZigBee protocol stack to integrate ZigBee communication into an application.
The ZigBee protocol stack** in `no_std` to integrate ZigBee communication into an application.

Zigbee is a wireless communication technology designed for low-power devices in smart homes and industrial settings.
It enables these devices to connect and communicate with each other, allowing for efficient control and automation of various systems.
Expand Down
15 changes: 13 additions & 2 deletions src/aps/apsde.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#![allow(dead_code)]
use crate::aps::types;

// 2.2.4.1
// Application support sub-layer data entity – service access point
//
// Interface between the NWK (Network) layer and the APL (Application) layer
// through a general set of services for use by both the ZDO (device object) and the application.
pub(crate) trait ApsdeSap {
fn data_request(request: ApsdeSapRequest) -> ApsdeSapConfirm;
}



type DstAddrMode = u8;
// 2.2.4.1.1
struct ApsdeSapRequest {
pub(crate) struct ApsdeSapRequest {
dst_addr_mode: DstAddrMode,
dst_address: u8,
dst_endpoint: u8,
Expand All @@ -28,7 +39,7 @@ enum ApsdeSapConfirmStatus {
AsduTooLong
}
// 2.2.4.1.2
struct ApsdeSapConfirm {
pub(crate) struct ApsdeSapConfirm {
dst_addr_mode: DstAddrMode,
dst_address: u8,
dst_endpoint: u8,
Expand Down
8 changes: 4 additions & 4 deletions src/aps/apsme/basemgt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::aps::types;

type DstAddrMode = u8;
// 2.2.4.3.1 APSME-BIND.request
struct ApsmeBindRequest {
pub(crate) struct ApsmeBindRequest {
src_address: u64,
src_endpoint: types::SrcEndpoint,
cluster_id: u16,
Expand All @@ -23,7 +23,7 @@ enum ApsmeBindRequestStatus {
}

// 2.2.4.3.2 APSME-BIND.confirm
struct ApsmeBindConfirm {
pub(crate) struct ApsmeBindConfirm {
status: ApsmeBindRequestStatus,
src_address: u64,
src_endpoint: types::SrcEndpoint,
Expand Down Expand Up @@ -59,7 +59,7 @@ struct ApsmeUnbindConfirm {
dst_endpoint: u8,
}

enum AIBAttribute {
pub(crate) enum AIBAttribute {
IapsBindingTable = 0xc1,
ApsDesignatedCoordinator = 0xc2,
ApsChannelMaskList = 0xc3,
Expand All @@ -80,7 +80,7 @@ struct ApsmeGetRequest {
attribute: AIBAttribute
}

struct AIBAttributeValue {
pub(crate) struct AIBAttributeValue {

}

Expand Down
27 changes: 27 additions & 0 deletions src/aps/apsme/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
use basemgt::{AIBAttribute, AIBAttributeValue, ApsmeBindConfirm, ApsmeBindRequest};

pub(crate) mod basemgt;
pub(crate) mod groupmgt;

// 2.2.4.2
// Application support sub-layer management service = service access point
//
// supports the transport of management commands between the NHLE and the APSME
pub(crate) trait ApsmeSap {
// 2.2.4.3.1
// request to bind two devices together, or to bind a device to a group
fn bind_request(request: ApsmeBindRequest) -> ApsmeBindConfirm;
// 2.2.4.3.3
// request to unbind two devices, or to unbind a device from a group
fn unbind_request();
// 2.2.4.4.1
fn get(attribute: AIBAttribute) -> AIBAttributeValue;
// 2.2.4.4.3
fn set();
// 2.2.4.5.1
fn add_group();
// 2.2.4.5.1
fn remove_group();
// 2.2.4.5.5
fn remove_all_groups();
}

// TODO: add AIB (APS information base) a database of managed objects
//
// 2.2.4.4.1
2 changes: 0 additions & 2 deletions src/aps/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//! Bounded address
//! 2.2.4.1.1

use super::error::ApsError;
pub struct SrcEndpoint {
Expand Down
13 changes: 5 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#![no_std]

//! # zigbee
//! Implements the ZigBee protocol stack in `no-std` based on the [ZigBee specification]
//!
//! ZigBee is a protocol stack based on the ZigBee specification 22 1.0
//! [ZigBee specification]: https://csa-iot.org/wp-content/uploads/2022/01/docs-05-3474-22-0csg-zigbee-specification-1.pdf
//!
mod aps;

mod lib {
#![no_std]

}
mod aps;
pub mod zdo;

17 changes: 17 additions & 0 deletions src/zdo/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![allow(dead_code)]

#[derive(Debug)]
pub struct ZigbeeDevice {
field: bool
}

impl ZigbeeDevice {
pub fn new(gpio: u8) -> Self {
Self { field: true }
}

pub fn discover() {

}
}

0 comments on commit e0327a5

Please sign in to comment.