From 41e0fc2725435f1ee62a46e4952f29ebeb87b625 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 13 Feb 2023 16:31:25 +0100 Subject: [PATCH] [administrator-commissioning-cluster] Remove StatusCode from weak-enum-list.yaml (#24940) --- .../administrator-commissioning-server.cpp | 43 ++++++++----------- src/app/common/templates/config-data.yaml | 1 - .../zap-generated/cluster-enums-check.h | 8 ---- .../app-common/zap-generated/cluster-enums.h | 7 --- .../app-common/zap-generated/enums.h | 8 ---- 5 files changed, 19 insertions(+), 48 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 diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index f648bcea863766..612c1653ca5f65 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1034,17 +1034,9 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommission using EnumType = AdministratorCommissioning::StatusCode; switch (val) { -// Need to convert consumers to using the new enum classes, so we -// don't just have casts all over. -#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM case EnumType::kBusy: case EnumType::kPAKEParameterError: case EnumType::kWindowNotOpen: -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM - case EMBER_ZCL_STATUS_CODE_BUSY: - case EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR: - case EMBER_ZCL_STATUS_CODE_WINDOW_NOT_OPEN: -#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM return val; default: return static_cast(0); diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index d9e16296348ae0..1d02c01f3c0566 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -1192,9 +1192,6 @@ enum class CommissioningWindowStatusEnum : uint8_t kUnknownEnumValue = 3, }; -// Need to convert consumers to using the new enum classes, so we -// don't just have casts all over. -#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Enum for StatusCode enum class StatusCode : uint8_t { @@ -1207,10 +1204,6 @@ enum class StatusCode : uint8_t // enum value. This specific should never be transmitted. kUnknownEnumValue = 0, }; -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using StatusCode = EmberAfStatusCode; -static StatusCode __attribute__((unused)) kStatusCodekUnknownEnumValue = static_cast(0); -#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM } // namespace AdministratorCommissioning namespace OperationalCredentials { diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index b1ef3423aeca0f..a80c53d062358e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -269,14 +269,6 @@ enum EmberAfSecurityType : uint8_t EMBER_ZCL_SECURITY_TYPE_WPA3 = 5, }; -// Enum for StatusCode -enum EmberAfStatusCode : uint8_t -{ - EMBER_ZCL_STATUS_CODE_BUSY = 2, - EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR = 3, - EMBER_ZCL_STATUS_CODE_WINDOW_NOT_OPEN = 4, -}; - // Enum for StepMode enum EmberAfStepMode : uint8_t {