Skip to content

Commit

Permalink
allow endpoints with multiple device types (#205)
Browse files Browse the repository at this point in the history
* allow endpoints with multiple device types

* fix typo
  • Loading branch information
koalatux authored Sep 25, 2024
1 parent 470a7be commit 850e02a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/onoff_light/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn run() -> Result<(), Error> {
core::mem::size_of_val(&responder.run::<4, 4>())
);

// Run the responder with up to 4 handlers (i.e. 4 exchanges can be handled simultenously)
// Run the responder with up to 4 handlers (i.e. 4 exchanges can be handled simultaneously)
// Clients trying to open more exchanges than the ones currently running will get "I'm busy, please try again later"
let mut respond = pin!(responder.run::<4, 4>());
//let mut respond = responder_fut(responder);
Expand Down Expand Up @@ -229,7 +229,7 @@ const NODE: Node<'static> = Node {
root_endpoint::endpoint(0, root_endpoint::OperNwType::Ethernet),
Endpoint {
id: 1,
device_type: DEV_TYPE_ON_OFF_LIGHT,
device_types: &[DEV_TYPE_ON_OFF_LIGHT],
clusters: &[descriptor::CLUSTER, cluster_on_off::CLUSTER],
},
],
Expand Down
2 changes: 1 addition & 1 deletion examples/onoff_light_bt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const NODE: Node<'static> = Node {
root_endpoint::endpoint(0, root_endpoint::OperNwType::Wifi),
Endpoint {
id: 1,
device_type: DEV_TYPE_ON_OFF_LIGHT,
device_types: &[DEV_TYPE_ON_OFF_LIGHT],
clusters: &[descriptor::CLUSTER, cluster_on_off::CLUSTER],
},
],
Expand Down
2 changes: 1 addition & 1 deletion rs-matter/src/data_model/objects/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use super::{AttrId, Attribute, Cluster, ClusterId, CmdId, DeviceType, EndptId};
#[derive(Debug, Clone)]
pub struct Endpoint<'a> {
pub id: EndptId,
pub device_type: DeviceType,
pub device_types: &'a [DeviceType],
pub clusters: &'a [Cluster<'a>],
}

Expand Down
2 changes: 1 addition & 1 deletion rs-matter/src/data_model/root_endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub enum OperNwType {
pub const fn endpoint(id: EndptId, op_nw_type: OperNwType) -> Endpoint<'static> {
Endpoint {
id,
device_type: super::device_types::DEV_TYPE_ROOT_NODE,
device_types: &[super::device_types::DEV_TYPE_ROOT_NODE],
clusters: clusters(op_nw_type),
}
}
Expand Down
5 changes: 3 additions & 2 deletions rs-matter/src/data_model/system_model/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ impl<'a> DescriptorCluster<'a> {
tw.start_array(tag)?;
for endpoint in node.endpoints {
if endpoint.id == endpoint_id {
let dev_type = endpoint.device_type;
dev_type.to_tlv(&TagType::Anonymous, &mut *tw)?;
for dev_type in endpoint.device_types {
dev_type.to_tlv(&TagType::Anonymous, &mut *tw)?;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions rs-matter/tests/common/e2e/im/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'a> E2eTestHandler<'a> {
access_control::CLUSTER,
echo_cluster::CLUSTER,
],
device_type: DEV_TYPE_ROOT_NODE,
device_types: &[DEV_TYPE_ROOT_NODE],
},
Endpoint {
id: 1,
Expand All @@ -69,7 +69,7 @@ impl<'a> E2eTestHandler<'a> {
cluster_on_off::CLUSTER,
echo_cluster::CLUSTER,
],
device_type: DEV_TYPE_ON_OFF_LIGHT,
device_types: &[DEV_TYPE_ON_OFF_LIGHT],
},
],
};
Expand Down
4 changes: 2 additions & 2 deletions rs-matter/tests/common/im_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const NODE: Node<'static> = Node {
access_control::CLUSTER,
echo_cluster::CLUSTER,
],
device_type: DEV_TYPE_ROOT_NODE,
device_types: &[DEV_TYPE_ROOT_NODE],
},
Endpoint {
id: 1,
Expand All @@ -118,7 +118,7 @@ const NODE: Node<'static> = Node {
cluster_on_off::CLUSTER,
echo_cluster::CLUSTER,
],
device_type: DEV_TYPE_ON_OFF_LIGHT,
device_types: &[DEV_TYPE_ON_OFF_LIGHT],
},
],
};
Expand Down

0 comments on commit 850e02a

Please sign in to comment.