From f46973db3540df3eb89395c46b1fb20e1fcd0d89 Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Mon, 17 Jul 2023 19:22:17 +0800 Subject: [PATCH 1/2] Add option to disable Read Client --- config/esp32/components/chip/CMakeLists.txt | 4 ++++ config/esp32/components/chip/Kconfig | 6 ++++++ examples/lighting-app/esp32/sdkconfig.defaults | 3 +++ src/app/BUILD.gn | 9 ++++++++- src/app/InteractionModelEngine.cpp | 5 ++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index d35791cf1ed3c0..f8c6e839bffbb5 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -124,6 +124,10 @@ if(CONFIG_DISABLE_IPV4) chip_gn_arg_append("chip_inet_config_enable_ipv4" "false") endif() +if(CONFIG_DISABLE_READ_CLIENT) + chip_gn_arg_append("chip_enable_read_client" "false") +endif() + if(CHIP_CODEGEN_PREGEN_DIR) chip_gn_arg_append("chip_code_pre_generated_directory" "\"${CHIP_CODEGEN_PREGEN_DIR}\"") endif() diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 99de12afa97e6e..5c871c2d043a30 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -108,6 +108,12 @@ menu "CHIP Core" help Matter spec is based on IPv6 communication only. Enabling this option may save some flash/ram. + config DISABLE_READ_CLIENT + bool "Disable read client in Interaction Model" + default n + help + Some device types don't require the read client. Enabling this option may save some flash/ram. + config BUILD_CHIP_TESTS bool "Build CHIP tests" default n diff --git a/examples/lighting-app/esp32/sdkconfig.defaults b/examples/lighting-app/esp32/sdkconfig.defaults index 59c0af656896f0..f87a164ae41dd2 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults +++ b/examples/lighting-app/esp32/sdkconfig.defaults @@ -58,3 +58,6 @@ CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y + +# Disable Read Client +CONFIG_DISABLE_READ_CLIENT=y diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 7f2c4d82280392..ace8b6acae23e8 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -43,6 +43,7 @@ declare_args() { chip_im_force_fabric_quota_check = false enable_eventlist_attribute = true + chip_enable_read_client = true } buildconfig_header("app_buildconfig") { @@ -57,6 +58,7 @@ buildconfig_header("app_buildconfig") { "CHIP_CONFIG_PERSIST_SUBSCRIPTIONS=${chip_persist_subscriptions}", "CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE=${enable_eventlist_attribute}", "CHIP_CONFIG_ENABLE_ICD_SERVER=${chip_enable_icd_server}", + "CHIP_CONFIG_ENABLE_READ_CLIENT=${chip_enable_read_client}", ] } @@ -178,7 +180,6 @@ static_library("app") { "OperationalSessionSetup.cpp", "OperationalSessionSetup.h", "OperationalSessionSetupPool.h", - "ReadClient.cpp", "ReadHandler.cpp", "RequiredPrivilege.cpp", "RequiredPrivilege.h", @@ -206,6 +207,12 @@ static_library("app") { ] } + if (chip_enable_read_client) { + sources += [ + "ReadClient.cpp", + ] + } + public_deps = [ ":app_config", "${chip_root}/src/access", diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 6c32952135c902..32d7a2c721a8e7 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -878,10 +878,12 @@ CHIP_ERROR InteractionModelEngine::OnMessageReceived(Messaging::ExchangeContext status = OnReadInitialRequest(apExchangeContext, aPayloadHeader, std::move(aPayload), ReadHandler::InteractionType::Subscribe); } +#if CHIP_CONFIG_ENABLE_READ_CLIENT else if (aPayloadHeader.HasMessageType(Protocols::InteractionModel::MsgType::ReportData)) { status = OnUnsolicitedReportData(apExchangeContext, aPayloadHeader, std::move(aPayload)); } +#endif // CHIP_CONFIG_ENABLE_READ_CLIENT else if (aPayloadHeader.HasMessageType(MsgType::TimedRequest)) { OnTimedRequest(apExchangeContext, aPayloadHeader, std::move(aPayload), status); @@ -1723,7 +1725,7 @@ void InteractionModelEngine::OnFabricRemoved(const FabricTable & fabricTable, Fa return Loop::Continue; }); - +#if CHIP_CONFIG_ENABLE_READ_CLIENT for (auto * readClient = mpActiveReadClientList; readClient != nullptr; readClient = readClient->GetNextClient()) { if (readClient->GetFabricIndex() == fabricIndex) @@ -1732,6 +1734,7 @@ void InteractionModelEngine::OnFabricRemoved(const FabricTable & fabricTable, Fa readClient->Close(CHIP_ERROR_IM_FABRIC_DELETED, false); } } +#endif // CHIP_CONFIG_ENABLE_READ_CLIENT for (auto & handler : mWriteHandlers) { From a390f1feb80d7edb36bd32ff128d75bbc30992f5 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 19 Jul 2023 11:54:44 +0000 Subject: [PATCH 2/2] Restyled by gn --- src/app/BUILD.gn | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index ace8b6acae23e8..ab797ee12385fc 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -208,9 +208,7 @@ static_library("app") { } if (chip_enable_read_client) { - sources += [ - "ReadClient.cpp", - ] + sources += [ "ReadClient.cpp" ] } public_deps = [