Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[app] Add option to disable Read Client #28050

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about actually removing mpActiveReadClientList too? @wqx6

{
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