diff --git a/examples/laundry-washer-app/nxp/common/main/AppTask.cpp b/examples/laundry-washer-app/nxp/common/main/AppTask.cpp index fb37f4f13a78f5..5d82dcf92ef7b3 100644 --- a/examples/laundry-washer-app/nxp/common/main/AppTask.cpp +++ b/examples/laundry-washer-app/nxp/common/main/AppTask.cpp @@ -37,7 +37,14 @@ using namespace chip::Shell; using namespace chip; using namespace chip::app::Clusters; +/* + * Enable temperature level delegate of temperature control cluster + */ app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; +void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint) +{ + TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); +} #ifdef ENABLE_CHIP_SHELL const static std::map map_cmd_errstate{ @@ -119,8 +126,6 @@ void LaundryWasherApp::AppTask::PreInitMatterStack() void LaundryWasherApp::AppTask::PostInitMatterStack() { chip::app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&chip::NXP::App::GetICDUtil()); - - app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); } void LaundryWasherApp::AppTask::AppMatter_RegisterCustomCliCommands() diff --git a/examples/laundry-washer-app/nxp/common/main/DeviceCallbacks.cpp b/examples/laundry-washer-app/nxp/common/main/DeviceCallbacks.cpp index 0d20cf015a7954..8d5170c1e890ed 100644 --- a/examples/laundry-washer-app/nxp/common/main/DeviceCallbacks.cpp +++ b/examples/laundry-washer-app/nxp/common/main/DeviceCallbacks.cpp @@ -58,14 +58,6 @@ void OnTriggerEffect(::Identify * identify) } } -Identify gIdentify0 = { - chip::EndpointId{ 1 }, - [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, - [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); }, - chip::app::Clusters::Identify::IdentifyTypeEnum::kNone, - OnTriggerEffect, -}; - Identify gIdentify1 = { chip::EndpointId{ 1 }, [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, diff --git a/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp b/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp new file mode 100644 index 00000000000000..2dedf4c1f8c69b --- /dev/null +++ b/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp @@ -0,0 +1,104 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ +#include +#include + +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::LaundryWasherMode; +using chip::Protocols::InteractionModel::Status; +template +using List = chip::app::DataModel::List; +using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type; + +static LaundryWasherModeDelegate * gLaundryWasherModeDelegate = nullptr; +static ModeBase::Instance * gLaundryWasherModeInstance = nullptr; + +CHIP_ERROR LaundryWasherModeDelegate::Init() +{ + return CHIP_NO_ERROR; +} + +void LaundryWasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::ChangeToModeResponse::Type & response) +{ + response.status = to_underlying(ModeBase::StatusCode::kSuccess); +} + +CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) +{ + if (modeIndex >= ArraySize(kModeOptions)) + { + return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + } + return chip::CopyCharSpanToMutableCharSpan(kModeOptions[modeIndex].label, label); +} + +CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) +{ + if (modeIndex >= ArraySize(kModeOptions)) + { + return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + } + value = kModeOptions[modeIndex].mode; + return CHIP_NO_ERROR; +} + +CHIP_ERROR LaundryWasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) +{ + if (modeIndex >= ArraySize(kModeOptions)) + { + return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; + } + + if (tags.size() < kModeOptions[modeIndex].modeTags.size()) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + + std::copy(kModeOptions[modeIndex].modeTags.begin(), kModeOptions[modeIndex].modeTags.end(), tags.begin()); + tags.reduce_size(kModeOptions[modeIndex].modeTags.size()); + + return CHIP_NO_ERROR; +} + +ModeBase::Instance * LaundryWasherMode::Instance() +{ + return gLaundryWasherModeInstance; +} + +void LaundryWasherMode::Shutdown() +{ + if (gLaundryWasherModeInstance != nullptr) + { + delete gLaundryWasherModeInstance; + gLaundryWasherModeInstance = nullptr; + } + if (gLaundryWasherModeDelegate != nullptr) + { + delete gLaundryWasherModeDelegate; + gLaundryWasherModeDelegate = nullptr; + } +} + +void emberAfLaundryWasherModeClusterInitCallback(chip::EndpointId endpointId) +{ + VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. + VerifyOrDie(gLaundryWasherModeDelegate == nullptr && gLaundryWasherModeInstance == nullptr); + gLaundryWasherModeDelegate = new LaundryWasherMode::LaundryWasherModeDelegate; + gLaundryWasherModeInstance = new ModeBase::Instance(gLaundryWasherModeDelegate, 0x1, LaundryWasherMode::Id, 0); + gLaundryWasherModeInstance->Init(); +} diff --git a/examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn b/examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn index f487ff415f1330..580a3ad556702b 100644 --- a/examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn +++ b/examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn @@ -66,7 +66,8 @@ rt_sdk("sdk") { defines = [] # To be moved, temporary mbedtls config fix to build app with factory data - if (chip_enable_secure_dac_private_key_storage == 1) { + if (chip_enable_secure_dac_private_key_storage || + chip_enable_secure_whole_factory_data) { defines += [ "MBEDTLS_NIST_KW_C", "MBEDTLS_PSA_CRYPTO_CLIENT", @@ -150,8 +151,12 @@ rt_executable("laundry-washer") { "../../common/main/main.cpp", ] - if (chip_enable_secure_dac_private_key_storage == 1) { + if (chip_enable_secure_dac_private_key_storage || + chip_enable_secure_whole_factory_data) { sources += [ "${chip_root}/examples/platform/nxp/${nxp_platform}/factory_data/source/AppFactoryDataExample.cpp" ] + if (chip_enable_secure_whole_factory_data) { + defines += [ "ENABLE_SECURE_WHOLE_FACTORY_DATA" ] + } } else { sources += [ "${common_example_dir}/factory_data/source/AppFactoryDataDefaultImpl.cpp", @@ -186,10 +191,10 @@ rt_executable("laundry-washer") { sources += [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp", - "${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp", + "../../common/main/laundry-washer-mode.cpp", "../../common/main/operational-state-delegate-impl.cpp", ] diff --git a/examples/laundry-washer-app/nxp/rt/rw61x/args.gni b/examples/laundry-washer-app/nxp/rt/rw61x/args.gni index c2d91a5db7bae7..d65714c9287ce5 100644 --- a/examples/laundry-washer-app/nxp/rt/rw61x/args.gni +++ b/examples/laundry-washer-app/nxp/rt/rw61x/args.gni @@ -17,3 +17,9 @@ import("//build_overrides/chip.gni") # SDK target definitions nxp_sdk_target = get_label_info(":sdk", "label_no_toolchain") nxp_sdk_driver_target = get_label_info(":sdk_driver", "label_no_toolchain") + +# ICDM +chip_enable_icd_server = true +chip_persist_subscriptions = true +chip_subscription_timeout_resumption = true +chip_enable_icd_checkin = true diff --git a/examples/platform/nxp/common/diagnostic_logs/BUILD.gn b/examples/platform/nxp/common/diagnostic_logs/BUILD.gn deleted file mode 100644 index 04d864753a6633..00000000000000 --- a/examples/platform/nxp/common/diagnostic_logs/BUILD.gn +++ /dev/null @@ -1,24 +0,0 @@ -# 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("nxp_diagnostic_logs") { - sources = [ - "DiagnosticLogsProviderDelegateImpl.cpp", - "DiagnosticLogsProviderDelegateImpl.h", - ] - - include_dirs = [ "${chip_root}/src" ] -} diff --git a/examples/platform/nxp/common/matter_cli/source/AppCLIBase.cpp b/examples/platform/nxp/common/matter_cli/source/AppCLIBase.cpp index 9bd53ff21cbd4a..f6256040dca767 100644 --- a/examples/platform/nxp/common/matter_cli/source/AppCLIBase.cpp +++ b/examples/platform/nxp/common/matter_cli/source/AppCLIBase.cpp @@ -24,6 +24,15 @@ #include #include +#if (CHIP_DEVICE_CONFIG_ENABLE_WPA && CHIP_ENABLE_OPENTHREAD) + +#include + +extern "C" { +#include "addons_cli.h" +} +#endif + #define MATTER_CLI_LOG(message) (chip::Shell::streamer_printf(chip::Shell::streamer_get(), message)) static CHIP_ERROR commissioningManager(int argc, char * argv[]) @@ -80,6 +89,9 @@ void chip::NXP::App::AppCLIBase::RegisterDefaultCommands(void) /* Register common shell commands */ cmd_misc_init(); cmd_otcli_init(); +#if (CHIP_DEVICE_CONFIG_ENABLE_WPA && CHIP_ENABLE_OPENTHREAD) + otAppCliAddonsInit(chip::DeviceLayer::ThreadStackMgrImpl().OTInstance()); +#endif #if CHIP_SHELL_ENABLE_CMD_SERVER cmd_app_server_init(); #endif /* CHIP_SHELL_ENABLE_CMD_SERVER */ diff --git a/examples/thermostat/nxp/common/main/ZclCallbacks.cpp b/examples/thermostat/nxp/common/main/ZclCallbacks.cpp index d4be6f1eb89a8c..645c9fd86bbc6e 100644 --- a/examples/thermostat/nxp/common/main/ZclCallbacks.cpp +++ b/examples/thermostat/nxp/common/main/ZclCallbacks.cpp @@ -26,8 +26,17 @@ #include #include +#if CONFIG_DIAG_LOGS_DEMO +#include +#include +#endif + using namespace ::chip; +#if CONFIG_DIAG_LOGS_DEMO +using namespace ::chip::app::Clusters::DiagnosticLogs; +#endif + void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & path, uint8_t type, uint16_t size, uint8_t * value) { chip::DeviceManager::CHIPDeviceManagerCallbacks * cb = @@ -38,3 +47,11 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & cb->PostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId, type, size, value); } } + +#if CONFIG_DIAG_LOGS_DEMO +void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint) +{ + auto & logProvider = LogProvider::GetInstance(); + DiagnosticLogsServer::Instance().SetDiagnosticLogsProviderDelegate(endpoint, &logProvider); +} +#endif diff --git a/examples/thermostat/nxp/rt/rw61x/BUILD.gn b/examples/thermostat/nxp/rt/rw61x/BUILD.gn index 711ebf0d655f20..30af1be0e99a38 100644 --- a/examples/thermostat/nxp/rt/rw61x/BUILD.gn +++ b/examples/thermostat/nxp/rt/rw61x/BUILD.gn @@ -47,6 +47,8 @@ declare_args() { # Setup discriminator as argument setup_discriminator = 3840 + + chip_with_diag_logs_demo = true } example_platform_dir = @@ -66,7 +68,8 @@ rt_sdk("sdk") { defines = [] # To be moved, temporary mbedtls config fix to build app with factory data - if (chip_enable_secure_dac_private_key_storage == 1) { + if (chip_enable_secure_dac_private_key_storage || + chip_enable_secure_whole_factory_data) { defines += [ "MBEDTLS_NIST_KW_C", "MBEDTLS_PSA_CRYPTO_CLIENT", @@ -127,6 +130,13 @@ rt_executable("thermostat") { defines += [ "CONFIG_NET_L2_OPENTHREAD=1" ] } + if (chip_with_diag_logs_demo) { + defines += [ + "CONFIG_DIAG_LOGS_DEMO=1", + "CHIP_DEVICE_CONFIG_MAX_DIAG_LOG_SIZE=1024", + ] + } + include_dirs = [ "../../common/main/include", "../../common/main", @@ -146,8 +156,23 @@ rt_executable("thermostat") { "../../common/main/main.cpp", ] - if (chip_enable_secure_dac_private_key_storage == 1) { + if (chip_with_diag_logs_demo) { + include_dirs += [ + "${common_example_dir}/diagnostic_logs/include", + "${chip_root}", + ] + sources += [ + "${common_example_dir}/diagnostic_logs/source/DiagnosticLogsDemo.cpp", + "${common_example_dir}/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp", + ] + } + + if (chip_enable_secure_dac_private_key_storage || + chip_enable_secure_whole_factory_data) { sources += [ "${chip_root}/examples/platform/nxp/${nxp_platform}/factory_data/source/AppFactoryDataExample.cpp" ] + if (chip_enable_secure_whole_factory_data) { + defines += [ "ENABLE_SECURE_WHOLE_FACTORY_DATA" ] + } } else { sources += [ "${common_example_dir}/factory_data/source/AppFactoryDataDefaultImpl.cpp",