Skip to content

Commit 1d6b0a5

Browse files
Martin-NXPmarius-predaChin-Ran Lorestyled-commits
authored
[NXP][rw61x] Diagnostic log, factory data storage, ICD, fixes (#35576)
* [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 <martin.girardot@nxp.com> (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 <nxf57500@lsv051039.swis.nl-cdc01.nxp.com> (cherry picked from commit c46f6ceb2bc2c6708ba62663ab53a86215691052) * [NXP][examples][common] Fix laundry-washer app Identify cluster issue on endepoint 0 Signed-off-by: Chin-Ran Lo <nxf57500@lsv051039.swis.nl-cdc01.nxp.com> (cherry picked from commit 3f2d5f7cafce98761393f1db17f46c9590bb600a) * [NXP][examples][common] Add laundry wahser mode file Signed-off-by: Martin Girardot <martin.girardot@nxp.com> (cherry picked from commit a73da0d7e757b1b908470a3136761de58b9de08a) * [NXP][examples][rw61x] update laundry washer mode file path, add icd support Signed-off-by: Martin Girardot <martin.girardot@nxp.com> (cherry picked from commit 1f2b75325595951d389403d82180dd74152a85dc) * [NXP][examples][rw61x] Enable Disgnostic log for thermostat app Signed-off-by: Martin Girardot <martin.girardot@nxp.com> (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 <martin.girardot@nxp.com> * Restyled by clang-format * Restyled by gn * [NXP] fix PR comments: spelling, delete identify on endpoint 0 Signed-off-by: Martin Girardot <martin.girardot@nxp.com> --------- Signed-off-by: Martin Girardot <martin.girardot@nxp.com> Co-authored-by: Marius Preda <marius.preda@nxp.com> Co-authored-by: Chin-Ran Lo <nxf57500@lsv051039.swis.nl-cdc01.nxp.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent e6a6425 commit 1d6b0a5

File tree

9 files changed

+181
-39
lines changed

9 files changed

+181
-39
lines changed

examples/laundry-washer-app/nxp/common/main/AppTask.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ using namespace chip::Shell;
3737
using namespace chip;
3838
using namespace chip::app::Clusters;
3939

40+
/*
41+
* Enable temperature level delegate of temperature control cluster
42+
*/
4043
app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate;
44+
void emberAfTemperatureControlClusterInitCallback(EndpointId endpoint)
45+
{
46+
TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate);
47+
}
4148

4249
#ifdef ENABLE_CHIP_SHELL
4350
const static std::map<std::string, uint8_t> map_cmd_errstate{
@@ -119,8 +126,6 @@ void LaundryWasherApp::AppTask::PreInitMatterStack()
119126
void LaundryWasherApp::AppTask::PostInitMatterStack()
120127
{
121128
chip::app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&chip::NXP::App::GetICDUtil());
122-
123-
app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate);
124129
}
125130

126131
void LaundryWasherApp::AppTask::AppMatter_RegisterCustomCliCommands()

examples/laundry-washer-app/nxp/common/main/DeviceCallbacks.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ void OnTriggerEffect(::Identify * identify)
5858
}
5959
}
6060

61-
Identify gIdentify0 = {
62-
chip::EndpointId{ 1 },
63-
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
64-
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
65-
chip::app::Clusters::Identify::IdentifyTypeEnum::kNone,
66-
OnTriggerEffect,
67-
};
68-
6961
Identify gIdentify1 = {
7062
chip::EndpointId{ 1 },
7163
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
#include <app-common/zap-generated/attributes/Accessors.h>
19+
#include <laundry-washer-mode.h>
20+
21+
using namespace chip::app::Clusters;
22+
using namespace chip::app::Clusters::LaundryWasherMode;
23+
using chip::Protocols::InteractionModel::Status;
24+
template <typename T>
25+
using List = chip::app::DataModel::List<T>;
26+
using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::Type;
27+
28+
static LaundryWasherModeDelegate * gLaundryWasherModeDelegate = nullptr;
29+
static ModeBase::Instance * gLaundryWasherModeInstance = nullptr;
30+
31+
CHIP_ERROR LaundryWasherModeDelegate::Init()
32+
{
33+
return CHIP_NO_ERROR;
34+
}
35+
36+
void LaundryWasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::ChangeToModeResponse::Type & response)
37+
{
38+
response.status = to_underlying(ModeBase::StatusCode::kSuccess);
39+
}
40+
41+
CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label)
42+
{
43+
if (modeIndex >= ArraySize(kModeOptions))
44+
{
45+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
46+
}
47+
return chip::CopyCharSpanToMutableCharSpan(kModeOptions[modeIndex].label, label);
48+
}
49+
50+
CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value)
51+
{
52+
if (modeIndex >= ArraySize(kModeOptions))
53+
{
54+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
55+
}
56+
value = kModeOptions[modeIndex].mode;
57+
return CHIP_NO_ERROR;
58+
}
59+
60+
CHIP_ERROR LaundryWasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List<ModeTagStructType> & tags)
61+
{
62+
if (modeIndex >= ArraySize(kModeOptions))
63+
{
64+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
65+
}
66+
67+
if (tags.size() < kModeOptions[modeIndex].modeTags.size())
68+
{
69+
return CHIP_ERROR_INVALID_ARGUMENT;
70+
}
71+
72+
std::copy(kModeOptions[modeIndex].modeTags.begin(), kModeOptions[modeIndex].modeTags.end(), tags.begin());
73+
tags.reduce_size(kModeOptions[modeIndex].modeTags.size());
74+
75+
return CHIP_NO_ERROR;
76+
}
77+
78+
ModeBase::Instance * LaundryWasherMode::Instance()
79+
{
80+
return gLaundryWasherModeInstance;
81+
}
82+
83+
void LaundryWasherMode::Shutdown()
84+
{
85+
if (gLaundryWasherModeInstance != nullptr)
86+
{
87+
delete gLaundryWasherModeInstance;
88+
gLaundryWasherModeInstance = nullptr;
89+
}
90+
if (gLaundryWasherModeDelegate != nullptr)
91+
{
92+
delete gLaundryWasherModeDelegate;
93+
gLaundryWasherModeDelegate = nullptr;
94+
}
95+
}
96+
97+
void emberAfLaundryWasherModeClusterInitCallback(chip::EndpointId endpointId)
98+
{
99+
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
100+
VerifyOrDie(gLaundryWasherModeDelegate == nullptr && gLaundryWasherModeInstance == nullptr);
101+
gLaundryWasherModeDelegate = new LaundryWasherMode::LaundryWasherModeDelegate;
102+
gLaundryWasherModeInstance = new ModeBase::Instance(gLaundryWasherModeDelegate, 0x1, LaundryWasherMode::Id, 0);
103+
gLaundryWasherModeInstance->Init();
104+
}

examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn

+8-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ rt_sdk("sdk") {
6666
defines = []
6767

6868
# To be moved, temporary mbedtls config fix to build app with factory data
69-
if (chip_enable_secure_dac_private_key_storage == 1) {
69+
if (chip_enable_secure_dac_private_key_storage ||
70+
chip_enable_secure_whole_factory_data) {
7071
defines += [
7172
"MBEDTLS_NIST_KW_C",
7273
"MBEDTLS_PSA_CRYPTO_CLIENT",
@@ -150,8 +151,12 @@ rt_executable("laundry-washer") {
150151
"../../common/main/main.cpp",
151152
]
152153

153-
if (chip_enable_secure_dac_private_key_storage == 1) {
154+
if (chip_enable_secure_dac_private_key_storage ||
155+
chip_enable_secure_whole_factory_data) {
154156
sources += [ "${chip_root}/examples/platform/nxp/${nxp_platform}/factory_data/source/AppFactoryDataExample.cpp" ]
157+
if (chip_enable_secure_whole_factory_data) {
158+
defines += [ "ENABLE_SECURE_WHOLE_FACTORY_DATA" ]
159+
}
155160
} else {
156161
sources += [
157162
"${common_example_dir}/factory_data/source/AppFactoryDataDefaultImpl.cpp",
@@ -186,10 +191,10 @@ rt_executable("laundry-washer") {
186191
sources += [
187192
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
188193
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp",
189-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp",
190194
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp",
191195
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
192196
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
197+
"../../common/main/laundry-washer-mode.cpp",
193198
"../../common/main/operational-state-delegate-impl.cpp",
194199
]
195200

examples/laundry-washer-app/nxp/rt/rw61x/args.gni

+6
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ import("//build_overrides/chip.gni")
1717
# SDK target definitions
1818
nxp_sdk_target = get_label_info(":sdk", "label_no_toolchain")
1919
nxp_sdk_driver_target = get_label_info(":sdk_driver", "label_no_toolchain")
20+
21+
# ICDM
22+
chip_enable_icd_server = true
23+
chip_persist_subscriptions = true
24+
chip_subscription_timeout_resumption = true
25+
chip_enable_icd_checkin = true

examples/platform/nxp/common/diagnostic_logs/BUILD.gn

-24
This file was deleted.

examples/platform/nxp/common/matter_cli/source/AppCLIBase.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
#include <lib/shell/Engine.h>
2525
#include <platform/CHIPDeviceLayer.h>
2626

27+
#if (CHIP_DEVICE_CONFIG_ENABLE_WPA && CHIP_ENABLE_OPENTHREAD)
28+
29+
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h>
30+
31+
extern "C" {
32+
#include "addons_cli.h"
33+
}
34+
#endif
35+
2736
#define MATTER_CLI_LOG(message) (chip::Shell::streamer_printf(chip::Shell::streamer_get(), message))
2837

2938
static CHIP_ERROR commissioningManager(int argc, char * argv[])
@@ -80,6 +89,9 @@ void chip::NXP::App::AppCLIBase::RegisterDefaultCommands(void)
8089
/* Register common shell commands */
8190
cmd_misc_init();
8291
cmd_otcli_init();
92+
#if (CHIP_DEVICE_CONFIG_ENABLE_WPA && CHIP_ENABLE_OPENTHREAD)
93+
otAppCliAddonsInit(chip::DeviceLayer::ThreadStackMgrImpl().OTInstance());
94+
#endif
8395
#if CHIP_SHELL_ENABLE_CMD_SERVER
8496
cmd_app_server_init();
8597
#endif /* CHIP_SHELL_ENABLE_CMD_SERVER */

examples/thermostat/nxp/common/main/ZclCallbacks.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@
2626
#include <app/ConcreteAttributePath.h>
2727
#include <app/util/af-types.h>
2828

29+
#if CONFIG_DIAG_LOGS_DEMO
30+
#include <DiagnosticLogsProviderDelegateImpl.h>
31+
#include <app/clusters/diagnostic-logs-server/diagnostic-logs-server.h>
32+
#endif
33+
2934
using namespace ::chip;
3035

36+
#if CONFIG_DIAG_LOGS_DEMO
37+
using namespace ::chip::app::Clusters::DiagnosticLogs;
38+
#endif
39+
3140
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & path, uint8_t type, uint16_t size, uint8_t * value)
3241
{
3342
chip::DeviceManager::CHIPDeviceManagerCallbacks * cb =
@@ -38,3 +47,11 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
3847
cb->PostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId, type, size, value);
3948
}
4049
}
50+
51+
#if CONFIG_DIAG_LOGS_DEMO
52+
void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint)
53+
{
54+
auto & logProvider = LogProvider::GetInstance();
55+
DiagnosticLogsServer::Instance().SetDiagnosticLogsProviderDelegate(endpoint, &logProvider);
56+
}
57+
#endif

examples/thermostat/nxp/rt/rw61x/BUILD.gn

+27-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ declare_args() {
4747

4848
# Setup discriminator as argument
4949
setup_discriminator = 3840
50+
51+
chip_with_diag_logs_demo = true
5052
}
5153

5254
example_platform_dir =
@@ -66,7 +68,8 @@ rt_sdk("sdk") {
6668
defines = []
6769

6870
# To be moved, temporary mbedtls config fix to build app with factory data
69-
if (chip_enable_secure_dac_private_key_storage == 1) {
71+
if (chip_enable_secure_dac_private_key_storage ||
72+
chip_enable_secure_whole_factory_data) {
7073
defines += [
7174
"MBEDTLS_NIST_KW_C",
7275
"MBEDTLS_PSA_CRYPTO_CLIENT",
@@ -127,6 +130,13 @@ rt_executable("thermostat") {
127130
defines += [ "CONFIG_NET_L2_OPENTHREAD=1" ]
128131
}
129132

133+
if (chip_with_diag_logs_demo) {
134+
defines += [
135+
"CONFIG_DIAG_LOGS_DEMO=1",
136+
"CHIP_DEVICE_CONFIG_MAX_DIAG_LOG_SIZE=1024",
137+
]
138+
}
139+
130140
include_dirs = [
131141
"../../common/main/include",
132142
"../../common/main",
@@ -146,8 +156,23 @@ rt_executable("thermostat") {
146156
"../../common/main/main.cpp",
147157
]
148158

149-
if (chip_enable_secure_dac_private_key_storage == 1) {
159+
if (chip_with_diag_logs_demo) {
160+
include_dirs += [
161+
"${common_example_dir}/diagnostic_logs/include",
162+
"${chip_root}",
163+
]
164+
sources += [
165+
"${common_example_dir}/diagnostic_logs/source/DiagnosticLogsDemo.cpp",
166+
"${common_example_dir}/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp",
167+
]
168+
}
169+
170+
if (chip_enable_secure_dac_private_key_storage ||
171+
chip_enable_secure_whole_factory_data) {
150172
sources += [ "${chip_root}/examples/platform/nxp/${nxp_platform}/factory_data/source/AppFactoryDataExample.cpp" ]
173+
if (chip_enable_secure_whole_factory_data) {
174+
defines += [ "ENABLE_SECURE_WHOLE_FACTORY_DATA" ]
175+
}
151176
} else {
152177
sources += [
153178
"${common_example_dir}/factory_data/source/AppFactoryDataDefaultImpl.cpp",

0 commit comments

Comments
 (0)