-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add support for diagnostic logs server cluster and add the log provid… #29976
Changes from 34 commits
aa2ade5
86e01c7
38930dc
0349632
1ce1262
a5ec507
426d697
69f3dd9
bc2cbc0
dcadb91
4a67f96
76aa772
0028414
52ec06e
baca50e
3776d12
b5e2f4e
7294b5a
e0fc837
7fadbd3
7cf9d6d
2aaaf14
502b476
a9ff69c
56b73e2
c259633
646679e
56a9cfa
a9e6dc6
1078039
3151b6c
f3494cf
9cc3f56
e5340b4
5a37be1
707a677
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,20 +18,35 @@ | |
|
||
#include "AppOptions.h" | ||
|
||
#include <app/clusters/diagnostic-logs-server/diagnostic-logs-server.h> | ||
#include <app/server/CommissioningWindowManager.h> | ||
#include <app/server/Server.h> | ||
|
||
using namespace chip; | ||
using namespace chip::ArgParser; | ||
using namespace chip::app::Clusters::DiagnosticLogs; | ||
|
||
using chip::ArgParser::OptionDef; | ||
using chip::ArgParser::OptionSet; | ||
using chip::ArgParser::PrintArgError; | ||
|
||
constexpr uint16_t kOptionDacProviderFilePath = 0xFF01; | ||
constexpr uint16_t kOptionMinCommissioningTimeout = 0xFF02; | ||
constexpr uint16_t kOptionDacProviderFilePath = 0xFF01; | ||
constexpr uint16_t kOptionMinCommissioningTimeout = 0xFF02; | ||
constexpr uint16_t kOptionEndUserSupportFilePath = 0xFF03; | ||
constexpr uint16_t kOptionNetworkDiagnosticsFilePath = 0xFF04; | ||
constexpr uint16_t kOptionCrashFilePath = 0xFF05; | ||
|
||
static chip::Credentials::Examples::TestHarnessDACProvider mDacProvider; | ||
|
||
chip::Optional<std::string> mEndUserSupportLogFilePath; | ||
chip::Optional<std::string> mNetworkDiagnosticsLogFilePath; | ||
chip::Optional<std::string> mCrashLogFilePath; | ||
|
||
bool AppOptions::IsNullOrEmpty(const char * value) | ||
{ | ||
return (value == nullptr || strlen(value) == 0 || strncmp(value, "", strlen(value)) == 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand that third bit with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checking for an empty string. it might not be needed actually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
strlen == 0 checked that already. |
||
} | ||
|
||
bool AppOptions::HandleOptions(const char * program, OptionSet * options, int identifier, const char * name, const char * value) | ||
{ | ||
bool retval = true; | ||
|
@@ -45,6 +60,27 @@ bool AppOptions::HandleOptions(const char * program, OptionSet * options, int id | |
commissionMgr.OverrideMinCommissioningTimeout(chip::System::Clock::Seconds16(static_cast<uint16_t>(atoi(value)))); | ||
break; | ||
} | ||
case kOptionEndUserSupportFilePath: { | ||
if (!IsNullOrEmpty(value)) | ||
{ | ||
mEndUserSupportLogFilePath.SetValue(std::string{ value }); | ||
} | ||
break; | ||
} | ||
case kOptionNetworkDiagnosticsFilePath: { | ||
if (!IsNullOrEmpty(value)) | ||
{ | ||
mNetworkDiagnosticsLogFilePath.SetValue(std::string{ value }); | ||
} | ||
break; | ||
} | ||
case kOptionCrashFilePath: { | ||
if (!IsNullOrEmpty(value)) | ||
{ | ||
mCrashLogFilePath.SetValue(std::string{ value }); | ||
} | ||
break; | ||
} | ||
default: | ||
PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", program, name); | ||
retval = false; | ||
|
@@ -59,6 +95,9 @@ OptionSet * AppOptions::GetOptions() | |
static OptionDef optionsDef[] = { | ||
{ "dac_provider", kArgumentRequired, kOptionDacProviderFilePath }, | ||
{ "min_commissioning_timeout", kArgumentRequired, kOptionMinCommissioningTimeout }, | ||
{ "end_user_support_log", kArgumentRequired, kOptionEndUserSupportFilePath }, | ||
{ "network_diagnostics_log", kArgumentRequired, kOptionNetworkDiagnosticsFilePath }, | ||
{ "crash_log", kArgumentRequired, kOptionCrashFilePath }, | ||
{}, | ||
}; | ||
|
||
|
@@ -68,6 +107,12 @@ OptionSet * AppOptions::GetOptions() | |
" A json file with data used by the example dac provider to validate device attestation procedure.\n" | ||
" --min_commissioning_timeout <value>\n" | ||
" The minimum time in seconds during which commissioning session establishment is allowed by the Node.\n" | ||
" --end_user_support_log <value>\n" | ||
" The end user support log file to be used for diagnostic logs transfer.\n" | ||
" --network_diagnostics_log <value>\n" | ||
" The network diagnostics log file to be used for diagnostic logs transfer.\n" | ||
" --crash_log <value>\n" | ||
" The crash log file to be used for diagnostic logs transfer\n" | ||
}; | ||
|
||
return &options; | ||
|
@@ -77,3 +122,18 @@ chip::Credentials::DeviceAttestationCredentialsProvider * AppOptions::GetDACProv | |
{ | ||
return &mDacProvider; | ||
} | ||
|
||
Optional<std::string> AppOptions::GetEndUserSupportLogFilePath() | ||
{ | ||
return mEndUserSupportLogFilePath; | ||
} | ||
|
||
Optional<std::string> AppOptions::GetNetworkDiagnosticsLogFilePath() | ||
{ | ||
return mNetworkDiagnosticsLogFilePath; | ||
} | ||
|
||
Optional<std::string> AppOptions::GetCrashLogFilePath() | ||
{ | ||
return mCrashLogFilePath; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these named "m" of they are global variables (and why are they application globals instead of file statics or class members or something)? My previous review said:
and given how you use them, static members should be the way to go... Probably named "sEndUser...." and whatnot.
And why the extra
chip::
prefixes?Also, I suggested using
std::optional
. Did that not work for some reason?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefixed file path names with s, made them file statics. replaced chip::Optional with std::optional.