Skip to content

Commit

Permalink
[app] Add option to disable Read Client (#28050)
Browse files Browse the repository at this point in the history
* Add option to disable Read Client

* Restyled by gn

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 8, 2024
1 parent 6e1e069 commit 2396305
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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}",
]
}

Expand Down Expand Up @@ -178,7 +180,6 @@ static_library("app") {
"OperationalSessionSetup.cpp",
"OperationalSessionSetup.h",
"OperationalSessionSetupPool.h",
"ReadClient.cpp",
"ReadHandler.cpp",
"RequiredPrivilege.cpp",
"RequiredPrivilege.h",
Expand Down Expand Up @@ -206,6 +207,10 @@ static_library("app") {
]
}

if (chip_enable_read_client) {
sources += [ "ReadClient.cpp" ]
}

public_deps = [
":app_config",
"${chip_root}/src/access",
Expand Down
5 changes: 4 additions & 1 deletion src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down

0 comments on commit 2396305

Please sign in to comment.