From 218879e2ff6143eb8dd33fd55c551170816afd80 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Wed, 8 Feb 2023 21:31:27 +0100 Subject: [PATCH] [administator-commissioning-cluster] Remove StatusCode from weak-enum-list.yaml --- .../administrator-commissioning-server.cpp | 43 ++++++++----------- src/app/common/templates/config-data.yaml | 1 - 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp index b38cc27407965a..67ee2c831c755a 100644 --- a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp +++ b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp @@ -98,36 +98,31 @@ bool emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback( auto & failSafeContext = Server::GetInstance().GetFailSafeContext(); auto & commissionMgr = Server::GetInstance().GetCommissioningWindowManager(); - VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); - - VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); - VerifyOrExit(iterations >= kSpake2p_Min_PBKDF_Iterations, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(iterations <= kSpake2p_Max_PBKDF_Iterations, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(salt.size() >= kSpake2p_Min_PBKDF_Salt_Length, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(salt.size() <= kSpake2p_Max_PBKDF_Salt_Length, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::kBusy)); + + VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::kBusy)); + VerifyOrExit(iterations >= kSpake2p_Min_PBKDF_Iterations, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(iterations <= kSpake2p_Max_PBKDF_Iterations, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(salt.size() >= kSpake2p_Min_PBKDF_Salt_Length, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(salt.size() <= kSpake2p_Max_PBKDF_Salt_Length, status.Emplace(StatusCode::kPAKEParameterError)); VerifyOrExit(commissioningTimeout <= commissionMgr.MaxCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(commissioningTimeout >= commissionMgr.MinCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(discriminator <= kMaxDiscriminatorValue, globalStatus = InteractionModel::Status::InvalidCommand); - VerifyOrExit(verifier.Deserialize(pakeVerifier) == CHIP_NO_ERROR, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + VerifyOrExit(verifier.Deserialize(pakeVerifier) == CHIP_NO_ERROR, status.Emplace(StatusCode::kPAKEParameterError)); VerifyOrExit(commissionMgr.OpenEnhancedCommissioningWindow(commissioningTimeout, discriminator, verifier, iterations, salt, fabricIndex, fabricInfo->GetVendorId()) == CHIP_NO_ERROR, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + status.Emplace(StatusCode::kPAKEParameterError)); ChipLogProgress(Zcl, "Commissioning window is now open"); exit: if (status.HasValue()) { - ChipLogError(Zcl, "Failed to open commissioning window. Cluster status %d", status.Value()); - commandObj->AddClusterSpecificFailure(commandPath, status.Value()); + ChipLogError(Zcl, "Failed to open commissioning window. Cluster status 0x%02x", to_underlying(status.Value())); + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(status.Value())); } else { @@ -156,24 +151,24 @@ bool emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallbac auto & failSafeContext = Server::GetInstance().GetFailSafeContext(); auto & commissionMgr = Server::GetInstance().GetCommissioningWindowManager(); - VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::kPAKEParameterError)); - VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); - VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); + VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::kBusy)); + VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::kBusy)); VerifyOrExit(commissioningTimeout <= commissionMgr.MaxCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(commissioningTimeout >= commissionMgr.MinCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(commissionMgr.OpenBasicCommissioningWindowForAdministratorCommissioningCluster( commissioningTimeout, fabricIndex, fabricInfo->GetVendorId()) == CHIP_NO_ERROR, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + status.Emplace(StatusCode::kPAKEParameterError)); ChipLogProgress(Zcl, "Commissioning window is now open"); exit: if (status.HasValue()) { - ChipLogError(Zcl, "Failed to open commissioning window. Cluster status %d", status.Value()); - commandObj->AddClusterSpecificFailure(commandPath, status.Value()); + ChipLogError(Zcl, "Failed to open commissioning window. Cluster status 0x%02x", to_underlying(status.Value())); + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(status.Value())); } else { @@ -198,7 +193,7 @@ bool emberAfAdministratorCommissioningClusterRevokeCommissioningCallback( if (!Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen()) { ChipLogError(Zcl, "Commissioning window is currently not open"); - commandObj->AddClusterSpecificFailure(commandPath, StatusCode::EMBER_ZCL_STATUS_CODE_WINDOW_NOT_OPEN); + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(StatusCode::kWindowNotOpen)); } else { diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 063eadbb48e800..d21325e2ba812b 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -36,7 +36,6 @@ WeakEnums: - SaturationMoveMode - SaturationStepMode - SecurityType - - StatusCode - StepMode - TemperatureDisplayMode - WiFiVersionType