From 8126bbd25626e0305dd514e9857d4eed349c8b6b Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 6 Dec 2024 12:10:37 +0100 Subject: [PATCH] [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; }