From acea4646d980196f3298129d9fdef76238f2f238 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 14 Nov 2024 08:35:30 -0500 Subject: [PATCH] Move ember-specific attribute persistence providers into `src/util/persistence` (#36473) * Move persistence providers code into util since they depend on ember. Unit tests pass, will need to fix up apps. * Fix up more includes * Restyled by clang-format * Fix up qpg build * Also fix nrfconnect deferred attribute persistence use * Fix path * Add persistence to esp32 CMakeLists.txt * Update examples/lighting-app/qpg/BUILD.gn --------- Co-authored-by: Andrei Litvin Co-authored-by: Restyled.io --- .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + examples/bridge-app/esp32/main/CMakeLists.txt | 1 + examples/chef/esp32/main/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + .../lighting-app/esp32/main/CMakeLists.txt | 1 + .../lighting-app/nrfconnect/CMakeLists.txt | 1 + .../lighting-app/nrfconnect/main/AppTask.cpp | 2 +- examples/lighting-app/qpg/BUILD.gn | 1 + examples/lighting-app/qpg/src/AppTask.cpp | 2 +- .../lit-icd-app/esp32/main/CMakeLists.txt | 1 + examples/lock-app/esp32/main/CMakeLists.txt | 2 + .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + .../thread-br-app/esp32/main/CMakeLists.txt | 1 + src/BUILD.gn | 5 +- src/app/BUILD.gn | 18 ++++--- src/app/SafeAttributePersistenceProvider.h | 5 +- src/app/chip_data_model.cmake | 1 + src/app/chip_data_model.gni | 1 + .../mode-base-server/mode-base-server.h | 2 +- src/app/server/BUILD.gn | 1 + src/app/server/Server.h | 6 ++- src/app/tests/BUILD.gn | 1 - src/app/util/attribute-storage.cpp | 2 +- .../AttributePersistenceProvider.h | 0 src/app/util/persistence/BUILD.gn | 47 +++++++++++++++++++ .../DefaultAttributePersistenceProvider.cpp | 2 +- .../DefaultAttributePersistenceProvider.h | 2 +- .../DeferredAttributePersistenceProvider.cpp | 2 +- .../DeferredAttributePersistenceProvider.h | 2 +- src/app/util/persistence/tests/BUILD.gn | 34 ++++++++++++++ .../TestAttributePersistenceProvider.cpp | 2 +- 35 files changed, 133 insertions(+), 20 deletions(-) rename src/app/{ => util/persistence}/AttributePersistenceProvider.h (100%) create mode 100644 src/app/util/persistence/BUILD.gn rename src/app/{ => util/persistence}/DefaultAttributePersistenceProvider.cpp (98%) rename src/app/{ => util/persistence}/DefaultAttributePersistenceProvider.h (97%) rename src/app/{ => util/persistence}/DeferredAttributePersistenceProvider.cpp (97%) rename src/app/{ => util/persistence}/DeferredAttributePersistenceProvider.h (98%) create mode 100644 src/app/util/persistence/tests/BUILD.gn rename src/app/{ => util/persistence}/tests/TestAttributePersistenceProvider.cpp (99%) diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 31292543ca5f50..c35efdf4def94e 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -45,6 +45,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/air-quality-server" diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index f82f301e3ae362..680d4a9c02636e 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -38,6 +38,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server" diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt index 3330f6971b68cd..9d34b44a92f0e1 100644 --- a/examples/bridge-app/esp32/main/CMakeLists.txt +++ b/examples/bridge-app/esp32/main/CMakeLists.txt @@ -23,6 +23,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index 5c8963f7735f6d..a7905ff214c584 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -79,6 +79,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" ) diff --git a/examples/energy-management-app/esp32/main/CMakeLists.txt b/examples/energy-management-app/esp32/main/CMakeLists.txt index e5459616238d3d..06623d3faf839d 100644 --- a/examples/energy-management-app/esp32/main/CMakeLists.txt +++ b/examples/energy-management-app/esp32/main/CMakeLists.txt @@ -44,6 +44,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/light-switch-app/esp32/main/CMakeLists.txt b/examples/light-switch-app/esp32/main/CMakeLists.txt index b4b6f5946eb2f9..92be83565a138e 100644 --- a/examples/light-switch-app/esp32/main/CMakeLists.txt +++ b/examples/light-switch-app/esp32/main/CMakeLists.txt @@ -30,6 +30,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index d3dc3421cc105f..1ad5bc1aa37c9e 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -34,6 +34,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 59bf2f26bed466..dd5b65afe632df 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -51,6 +51,7 @@ target_sources(app PRIVATE main/AppTask.cpp main/main.cpp main/ZclCallbacks.cpp + ${CHIP_ROOT}/src/app/util/persistence/DeferredAttributePersistenceProvider.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp ${NRFCONNECT_COMMON}/util/PWMDevice.cpp) diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 88964d9aa1d3c8..014849780caf06 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -26,13 +26,13 @@ #include #include -#include #include #include #include #include #include #include +#include #include #include #include diff --git a/examples/lighting-app/qpg/BUILD.gn b/examples/lighting-app/qpg/BUILD.gn index 886c8aa313d097..b4a2998f02dc7f 100644 --- a/examples/lighting-app/qpg/BUILD.gn +++ b/examples/lighting-app/qpg/BUILD.gn @@ -66,6 +66,7 @@ qpg_executable("lighting_app") { "${chip_root}/examples/lighting-app/lighting-common:color-format", "${chip_root}/examples/lighting-app/qpg/zap/", "${chip_root}/examples/providers:device_info_provider", + "${chip_root}/src/app/util/persistence:deferred", "${chip_root}/src/lib", "${chip_root}/src/platform/logging:default", "${chip_root}/src/setup_payload", diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index 90f2e30ecb03c5..0c09e97a6a5681 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include diff --git a/examples/lit-icd-app/esp32/main/CMakeLists.txt b/examples/lit-icd-app/esp32/main/CMakeLists.txt index 5f2850feff98b6..4d8fe2ab4bb163 100644 --- a/examples/lit-icd-app/esp32/main/CMakeLists.txt +++ b/examples/lit-icd-app/esp32/main/CMakeLists.txt @@ -29,6 +29,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index 5c5f46abdd1860..028a92ae8dbd27 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -49,6 +49,7 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" @@ -162,6 +163,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt index 41acd9e9316e00..d651ac77065803 100644 --- a/examples/ota-provider-app/esp32/main/CMakeLists.txt +++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt @@ -26,6 +26,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index fbda70f2cec48f..2688fea4977eab 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -31,6 +31,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index 8bc94f7b97969a..8036700df626a0 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -29,6 +29,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" diff --git a/examples/thread-br-app/esp32/main/CMakeLists.txt b/examples/thread-br-app/esp32/main/CMakeLists.txt index c0cb1234b0cca3..c1f82285e4ac7f 100644 --- a/examples/thread-br-app/esp32/main/CMakeLists.txt +++ b/examples/thread-br-app/esp32/main/CMakeLists.txt @@ -30,6 +30,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util/persistence" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/icd/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" diff --git a/src/BUILD.gn b/src/BUILD.gn index 722e0c8278582a..3676c92c97e8a4 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -100,7 +100,10 @@ if (chip_build_tests) { } if (chip_device_platform != "efr32") { - tests += [ "${chip_root}/src/app/tests" ] + tests += [ + "${chip_root}/src/app/tests", + "${chip_root}/src/app/util/persistence/tests", + ] # Disabled for EFR32 because _open is not implemented. # https://github.com/project-chip/connectedhomeip/issues/35624 diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index b0cde0960c9013..8b008c4e9b238b 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -389,6 +389,18 @@ source_set("command-handler-impl") { ] } +source_set("attribute-persistence") { + sources = [ "SafeAttributePersistenceProvider.h" ] + + public_deps = [ + ":paths", + "${chip_root}/src/app/data-model:nullable", + "${chip_root}/src/app/util:types", + "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:span", + ] +} + # Note to developpers, instead of continuously adding files in the app librabry, it is recommand to create smaller source_sets that app can depend on. # This way, we can have a better understanding of dependencies and other componenets can depend on the different source_sets without needing to depend on the entire app library. static_library("app") { @@ -398,15 +410,10 @@ static_library("app") { "AttributePathExpandIterator.cpp", "AttributePathExpandIterator.h", "AttributePathExpandIterator.h", - "AttributePersistenceProvider.h", "ChunkedWriteCallback.cpp", "ChunkedWriteCallback.h", "CommandResponseHelper.h", "CommandResponseSender.cpp", - "DefaultAttributePersistenceProvider.cpp", - "DefaultAttributePersistenceProvider.h", - "DeferredAttributePersistenceProvider.cpp", - "DeferredAttributePersistenceProvider.h", "EventLogging.h", "EventManagement.cpp", "EventManagement.h", @@ -416,7 +423,6 @@ static_library("app") { "GenericEventManagementTestEventTriggerHandler.h", "OTAUserConsentCommon.h", "ReadHandler.cpp", - "SafeAttributePersistenceProvider.h", "TimerDelegates.cpp", "TimerDelegates.h", "WriteHandler.cpp", diff --git a/src/app/SafeAttributePersistenceProvider.h b/src/app/SafeAttributePersistenceProvider.h index 8d11d95d47b02d..b1e7148c79b1bb 100644 --- a/src/app/SafeAttributePersistenceProvider.h +++ b/src/app/SafeAttributePersistenceProvider.h @@ -18,12 +18,13 @@ #include #include #include -#include -#include #include #include #include +#include +#include + namespace chip { namespace app { diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index 75e2d8a349668a..0f628428952da8 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -164,6 +164,7 @@ function(chip_configure_data_model APP_TARGET) ${CHIP_APP_BASE_DIR}/util/generic-callback-stubs.cpp ${CHIP_APP_BASE_DIR}/util/privilege-storage.cpp ${CHIP_APP_BASE_DIR}/util/util.cpp + ${CHIP_APP_BASE_DIR}/util/persistence/DefaultAttributePersistenceProvider.cpp ${CODEGEN_DATA_MODEL_SOURCES} ${APP_GEN_FILES} ${APP_TEMPLATES_GEN_FILES} diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 9f4ed594ccb912..3be8df5710616c 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -460,6 +460,7 @@ template("chip_data_model") { "${chip_root}/src/app/common:cluster-objects", "${chip_root}/src/app/common:enums", "${chip_root}/src/app/util:types", + "${chip_root}/src/app/util/persistence", "${chip_root}/src/controller", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", diff --git a/src/app/clusters/mode-base-server/mode-base-server.h b/src/app/clusters/mode-base-server/mode-base-server.h index f787e9fc19f11f..06c22f3a42cd3e 100644 --- a/src/app/clusters/mode-base-server/mode-base-server.h +++ b/src/app/clusters/mode-base-server/mode-base-server.h @@ -20,8 +20,8 @@ #include "mode-base-cluster-objects.h" #include -#include #include +#include #include namespace chip { diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn index 42c4caf05cad78..43c970843ba66d 100644 --- a/src/app/server/BUILD.gn +++ b/src/app/server/BUILD.gn @@ -58,6 +58,7 @@ static_library("server") { "${chip_root}/src/app:test-event-trigger", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/app/icd/server:observer", + "${chip_root}/src/app/util/persistence", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/dnssd", "${chip_root}/src/lib/dnssd:naming", diff --git a/src/app/server/Server.h b/src/app/server/Server.h index 2f61197fcee2dd..fc6f7ac10750d3 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -81,6 +80,11 @@ #endif // CHIP_CONFIG_ENABLE_ICD_CIP #endif // CHIP_CONFIG_ENABLE_ICD_SERVER +// TODO: https://github.com/project-chip/connectedhomeip/issues/36472 +// this strongly couples Server to Ember and this dependency should +// be removed +#include + namespace chip { inline constexpr size_t kMaxBlePendingPackets = 1; diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 6f55c7bb6fafd1..105d09f7ad6fc8 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -198,7 +198,6 @@ chip_test_suite("tests") { "TestAttributeAccessInterfaceCache.cpp", "TestAttributePathExpandIterator.cpp", "TestAttributePathParams.cpp", - "TestAttributePersistenceProvider.cpp", "TestAttributeValueDecoder.cpp", "TestAttributeValueEncoder.cpp", "TestBasicCommandPathRegistry.cpp", diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 51c01c7e43fa80..4d9cc2368f6900 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -28,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/app/AttributePersistenceProvider.h b/src/app/util/persistence/AttributePersistenceProvider.h similarity index 100% rename from src/app/AttributePersistenceProvider.h rename to src/app/util/persistence/AttributePersistenceProvider.h diff --git a/src/app/util/persistence/BUILD.gn b/src/app/util/persistence/BUILD.gn new file mode 100644 index 00000000000000..dbc8dbe31b0c58 --- /dev/null +++ b/src/app/util/persistence/BUILD.gn @@ -0,0 +1,47 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +source_set("persistence") { + sources = [ + "AttributePersistenceProvider.h", + "DefaultAttributePersistenceProvider.cpp", + "DefaultAttributePersistenceProvider.h", + ] + + public_deps = [ + "${chip_root}/src/app:attribute-persistence", + "${chip_root}/src/app:paths", + "${chip_root}/src/app/util:types", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:span", + ] +} + +source_set("deferred") { + sources = [ + "DeferredAttributePersistenceProvider.cpp", + "DeferredAttributePersistenceProvider.h", + ] + + public_deps = [ + ":persistence", + "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:span", + "${chip_root}/src/platform", + "${chip_root}/src/system", + ] +} diff --git a/src/app/DefaultAttributePersistenceProvider.cpp b/src/app/util/persistence/DefaultAttributePersistenceProvider.cpp similarity index 98% rename from src/app/DefaultAttributePersistenceProvider.cpp rename to src/app/util/persistence/DefaultAttributePersistenceProvider.cpp index 40ce5213628944..70488e80e7e1d7 100644 --- a/src/app/DefaultAttributePersistenceProvider.cpp +++ b/src/app/util/persistence/DefaultAttributePersistenceProvider.cpp @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include -#include #include #include #include diff --git a/src/app/DefaultAttributePersistenceProvider.h b/src/app/util/persistence/DefaultAttributePersistenceProvider.h similarity index 97% rename from src/app/DefaultAttributePersistenceProvider.h rename to src/app/util/persistence/DefaultAttributePersistenceProvider.h index 3e18808f366d37..a4796f2b63b11d 100644 --- a/src/app/DefaultAttributePersistenceProvider.h +++ b/src/app/util/persistence/DefaultAttributePersistenceProvider.h @@ -15,8 +15,8 @@ */ #pragma once -#include #include +#include #include #include diff --git a/src/app/DeferredAttributePersistenceProvider.cpp b/src/app/util/persistence/DeferredAttributePersistenceProvider.cpp similarity index 97% rename from src/app/DeferredAttributePersistenceProvider.cpp rename to src/app/util/persistence/DeferredAttributePersistenceProvider.cpp index 26adcb18c8dcf7..6b1822f29257ac 100644 --- a/src/app/DeferredAttributePersistenceProvider.cpp +++ b/src/app/util/persistence/DeferredAttributePersistenceProvider.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include diff --git a/src/app/DeferredAttributePersistenceProvider.h b/src/app/util/persistence/DeferredAttributePersistenceProvider.h similarity index 98% rename from src/app/DeferredAttributePersistenceProvider.h rename to src/app/util/persistence/DeferredAttributePersistenceProvider.h index 6c641dc17d4400..592408b96b39ac 100644 --- a/src/app/DeferredAttributePersistenceProvider.h +++ b/src/app/util/persistence/DeferredAttributePersistenceProvider.h @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include #include diff --git a/src/app/util/persistence/tests/BUILD.gn b/src/app/util/persistence/tests/BUILD.gn new file mode 100644 index 00000000000000..7a0bd524305623 --- /dev/null +++ b/src/app/util/persistence/tests/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") + +import("${chip_root}/build/chip/chip_test_suite.gni") + +chip_test_suite("tests") { + output_name = "libAppUtilPersistenceTests" + + test_sources = [ "TestAttributePersistenceProvider.cpp" ] + + cflags = [ "-Wconversion" ] + + public_deps = [ + "${chip_root}/src/app/common:cluster-objects", + "${chip_root}/src/app/util/persistence", + "${chip_root}/src/lib/core:string-builder-adapters", + "${chip_root}/src/lib/support:testing", + ] +} diff --git a/src/app/tests/TestAttributePersistenceProvider.cpp b/src/app/util/persistence/tests/TestAttributePersistenceProvider.cpp similarity index 99% rename from src/app/tests/TestAttributePersistenceProvider.cpp rename to src/app/util/persistence/tests/TestAttributePersistenceProvider.cpp index 1b8c7ee3d3872c..1324f37a7138c3 100644 --- a/src/app/tests/TestAttributePersistenceProvider.cpp +++ b/src/app/util/persistence/tests/TestAttributePersistenceProvider.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include