Skip to content

Commit

Permalink
Add support for diagnostic logs server cluster with BDX support (#31198)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
vivien-apple authored and pull[bot] committed Feb 22, 2024
1 parent d878b72 commit d01addd
Show file tree
Hide file tree
Showing 53 changed files with 3,101 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7228,10 +7228,15 @@ endpoint 0 {
}

server cluster DiagnosticLogs {
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;

handle command RetrieveLogsRequest;
handle command RetrieveLogsResponse;
}

server cluster GeneralDiagnostics {
Expand Down
72 changes: 72 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -2723,9 +2723,81 @@
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "RetrieveLogsResponse",
"code": 1,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "EventList",
"code": 65530,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down
61 changes: 59 additions & 2 deletions examples/all-clusters-app/linux/AppOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,23 @@ 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;

static chip::Optional<std::string> sEndUserSupportLogFilePath;
static chip::Optional<std::string> sNetworkDiagnosticsLogFilePath;
static chip::Optional<std::string> sCrashLogFilePath;

bool AppOptions::IsEmptyString(const char * value)
{
return (value == nullptr || strlen(value) == 0);
}

bool AppOptions::HandleOptions(const char * program, OptionSet * options, int identifier, const char * name, const char * value)
{
bool retval = true;
Expand All @@ -45,6 +57,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 (!IsEmptyString(value))
{
sEndUserSupportLogFilePath.SetValue(value);
}
break;
}
case kOptionNetworkDiagnosticsFilePath: {
if (!IsEmptyString(value))
{
sNetworkDiagnosticsLogFilePath.SetValue(value);
}
break;
}
case kOptionCrashFilePath: {
if (!IsEmptyString(value))
{
sCrashLogFilePath.SetValue(value);
}
break;
}
default:
PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", program, name);
retval = false;
Expand All @@ -59,6 +92,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 },
{},
};

Expand All @@ -68,6 +104,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;
Expand All @@ -77,3 +119,18 @@ chip::Credentials::DeviceAttestationCredentialsProvider * AppOptions::GetDACProv
{
return &mDacProvider;
}

chip::Optional<std::string> AppOptions::GetEndUserSupportLogFilePath()
{
return sEndUserSupportLogFilePath;
}

chip::Optional<std::string> AppOptions::GetNetworkDiagnosticsLogFilePath()
{
return sNetworkDiagnosticsLogFilePath;
}

chip::Optional<std::string> AppOptions::GetCrashLogFilePath()
{
return sCrashLogFilePath;
}
7 changes: 6 additions & 1 deletion examples/all-clusters-app/linux/AppOptions.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2022 Project CHIP Authors
* Copyright (c) 2022-2023 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -27,8 +27,13 @@ class AppOptions
public:
static chip::ArgParser::OptionSet * GetOptions();
static chip::Credentials::DeviceAttestationCredentialsProvider * GetDACProvider();
static chip::Optional<std::string> GetEndUserSupportLogFilePath();
static chip::Optional<std::string> GetNetworkDiagnosticsLogFilePath();
static chip::Optional<std::string> GetCrashLogFilePath();

private:
static bool HandleOptions(const char * program, chip::ArgParser::OptionSet * options, int identifier, const char * name,
const char * value);

static bool IsEmptyString(const char * value);
};
1 change: 1 addition & 0 deletions examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ source_set("chip-all-clusters-common") {
"${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",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp",
"${chip_root}/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementManager.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/src/EnergyEvseDelegateImpl.cpp",
Expand Down
Loading

0 comments on commit d01addd

Please sign in to comment.