diff --git a/homekit-controller/src/tlv8/mod.rs b/homekit-controller/src/tlv8/mod.rs index 76cfff4..add2e49 100644 --- a/homekit-controller/src/tlv8/mod.rs +++ b/homekit-controller/src/tlv8/mod.rs @@ -19,6 +19,7 @@ impl FormatTlv for (u8, Vec) { impl FormatTlv for (&u8, &Vec) { fn as_tlv_string(&self) -> String { let (tlv_type, data) = self; + let tlv_type_num = *self.0; let tlv_type = TlvType::try_from(**tlv_type).map_err(|e| format!("Unknown TLV type: {}", e.0)); match tlv_type { @@ -47,7 +48,10 @@ impl FormatTlv for (&u8, &Vec) { ) }) .unwrap_or(String::from("TLV error type with no data!")), - _ => format!("{tlv_type:?}: {data:?} (length: {})", data.len()), + _ => format!( + "{tlv_type:?} ({tlv_type_num}): {data:?} (length: {})", + data.len() + ), }, Err(tlv_type) => format!("{tlv_type}: {data:?} (length: {})", data.len()), } @@ -61,7 +65,7 @@ impl FormatTlv for HashMap> { } } -impl FormatTlv for Vec<(u8, Vec)> { +impl FormatTlv for &[(u8, Vec)] { fn as_tlv_string(&self) -> String { self.iter() .fold(String::new(), |a, v| format!("{a}\n{}", v.as_tlv_string())) @@ -97,7 +101,7 @@ pub fn decode(data: &[u8]) -> Result>, TlvCodecError> { }; tlvs.insert(tlv_type, tlv_data); } - log::info!("{}", tlvs.as_tlv_string()); + log::info!("Decoded TLV: {}\n", tlvs.as_tlv_string()); Ok(tlvs) }