Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow endpoints with multiple device types #205

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>());

Expand Down Expand Up @@ -195,7 +195,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
Loading