Skip to content

Commit

Permalink
[NXP][rw61x] Diagnostic log, factory data storage, ICD, fixes (#35576)
Browse files Browse the repository at this point in the history
* [NXP][cli][common] Enabled lwip and ephemeral key CLI addons in Matter shell

(cherry picked from commit 01477f70a674691aa3f8957df09955ad94db4372)

* [NXP][examples][common]Add diagnostic logs support for thermostat app

Signed-off-by: Martin Girardot <[email protected]>
(cherry picked from commit 278973079fee7357c0d60b2cf2d10730c82e4497)

* [NXP][examples][laundry-washer] Fix Matter 1.3 certifiction TC-TCTL-3.3 case that SupportedTemperatureLevel should not be empty

Signed-off-by: Chin-Ran Lo <[email protected]>
(cherry picked from commit c46f6ceb2bc2c6708ba62663ab53a86215691052)

* [NXP][examples][common] Fix laundry-washer app Identify cluster issue on endepoint 0

Signed-off-by: Chin-Ran Lo <[email protected]>
(cherry picked from commit 3f2d5f7cafce98761393f1db17f46c9590bb600a)

* [NXP][examples][common] Add laundry wahser mode file

Signed-off-by: Martin Girardot <[email protected]>
(cherry picked from commit a73da0d7e757b1b908470a3136761de58b9de08a)

* [NXP][examples][rw61x] update laundry washer mode file path, add icd support

Signed-off-by: Martin Girardot <[email protected]>
(cherry picked from commit 1f2b75325595951d389403d82180dd74152a85dc)

* [NXP][examples][rw61x] Enable Disgnostic log for thermostat app

Signed-off-by: Martin Girardot <[email protected]>
(cherry picked from commit c10f479ab9bff6b16a595448c3c03ced17f4d725)

* [NXP][examples][rw61x] Update thermostat and laundry washer example for new factory data protection option

Signed-off-by: Martin Girardot <[email protected]>

* Restyled by clang-format

* Restyled by gn

* [NXP] fix PR comments: spelling, delete identify on endpoint 0

Signed-off-by: Martin Girardot <[email protected]>

---------

Signed-off-by: Martin Girardot <[email protected]>
Co-authored-by: Marius Preda <[email protected]>
Co-authored-by: Chin-Ran Lo <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
4 people authored Sep 18, 2024
1 parent e6a6425 commit 1d6b0a5
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 39 deletions.
9 changes: 7 additions & 2 deletions examples/laundry-washer-app/nxp/common/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, uint8_t> map_cmd_errstate{
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"); },
Expand Down
104 changes: 104 additions & 0 deletions examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp
Original file line number Diff line number Diff line change
@@ -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 <app-common/zap-generated/attributes/Accessors.h>
#include <laundry-washer-mode.h>

using namespace chip::app::Clusters;
using namespace chip::app::Clusters::LaundryWasherMode;
using chip::Protocols::InteractionModel::Status;
template <typename T>
using List = chip::app::DataModel::List<T>;
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<ModeTagStructType> & 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();
}
11 changes: 8 additions & 3 deletions examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
]

Expand Down
6 changes: 6 additions & 0 deletions examples/laundry-washer-app/nxp/rt/rw61x/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 0 additions & 24 deletions examples/platform/nxp/common/diagnostic_logs/BUILD.gn

This file was deleted.

12 changes: 12 additions & 0 deletions examples/platform/nxp/common/matter_cli/source/AppCLIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
#include <lib/shell/Engine.h>
#include <platform/CHIPDeviceLayer.h>

#if (CHIP_DEVICE_CONFIG_ENABLE_WPA && CHIP_ENABLE_OPENTHREAD)

#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h>

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[])
Expand Down Expand Up @@ -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 */
Expand Down
17 changes: 17 additions & 0 deletions examples/thermostat/nxp/common/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@
#include <app/ConcreteAttributePath.h>
#include <app/util/af-types.h>

#if CONFIG_DIAG_LOGS_DEMO
#include <DiagnosticLogsProviderDelegateImpl.h>
#include <app/clusters/diagnostic-logs-server/diagnostic-logs-server.h>
#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 =
Expand All @@ -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
29 changes: 27 additions & 2 deletions examples/thermostat/nxp/rt/rw61x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ declare_args() {

# Setup discriminator as argument
setup_discriminator = 3840

chip_with_diag_logs_demo = true
}

example_platform_dir =
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 1d6b0a5

Please sign in to comment.