NOC: Support read attribute for current fabric index
This commit is contained in:
parent
1048b781f1
commit
59ebfa06c9
1 changed files with 34 additions and 2 deletions
|
@ -78,6 +78,16 @@ pub enum Commands {
|
||||||
AddTrustedRootCert = 0x0b,
|
AddTrustedRootCert = 0x0b,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(FromPrimitive)]
|
||||||
|
enum Attributes {
|
||||||
|
NOCs = 0,
|
||||||
|
Fabrics = 1,
|
||||||
|
SupportedFabrics = 2,
|
||||||
|
CommissionedFabrics = 3,
|
||||||
|
TrustedRootCerts = 4,
|
||||||
|
CurrentFabricIndex = 5,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct NocCluster {
|
pub struct NocCluster {
|
||||||
base: Cluster,
|
base: Cluster,
|
||||||
dev_att: Box<dyn DevAttDataFetcher>,
|
dev_att: Box<dyn DevAttDataFetcher>,
|
||||||
|
@ -106,13 +116,15 @@ impl NocCluster {
|
||||||
acl_mgr: Arc<AclMgr>,
|
acl_mgr: Arc<AclMgr>,
|
||||||
failsafe: Arc<FailSafe>,
|
failsafe: Arc<FailSafe>,
|
||||||
) -> Result<Box<Self>, Error> {
|
) -> Result<Box<Self>, Error> {
|
||||||
Ok(Box::new(Self {
|
let mut c = Box::new(Self {
|
||||||
dev_att,
|
dev_att,
|
||||||
fabric_mgr,
|
fabric_mgr,
|
||||||
acl_mgr,
|
acl_mgr,
|
||||||
failsafe,
|
failsafe,
|
||||||
base: Cluster::new(ID)?,
|
base: Cluster::new(ID)?,
|
||||||
}))
|
});
|
||||||
|
c.base.add_attribute(attr_currfabindex_new()?)?;
|
||||||
|
Ok(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_acl(&self, fab_idx: u8, admin_subject: u64) -> Result<(), Error> {
|
fn add_acl(&self, fab_idx: u8, admin_subject: u64) -> Result<(), Error> {
|
||||||
|
@ -342,6 +354,15 @@ impl NocCluster {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn attr_currfabindex_new() -> Result<Attribute, Error> {
|
||||||
|
Attribute::new(
|
||||||
|
Attributes::CurrentFabricIndex as u16,
|
||||||
|
AttrValue::Custom,
|
||||||
|
Access::RV,
|
||||||
|
Quality::NONE,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
impl ClusterType for NocCluster {
|
impl ClusterType for NocCluster {
|
||||||
fn base(&self) -> &Cluster {
|
fn base(&self) -> &Cluster {
|
||||||
&self.base
|
&self.base
|
||||||
|
@ -367,6 +388,17 @@ impl ClusterType for NocCluster {
|
||||||
_ => Err(IMStatusCode::UnsupportedCommand),
|
_ => Err(IMStatusCode::UnsupportedCommand),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_custom_attribute(&self, encoder: &mut dyn Encoder, attr: &AttrDetails) {
|
||||||
|
match num::FromPrimitive::from_u16(attr.attr_id) {
|
||||||
|
Some(Attributes::CurrentFabricIndex) => {
|
||||||
|
encoder.encode(EncodeValue::Value(&attr.fab_idx))
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
error!("Attribute not supported: this shouldn't happen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_attestation_element(
|
fn add_attestation_element(
|
||||||
|
|
Loading…
Add table
Reference in a new issue