Skip to content

Commit db7d887

Browse files
authored
Add support for diagnostic logs server cluster with BDX support (project-chip#31198)
* [CI] Add Automation category to the logs that are accepted when in interactive mode to make sure it does not crash when using BDX * [CI] Ensure that WaitForMessage does not read content that it has already consumed * [tracing] Implement BDX message decoding in examples/common/tracing/decoder/bdx/Decoder.cpp * Add a single implementation for GetBdxStatusCodeFromChipError * Update Diagnostic Logs server implementation with an application provided delegate * Add Diagnostic Logs server delegate implementation to the all-clusters-app * Add some YAML tests for the diagnostic logs cluster * Add BDX support to src/app/clusters/diagnostic-logs-server Make sure to reset the exchange context in the TransferFacilitator to make it possible to reuse it for a new exchange * Add BDXTransferServer to src/protocols/bdx * Add an instance of BDXTransferServer to be started by the CHIPDeviceControllerFactory * Add chip-tool BDXTransferServerDelegate support * Add more YAML tests for the diagnostic logs cluster but related to BDX this time
1 parent a092fd1 commit db7d887

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3101
-171
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+5
Original file line numberDiff line numberDiff line change
@@ -7228,10 +7228,15 @@ endpoint 0 {
72287228
}
72297229

72307230
server cluster DiagnosticLogs {
7231+
callback attribute generatedCommandList;
7232+
callback attribute acceptedCommandList;
7233+
callback attribute eventList;
7234+
callback attribute attributeList;
72317235
ram attribute featureMap default = 0;
72327236
ram attribute clusterRevision default = 1;
72337237

72347238
handle command RetrieveLogsRequest;
7239+
handle command RetrieveLogsResponse;
72357240
}
72367241

72377242
server cluster GeneralDiagnostics {

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+72
Original file line numberDiff line numberDiff line change
@@ -2723,9 +2723,81 @@
27232723
"source": "client",
27242724
"isIncoming": 1,
27252725
"isEnabled": 1
2726+
},
2727+
{
2728+
"name": "RetrieveLogsResponse",
2729+
"code": 1,
2730+
"mfgCode": null,
2731+
"source": "server",
2732+
"isIncoming": 0,
2733+
"isEnabled": 1
27262734
}
27272735
],
27282736
"attributes": [
2737+
{
2738+
"name": "GeneratedCommandList",
2739+
"code": 65528,
2740+
"mfgCode": null,
2741+
"side": "server",
2742+
"type": "array",
2743+
"included": 1,
2744+
"storageOption": "External",
2745+
"singleton": 0,
2746+
"bounded": 0,
2747+
"defaultValue": "",
2748+
"reportable": 1,
2749+
"minInterval": 1,
2750+
"maxInterval": 65534,
2751+
"reportableChange": 0
2752+
},
2753+
{
2754+
"name": "AcceptedCommandList",
2755+
"code": 65529,
2756+
"mfgCode": null,
2757+
"side": "server",
2758+
"type": "array",
2759+
"included": 1,
2760+
"storageOption": "External",
2761+
"singleton": 0,
2762+
"bounded": 0,
2763+
"defaultValue": "",
2764+
"reportable": 1,
2765+
"minInterval": 1,
2766+
"maxInterval": 65534,
2767+
"reportableChange": 0
2768+
},
2769+
{
2770+
"name": "EventList",
2771+
"code": 65530,
2772+
"mfgCode": null,
2773+
"side": "server",
2774+
"type": "array",
2775+
"included": 1,
2776+
"storageOption": "External",
2777+
"singleton": 0,
2778+
"bounded": 0,
2779+
"defaultValue": "",
2780+
"reportable": 1,
2781+
"minInterval": 1,
2782+
"maxInterval": 65534,
2783+
"reportableChange": 0
2784+
},
2785+
{
2786+
"name": "AttributeList",
2787+
"code": 65531,
2788+
"mfgCode": null,
2789+
"side": "server",
2790+
"type": "array",
2791+
"included": 1,
2792+
"storageOption": "External",
2793+
"singleton": 0,
2794+
"bounded": 0,
2795+
"defaultValue": "",
2796+
"reportable": 1,
2797+
"minInterval": 1,
2798+
"maxInterval": 65534,
2799+
"reportableChange": 0
2800+
},
27292801
{
27302802
"name": "FeatureMap",
27312803
"code": 65532,

examples/all-clusters-app/linux/AppOptions.cpp

+59-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,23 @@ using chip::ArgParser::OptionDef;
2727
using chip::ArgParser::OptionSet;
2828
using chip::ArgParser::PrintArgError;
2929

30-
constexpr uint16_t kOptionDacProviderFilePath = 0xFF01;
31-
constexpr uint16_t kOptionMinCommissioningTimeout = 0xFF02;
30+
constexpr uint16_t kOptionDacProviderFilePath = 0xFF01;
31+
constexpr uint16_t kOptionMinCommissioningTimeout = 0xFF02;
32+
constexpr uint16_t kOptionEndUserSupportFilePath = 0xFF03;
33+
constexpr uint16_t kOptionNetworkDiagnosticsFilePath = 0xFF04;
34+
constexpr uint16_t kOptionCrashFilePath = 0xFF05;
3235

3336
static chip::Credentials::Examples::TestHarnessDACProvider mDacProvider;
3437

38+
static chip::Optional<std::string> sEndUserSupportLogFilePath;
39+
static chip::Optional<std::string> sNetworkDiagnosticsLogFilePath;
40+
static chip::Optional<std::string> sCrashLogFilePath;
41+
42+
bool AppOptions::IsEmptyString(const char * value)
43+
{
44+
return (value == nullptr || strlen(value) == 0);
45+
}
46+
3547
bool AppOptions::HandleOptions(const char * program, OptionSet * options, int identifier, const char * name, const char * value)
3648
{
3749
bool retval = true;
@@ -45,6 +57,27 @@ bool AppOptions::HandleOptions(const char * program, OptionSet * options, int id
4557
commissionMgr.OverrideMinCommissioningTimeout(chip::System::Clock::Seconds16(static_cast<uint16_t>(atoi(value))));
4658
break;
4759
}
60+
case kOptionEndUserSupportFilePath: {
61+
if (!IsEmptyString(value))
62+
{
63+
sEndUserSupportLogFilePath.SetValue(value);
64+
}
65+
break;
66+
}
67+
case kOptionNetworkDiagnosticsFilePath: {
68+
if (!IsEmptyString(value))
69+
{
70+
sNetworkDiagnosticsLogFilePath.SetValue(value);
71+
}
72+
break;
73+
}
74+
case kOptionCrashFilePath: {
75+
if (!IsEmptyString(value))
76+
{
77+
sCrashLogFilePath.SetValue(value);
78+
}
79+
break;
80+
}
4881
default:
4982
PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", program, name);
5083
retval = false;
@@ -59,6 +92,9 @@ OptionSet * AppOptions::GetOptions()
5992
static OptionDef optionsDef[] = {
6093
{ "dac_provider", kArgumentRequired, kOptionDacProviderFilePath },
6194
{ "min_commissioning_timeout", kArgumentRequired, kOptionMinCommissioningTimeout },
95+
{ "end_user_support_log", kArgumentRequired, kOptionEndUserSupportFilePath },
96+
{ "network_diagnostics_log", kArgumentRequired, kOptionNetworkDiagnosticsFilePath },
97+
{ "crash_log", kArgumentRequired, kOptionCrashFilePath },
6298
{},
6399
};
64100

@@ -68,6 +104,12 @@ OptionSet * AppOptions::GetOptions()
68104
" A json file with data used by the example dac provider to validate device attestation procedure.\n"
69105
" --min_commissioning_timeout <value>\n"
70106
" The minimum time in seconds during which commissioning session establishment is allowed by the Node.\n"
107+
" --end_user_support_log <value>\n"
108+
" The end user support log file to be used for diagnostic logs transfer.\n"
109+
" --network_diagnostics_log <value>\n"
110+
" The network diagnostics log file to be used for diagnostic logs transfer.\n"
111+
" --crash_log <value>\n"
112+
" The crash log file to be used for diagnostic logs transfer.\n"
71113
};
72114

73115
return &options;
@@ -77,3 +119,18 @@ chip::Credentials::DeviceAttestationCredentialsProvider * AppOptions::GetDACProv
77119
{
78120
return &mDacProvider;
79121
}
122+
123+
chip::Optional<std::string> AppOptions::GetEndUserSupportLogFilePath()
124+
{
125+
return sEndUserSupportLogFilePath;
126+
}
127+
128+
chip::Optional<std::string> AppOptions::GetNetworkDiagnosticsLogFilePath()
129+
{
130+
return sNetworkDiagnosticsLogFilePath;
131+
}
132+
133+
chip::Optional<std::string> AppOptions::GetCrashLogFilePath()
134+
{
135+
return sCrashLogFilePath;
136+
}

examples/all-clusters-app/linux/AppOptions.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2022 Project CHIP Authors
3+
* Copyright (c) 2022-2023 Project CHIP Authors
44
* All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,8 +27,13 @@ class AppOptions
2727
public:
2828
static chip::ArgParser::OptionSet * GetOptions();
2929
static chip::Credentials::DeviceAttestationCredentialsProvider * GetDACProvider();
30+
static chip::Optional<std::string> GetEndUserSupportLogFilePath();
31+
static chip::Optional<std::string> GetNetworkDiagnosticsLogFilePath();
32+
static chip::Optional<std::string> GetCrashLogFilePath();
3033

3134
private:
3235
static bool HandleOptions(const char * program, chip::ArgParser::OptionSet * options, int identifier, const char * name,
3336
const char * value);
37+
38+
static bool IsEmptyString(const char * value);
3439
};

examples/all-clusters-app/linux/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ source_set("chip-all-clusters-common") {
4545
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
4646
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
4747
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp",
48+
"${chip_root}/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp",
4849
"${chip_root}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp",
4950
"${chip_root}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementManager.cpp",
5051
"${chip_root}/examples/energy-management-app/energy-management-common/src/EnergyEvseDelegateImpl.cpp",

0 commit comments

Comments
 (0)