Skip to content

Commit

Permalink
Add trace events to commissioning flow (#16380)
Browse files Browse the repository at this point in the history
* Add trace events to commissioning flow

Trace events are added to CHIPDeviceCommissioner and some clusters
callbacks used for commissioning.

* Restyled by gn

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 12, 2023
1 parent b9c94f1 commit a147a91
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ target_compile_options(${COMPONENT_LIB} PRIVATE
"-DPW_RPC_LIGHTING_SERVICE=1"
"-DPW_RPC_LOCKING_SERVICE=1"
"-DPW_RPC_TRACING_SERVICE=1"
"-DPW_RPC_WIFI_SERVICE=1")
"-DPW_RPC_WIFI_SERVICE=1"
"-DPW_TRACE_BACKEND_SET=1")

endif (CONFIG_ENABLE_PW_RPC)
3 changes: 2 additions & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ target_compile_options(app PRIVATE
"-DPW_RPC_DEVICE_SERVICE=1"
"-DPW_RPC_LIGHTING_SERVICE=1"
"-DPW_RPC_THREAD_SERVICE=1"
"-DPW_RPC_TRACING_SERVICE=1")
"-DPW_RPC_TRACING_SERVICE=1"
"-DPW_TRACE_BACKEND_SET=1")

target_link_libraries(app PRIVATE
attributes_service.nanopb_rpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <platform/CHIPDeviceConfig.h>
#include <platform/ConfigurationManager.h>
#include <platform/DeviceControlServer.h>
#include <trace/trace.h>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -131,6 +132,7 @@ bool emberAfGeneralCommissioningClusterArmFailSafeCallback(app::CommandHandler *
const app::ConcreteCommandPath & commandPath,
const Commands::ArmFailSafe::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("ArmFailSafe", "GeneralCommissioning");
FailSafeContext & failSafeContext = DeviceLayer::DeviceControlServer::DeviceControlSvr().GetFailSafeContext();
Commands::ArmFailSafeResponse::Type response;

Expand Down Expand Up @@ -162,6 +164,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::CommissioningComplete::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("CommissioningComplete", "GeneralCommissioning");
DeviceControlServer * server = &DeviceLayer::DeviceControlServer::DeviceControlSvr();

/*
Expand All @@ -184,6 +187,7 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH
const app::ConcreteCommandPath & commandPath,
const Commands::SetRegulatoryConfig::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("SetRegulatoryConfig", "GeneralCommissioning");
DeviceControlServer * server = &DeviceLayer::DeviceControlServer::DeviceControlSvr();

CheckSuccess(server->SetRegulatoryConfig(to_underlying(commandData.location), commandData.countryCode, commandData.breadcrumb),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <platform/DeviceControlServer.h>
#include <platform/PlatformManager.h>
#include <platform/internal/DeviceNetworkInfo.h>
#include <trace/trace.h>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -269,7 +270,7 @@ void Instance::OnNetworkingStatusChange(DeviceLayer::NetworkCommissioning::Statu

void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetworks::DecodableType & req)
{

MATTER_TRACE_EVENT_SCOPE("HandleScanNetwork", "NetworkCommissioning");
if (mFeatureFlags.Has(NetworkCommissioningFeature::kWiFiNetworkInterface))
{
mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler);
Expand All @@ -288,27 +289,31 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw

void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleAddOrUpdateWiFiNetwork", "NetworkCommissioning");
Commands::NetworkConfigResponse::Type response;
response.networkingStatus = ToClusterObjectEnum(mpDriver.Get<WiFiDriver *>()->AddOrUpdateNetwork(req.ssid, req.credentials));
ctx.mCommandHandler.AddResponseData(ctx.mRequestPath, response);
}

void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Commands::AddOrUpdateThreadNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleAddOrUpdateThreadNetwork", "NetworkCommissioning");
Commands::NetworkConfigResponse::Type response;
response.networkingStatus = ToClusterObjectEnum(mpDriver.Get<ThreadDriver *>()->AddOrUpdateNetwork(req.operationalDataset));
ctx.mCommandHandler.AddResponseData(ctx.mRequestPath, response);
}

void Instance::HandleRemoveNetwork(HandlerContext & ctx, const Commands::RemoveNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleRemoveNetwork", "NetworkCommissioning");
Commands::NetworkConfigResponse::Type response;
response.networkingStatus = ToClusterObjectEnum(mpWirelessDriver->RemoveNetwork(req.networkID));
ctx.mCommandHandler.AddResponseData(ctx.mRequestPath, response);
}

void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::ConnectNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleConnectNetwork", "NetworkCommissioning");
if (req.networkID.size() > DeviceLayer::NetworkCommissioning::kMaxNetworkIDLen)
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidValue);
Expand All @@ -324,6 +329,7 @@ void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::Connec

void Instance::HandleReorderNetwork(HandlerContext & ctx, const Commands::ReorderNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleReorderNetwork", "NetworkCommissioning");
Commands::NetworkConfigResponse::Type response;
response.networkingStatus = ToClusterObjectEnum(mpWirelessDriver->ReorderNetwork(req.networkID, req.networkIndex));
ctx.mCommandHandler.AddResponseData(ctx.mRequestPath, response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <platform/CHIPDeviceLayer.h>
#include <platform/DeviceControlServer.h>
#include <string.h>
#include <trace/trace.h>

using namespace chip;
using namespace ::chip::DeviceLayer;
Expand Down Expand Up @@ -368,6 +369,7 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(app::CommandHandle
const app::ConcreteCommandPath & commandPath,
const Commands::RemoveFabric::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("RemoveFabric", "OperationalCredentials");
auto & fabricBeingRemoved = commandData.fabricIndex;

emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: RemoveFabric"); // TODO: Generate emberAfFabricClusterPrintln
Expand Down Expand Up @@ -425,6 +427,7 @@ bool emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(app::CommandH
const app::ConcreteCommandPath & commandPath,
const Commands::UpdateFabricLabel::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("UpdateFabricLabel", "OperationalCredentials");
auto & Label = commandData.label;
auto ourFabricIndex = commandObj->GetAccessingFabricIndex();

Expand Down Expand Up @@ -521,6 +524,7 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co
const app::ConcreteCommandPath & commandPath,
const Commands::AddNOC::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("AddNOC", "OperationalCredentials");
auto & NOCValue = commandData.NOCValue;
auto & ICACValue = commandData.ICACValue;
auto & adminVendorId = commandData.adminVendorId;
Expand Down Expand Up @@ -618,6 +622,7 @@ bool emberAfOperationalCredentialsClusterUpdateNOCCallback(app::CommandHandler *
const app::ConcreteCommandPath & commandPath,
const Commands::UpdateNOC::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("UpdateNOC", "OperationalCredentials");
auto & NOCValue = commandData.NOCValue;
auto & ICACValue = commandData.ICACValue;

Expand Down Expand Up @@ -683,6 +688,7 @@ bool emberAfOperationalCredentialsClusterCertificateChainRequestCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::CertificateChainRequest::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("CertificateChainRequest", "OperationalCredentials");
auto & certificateType = commandData.certificateType;

CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -730,6 +736,7 @@ bool emberAfOperationalCredentialsClusterAttestationRequestCallback(app::Command
const app::ConcreteCommandPath & commandPath,
const Commands::AttestationRequest::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("AttestationRequest", "OperationalCredentials");
auto & attestationNonce = commandData.attestationNonce;

CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -790,6 +797,7 @@ bool emberAfOperationalCredentialsClusterCSRRequestCallback(app::CommandHandler
const app::ConcreteCommandPath & commandPath,
const Commands::CSRRequest::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("CSRRequest", "OperationalCredentials");
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: commissioner has requested a CSR");

CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -879,6 +887,7 @@ bool emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::AddTrustedRootCertificate::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("AddTrustedRootCertificate", "OperationalCredentials");
auto & RootCertificate = commandData.rootCertificate;

EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
Expand Down Expand Up @@ -917,6 +926,7 @@ bool emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::RemoveTrustedRootCertificate::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("RemoveTrustedRootCertificate", "OperationalCredentials");
// TODO: Implement the logic for RemoveTrustedRootCertificate
EmberAfStatus status = EMBER_ZCL_STATUS_FAILURE;
emberAfSendImmediateDefaultResponse(status);
Expand Down
1 change: 1 addition & 0 deletions src/controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static_library("controller") {
"${chip_root}/src/platform",
"${chip_root}/src/protocols",
"${chip_root}/src/setup_payload",
"${chip_root}/src/trace",
"${chip_root}/src/transport",
]

Expand Down
Loading

0 comments on commit a147a91

Please sign in to comment.