diff --git a/src/app/DefaultAttributePersistenceProvider.cpp b/src/app/DefaultAttributePersistenceProvider.cpp index 9b7c3a4538912b..502b28e914d638 100644 --- a/src/app/DefaultAttributePersistenceProvider.cpp +++ b/src/app/DefaultAttributePersistenceProvider.cpp @@ -35,7 +35,8 @@ CHIP_ERROR DefaultAttributePersistenceProvider::WriteValue(const ConcreteAttribu { return CHIP_ERROR_BUFFER_TOO_SMALL; } - return mStorage->SyncSetKeyValue(key.AttributeValue(aPath), aValue.data(), static_cast(aValue.size())); + return mStorage->SyncSetKeyValue(key.AttributeValue(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId), aValue.data(), + static_cast(aValue.size())); } CHIP_ERROR DefaultAttributePersistenceProvider::ReadValue(const ConcreteAttributePath & aPath, @@ -45,7 +46,8 @@ CHIP_ERROR DefaultAttributePersistenceProvider::ReadValue(const ConcreteAttribut DefaultStorageKeyAllocator key; uint16_t size = static_cast(min(aValue.size(), static_cast(UINT16_MAX))); - ReturnErrorOnFailure(mStorage->SyncGetKeyValue(key.AttributeValue(aPath), aValue.data(), size)); + ReturnErrorOnFailure(mStorage->SyncGetKeyValue(key.AttributeValue(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId), + aValue.data(), size)); EmberAfAttributeType type = aMetadata->attributeType; if (emberAfIsStringAttributeType(type)) { diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index d5e18e69f702f0..38903219b75ab1 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -100,6 +100,7 @@ static_library("support") { "CHIPPlatformMemory.h", "CodeUtils.h", "DLLUtil.h", + "DefaultStorageKeyAllocator.h", "Defer.h", "ErrorStr.cpp", "ErrorStr.h", diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index 94b315b7e37c58..920e834bfdcd36 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -16,12 +16,14 @@ */ #pragma once -#include -#include #include +#include #include #include #include +#include +#include +#include #include namespace chip { @@ -93,11 +95,11 @@ class DefaultStorageKeyAllocator } const char * FabricKeyset(chip::FabricIndex fabric, uint16_t keyset) { return Format("f/%x/k/%x", fabric, keyset); } - const char * AttributeValue(const app::ConcreteAttributePath & aPath) + const char * AttributeValue(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId) { // Needs at most 26 chars: 6 for "g/a///", 4 for the endpoint id, 8 each // for the cluster and attribute ids. - return Format("g/a/%x/%" PRIx32 "/%" PRIx32, aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); + return Format("g/a/%x/%" PRIx32 "/%" PRIx32, endpointId, clusterId, attributeId); } // TODO: Should store fabric-specific parts of the binding list under keys