From 8126bbd25626e0305dd514e9857d4eed349c8b6b Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 6 Dec 2024 12:10:37 +0100 Subject: [PATCH 1/3] [Fabric-Sync] Synchronize all required attributes --- .../admin/DeviceSynchronization.cpp | 83 ++++++++++--------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/examples/fabric-sync/admin/DeviceSynchronization.cpp b/examples/fabric-sync/admin/DeviceSynchronization.cpp index 527ccfa631295a..85310743f9693c 100644 --- a/examples/fabric-sync/admin/DeviceSynchronization.cpp +++ b/examples/fabric-sync/admin/DeviceSynchronization.cpp @@ -81,58 +81,65 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path, return; } + char attribStringBuffer[kBasicInformationAttributeBufSize]; + uint32_t attribUInt32Value; + switch (path.mAttributeId) { - case Clusters::BasicInformation::Attributes::UniqueID::Id: { - char uniqueIdBuffer[kBasicInformationAttributeBufSize]; - if (SuccessOrLog(data->GetString(uniqueIdBuffer, sizeof(uniqueIdBuffer)), "UniqueId")) + case Clusters::BasicInformation::Attributes::UniqueID::Id: + if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "UniqueId")) { - mCurrentDeviceData.uniqueId = std::string(uniqueIdBuffer); + mCurrentDeviceData.uniqueId = std::string(attribStringBuffer); } - } - break; - case Clusters::BasicInformation::Attributes::VendorName::Id: { - char vendorNameBuffer[kBasicInformationAttributeBufSize]; - if (SuccessOrLog(data->GetString(vendorNameBuffer, sizeof(vendorNameBuffer)), "VendorName")) + break; + case Clusters::BasicInformation::Attributes::VendorID::Id: + if (SuccessOrLog(data->Get(attribUInt32Value), "VendorID")) { - mCurrentDeviceData.vendorName = std::string(vendorNameBuffer); + mCurrentDeviceData.vendorId = static_cast(attribUInt32Value); } - } - break; - case Clusters::BasicInformation::Attributes::ProductName::Id: { - char productNameBuffer[kBasicInformationAttributeBufSize]; - if (SuccessOrLog(data->GetString(productNameBuffer, sizeof(productNameBuffer)), "ProductName")) + break; + case Clusters::BasicInformation::Attributes::VendorName::Id: + if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "VendorName")) { - mCurrentDeviceData.productName = std::string(productNameBuffer); + mCurrentDeviceData.vendorName = std::string(attribStringBuffer); } - } - break; - case Clusters::BasicInformation::Attributes::NodeLabel::Id: { - char nodeLabelBuffer[kBasicInformationAttributeBufSize]; - if (SuccessOrLog(data->GetString(nodeLabelBuffer, sizeof(nodeLabelBuffer)), "NodeLabel")) + break; + case Clusters::BasicInformation::Attributes::ProductID::Id: + if (SuccessOrLog(data->Get(attribUInt32Value), "ProductID")) { - mCurrentDeviceData.nodeLabel = std::string(nodeLabelBuffer); + mCurrentDeviceData.productId = attribUInt32Value; } - } - break; - case Clusters::BasicInformation::Attributes::HardwareVersionString::Id: { - char hardwareVersionStringBuffer[kBasicInformationAttributeBufSize]; - if (SuccessOrLog(data->GetString(hardwareVersionStringBuffer, sizeof(hardwareVersionStringBuffer)), - "HardwareVersionString")) + break; + case Clusters::BasicInformation::Attributes::ProductName::Id: + if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "ProductName")) { - mCurrentDeviceData.hardwareVersionString = std::string(hardwareVersionStringBuffer); + mCurrentDeviceData.productName = std::string(attribStringBuffer); } - } - break; - case Clusters::BasicInformation::Attributes::SoftwareVersionString::Id: { - char softwareVersionStringBuffer[kBasicInformationAttributeBufSize]; - if (SuccessOrLog(data->GetString(softwareVersionStringBuffer, sizeof(softwareVersionStringBuffer)), - "SoftwareVersionString")) + break; + case Clusters::BasicInformation::Attributes::NodeLabel::Id: + if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "NodeLabel")) { - mCurrentDeviceData.softwareVersionString = std::string(softwareVersionStringBuffer); + mCurrentDeviceData.nodeLabel = std::string(attribStringBuffer); } - } - break; + break; + case Clusters::BasicInformation::Attributes::HardwareVersionString::Id: + if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "HardwareVersionString")) + { + mCurrentDeviceData.hardwareVersionString = std::string(attribStringBuffer); + } + break; + case Clusters::BasicInformation::Attributes::SoftwareVersion::Id: + if (SuccessOrLog(data->Get(attribUInt32Value), "SoftwareVersion")) + { + mCurrentDeviceData.softwareVersion = attribUInt32Value; + } + break; + case Clusters::BasicInformation::Attributes::SoftwareVersionString::Id: + if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "SoftwareVersionString")) + { + mCurrentDeviceData.softwareVersionString = std::string(attribStringBuffer); + } + break; default: break; } From 17998c371d412f1a77eb8f088ac1d79e8071322d Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Wed, 11 Dec 2024 08:19:14 +0100 Subject: [PATCH 2/3] Revert commit 8126bbd --- .../admin/DeviceSynchronization.cpp | 83 +++++++++---------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/examples/fabric-sync/admin/DeviceSynchronization.cpp b/examples/fabric-sync/admin/DeviceSynchronization.cpp index 85310743f9693c..527ccfa631295a 100644 --- a/examples/fabric-sync/admin/DeviceSynchronization.cpp +++ b/examples/fabric-sync/admin/DeviceSynchronization.cpp @@ -81,65 +81,58 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path, return; } - char attribStringBuffer[kBasicInformationAttributeBufSize]; - uint32_t attribUInt32Value; - switch (path.mAttributeId) { - case Clusters::BasicInformation::Attributes::UniqueID::Id: - if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "UniqueId")) - { - mCurrentDeviceData.uniqueId = std::string(attribStringBuffer); - } - break; - case Clusters::BasicInformation::Attributes::VendorID::Id: - if (SuccessOrLog(data->Get(attribUInt32Value), "VendorID")) + case Clusters::BasicInformation::Attributes::UniqueID::Id: { + char uniqueIdBuffer[kBasicInformationAttributeBufSize]; + if (SuccessOrLog(data->GetString(uniqueIdBuffer, sizeof(uniqueIdBuffer)), "UniqueId")) { - mCurrentDeviceData.vendorId = static_cast(attribUInt32Value); + mCurrentDeviceData.uniqueId = std::string(uniqueIdBuffer); } - break; - case Clusters::BasicInformation::Attributes::VendorName::Id: - if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "VendorName")) - { - mCurrentDeviceData.vendorName = std::string(attribStringBuffer); - } - break; - case Clusters::BasicInformation::Attributes::ProductID::Id: - if (SuccessOrLog(data->Get(attribUInt32Value), "ProductID")) - { - mCurrentDeviceData.productId = attribUInt32Value; - } - break; - case Clusters::BasicInformation::Attributes::ProductName::Id: - if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "ProductName")) + } + break; + case Clusters::BasicInformation::Attributes::VendorName::Id: { + char vendorNameBuffer[kBasicInformationAttributeBufSize]; + if (SuccessOrLog(data->GetString(vendorNameBuffer, sizeof(vendorNameBuffer)), "VendorName")) { - mCurrentDeviceData.productName = std::string(attribStringBuffer); + mCurrentDeviceData.vendorName = std::string(vendorNameBuffer); } - break; - case Clusters::BasicInformation::Attributes::NodeLabel::Id: - if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "NodeLabel")) + } + break; + case Clusters::BasicInformation::Attributes::ProductName::Id: { + char productNameBuffer[kBasicInformationAttributeBufSize]; + if (SuccessOrLog(data->GetString(productNameBuffer, sizeof(productNameBuffer)), "ProductName")) { - mCurrentDeviceData.nodeLabel = std::string(attribStringBuffer); + mCurrentDeviceData.productName = std::string(productNameBuffer); } - break; - case Clusters::BasicInformation::Attributes::HardwareVersionString::Id: - if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "HardwareVersionString")) + } + break; + case Clusters::BasicInformation::Attributes::NodeLabel::Id: { + char nodeLabelBuffer[kBasicInformationAttributeBufSize]; + if (SuccessOrLog(data->GetString(nodeLabelBuffer, sizeof(nodeLabelBuffer)), "NodeLabel")) { - mCurrentDeviceData.hardwareVersionString = std::string(attribStringBuffer); + mCurrentDeviceData.nodeLabel = std::string(nodeLabelBuffer); } - break; - case Clusters::BasicInformation::Attributes::SoftwareVersion::Id: - if (SuccessOrLog(data->Get(attribUInt32Value), "SoftwareVersion")) + } + break; + case Clusters::BasicInformation::Attributes::HardwareVersionString::Id: { + char hardwareVersionStringBuffer[kBasicInformationAttributeBufSize]; + if (SuccessOrLog(data->GetString(hardwareVersionStringBuffer, sizeof(hardwareVersionStringBuffer)), + "HardwareVersionString")) { - mCurrentDeviceData.softwareVersion = attribUInt32Value; + mCurrentDeviceData.hardwareVersionString = std::string(hardwareVersionStringBuffer); } - break; - case Clusters::BasicInformation::Attributes::SoftwareVersionString::Id: - if (SuccessOrLog(data->GetString(attribStringBuffer, sizeof(attribStringBuffer)), "SoftwareVersionString")) + } + break; + case Clusters::BasicInformation::Attributes::SoftwareVersionString::Id: { + char softwareVersionStringBuffer[kBasicInformationAttributeBufSize]; + if (SuccessOrLog(data->GetString(softwareVersionStringBuffer, sizeof(softwareVersionStringBuffer)), + "SoftwareVersionString")) { - mCurrentDeviceData.softwareVersionString = std::string(attribStringBuffer); + mCurrentDeviceData.softwareVersionString = std::string(softwareVersionStringBuffer); } - break; + } + break; default: break; } From 32da304c5def29e9e1d323f20da7485da9dba23e Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Wed, 11 Dec 2024 08:25:42 +0100 Subject: [PATCH 3/3] Synchronize all required attributes --- .../admin/DeviceSynchronization.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/examples/fabric-sync/admin/DeviceSynchronization.cpp b/examples/fabric-sync/admin/DeviceSynchronization.cpp index 527ccfa631295a..05b16bd9f3bcaa 100644 --- a/examples/fabric-sync/admin/DeviceSynchronization.cpp +++ b/examples/fabric-sync/admin/DeviceSynchronization.cpp @@ -91,6 +91,14 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path, } } break; + case Clusters::BasicInformation::Attributes::VendorID::Id: { + uint32_t vendorId; + if (SuccessOrLog(data->Get(vendorId), "VendorID")) + { + mCurrentDeviceData.vendorId = static_cast(vendorId); + } + } + break; case Clusters::BasicInformation::Attributes::VendorName::Id: { char vendorNameBuffer[kBasicInformationAttributeBufSize]; if (SuccessOrLog(data->GetString(vendorNameBuffer, sizeof(vendorNameBuffer)), "VendorName")) @@ -99,6 +107,14 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path, } } break; + case Clusters::BasicInformation::Attributes::ProductID::Id: { + uint32_t productId; + if (SuccessOrLog(data->Get(productId), "ProductID")) + { + mCurrentDeviceData.productId = productId; + } + } + break; case Clusters::BasicInformation::Attributes::ProductName::Id: { char productNameBuffer[kBasicInformationAttributeBufSize]; if (SuccessOrLog(data->GetString(productNameBuffer, sizeof(productNameBuffer)), "ProductName")) @@ -124,6 +140,14 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path, } } break; + case Clusters::BasicInformation::Attributes::SoftwareVersion::Id: { + uint32_t softwareVersion; + if (SuccessOrLog(data->Get(softwareVersion), "SoftwareVersion")) + { + mCurrentDeviceData.softwareVersion = softwareVersion; + } + } + break; case Clusters::BasicInformation::Attributes::SoftwareVersionString::Id: { char softwareVersionStringBuffer[kBasicInformationAttributeBufSize]; if (SuccessOrLog(data->GetString(softwareVersionStringBuffer, sizeof(softwareVersionStringBuffer)),