Bugfix: fabric adding wrongly started at index 0
This commit is contained in:
parent
b4f92b0063
commit
4c83112b33
2 changed files with 20 additions and 14 deletions
|
@ -199,6 +199,12 @@ impl KeyPair {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Debug for KeyPair {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("KeyPair").finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn convert_r_s_to_asn1_sign(signature: &[u8], mbedtls_sign: &mut [u8]) -> Result<usize, Error> {
|
fn convert_r_s_to_asn1_sign(signature: &[u8], mbedtls_sign: &mut [u8]) -> Result<usize, Error> {
|
||||||
let r = &signature[0..32];
|
let r = &signature[0..32];
|
||||||
let s = &signature[32..64];
|
let s = &signature[32..64];
|
||||||
|
|
|
@ -53,7 +53,7 @@ const ST_PBKEY: &str = "pubkey";
|
||||||
const ST_PRKEY: &str = "privkey";
|
const ST_PRKEY: &str = "privkey";
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(ToTLV)]
|
#[derive(Debug, ToTLV)]
|
||||||
#[tlvargs(lifetime = "'a", start = 1)]
|
#[tlvargs(lifetime = "'a", start = 1)]
|
||||||
pub struct FabricDescriptor<'a> {
|
pub struct FabricDescriptor<'a> {
|
||||||
root_public_key: OctetStr<'a>,
|
root_public_key: OctetStr<'a>,
|
||||||
|
@ -66,6 +66,7 @@ pub struct FabricDescriptor<'a> {
|
||||||
pub fab_idx: Option<u8>,
|
pub fab_idx: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Fabric {
|
pub struct Fabric {
|
||||||
node_id: u64,
|
node_id: u64,
|
||||||
fabric_id: u64,
|
fabric_id: u64,
|
||||||
|
@ -532,22 +533,21 @@ impl FabricMgr {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(&mut self, f: Fabric, mdns_mgr: &mut MdnsMgr) -> Result<u8, Error> {
|
pub fn add(&mut self, f: Fabric, mdns_mgr: &mut MdnsMgr) -> Result<u8, Error> {
|
||||||
let index = self
|
for i in 1..MAX_SUPPORTED_FABRICS {
|
||||||
.fabrics
|
if self.fabrics[i].is_none() {
|
||||||
.iter()
|
self.fabrics[i] = Some(f);
|
||||||
.skip(1)
|
mdns_mgr.publish_service(
|
||||||
.position(|f| f.is_none())
|
&self.fabrics[i].as_ref().unwrap().mdns_service_name,
|
||||||
.ok_or(Error::NoSpace)?;
|
ServiceMode::Commissioned,
|
||||||
|
)?;
|
||||||
|
|
||||||
self.fabrics[index] = Some(f);
|
self.changed = true;
|
||||||
mdns_mgr.publish_service(
|
|
||||||
&self.fabrics[index].as_ref().unwrap().mdns_service_name,
|
|
||||||
ServiceMode::Commissioned,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
self.changed = true;
|
return Ok(i as u8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(index as u8)
|
Err(Error::NoSpace)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&mut self, fab_idx: u8, mdns_mgr: &mut MdnsMgr) -> Result<(), Error> {
|
pub fn remove(&mut self, fab_idx: u8, mdns_mgr: &mut MdnsMgr) -> Result<(), Error> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue