From 154554131cdb1e188424680e4c09c6429bd6155c Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 17 Nov 2023 03:31:53 -0500 Subject: [PATCH] Remove `PHYRateEnum` from the list of WeakEnums (#30530) * Remove ZCL for PHYRateEnum * make it compile * Restyle --------- Co-authored-by: Andrei Litvin --- .../ethernet-network-diagnostics-server.cpp | 5 +++-- src/app/common/templates/config-data.yaml | 1 - src/platform/Linux/ConnectivityUtils.cpp | 20 +++++++++---------- src/platform/Tizen/ConnectivityUtils.cpp | 20 +++++++++---------- src/platform/webos/ConnectivityUtils.cpp | 20 +++++++++---------- .../zap-generated/cluster-enums-check.h | 15 -------------- .../app-common/zap-generated/cluster-enums.h | 7 ------- .../app-common/zap-generated/enums.h | 15 -------------- 8 files changed, 33 insertions(+), 70 deletions(-) diff --git a/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp b/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp index c978a56704397e..5d73f36ca12b8c 100644 --- a/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp +++ b/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp @@ -74,12 +74,13 @@ CHIP_ERROR EthernetDiagosticsAttrAccess::ReadIfSupported(CHIP_ERROR (DiagnosticD CHIP_ERROR EthernetDiagosticsAttrAccess::ReadPHYRate(AttributeValueEncoder & aEncoder) { Attributes::PHYRate::TypeInfo::Type pHYRate; - auto value = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_M; + auto value = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10M; if (DeviceLayer::GetDiagnosticDataProvider().GetEthPHYRate(value) == CHIP_NO_ERROR) { pHYRate.SetNonNull(value); - ChipLogProgress(Zcl, "The current nominal, usable speed at the top of the physical layer of the Node: %d", value); + ChipLogProgress(Zcl, "The current nominal, usable speed at the top of the physical layer of the Node: %d", + chip::to_underlying(value)); } else { diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index a7202afe6d7ba5..e2444f0a14d029 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -13,7 +13,6 @@ WeakEnums: - ColorControlOptions - ColorMode - EnhancedColorMode - - PHYRateEnum EnumsNotUsedAsTypeInXML: # List of enums that are not used as a type in XML. By adding an enum diff --git a/src/platform/Linux/ConnectivityUtils.cpp b/src/platform/Linux/ConnectivityUtils.cpp index 2924d48612317e..01e41af7c583bd 100644 --- a/src/platform/Linux/ConnectivityUtils.cpp +++ b/src/platform/Linux/ConnectivityUtils.cpp @@ -658,34 +658,34 @@ CHIP_ERROR ConnectivityUtils::GetEthPHYRate(const char * ifname, app::Clusters:: switch (speed) { case 10: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_M; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10M; break; case 100: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_M; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate100M; break; case 1000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE1_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate1G; break; case 25000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE2_5_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate25g; break; case 5000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE5_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate5G; break; case 10000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10G; break; case 40000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE40_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate40G; break; case 100000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate100G; break; case 200000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE200_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate200G; break; case 400000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE400_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate400G; break; default: ChipLogError(DeviceLayer, "Undefined speed! (%d)\n", speed); diff --git a/src/platform/Tizen/ConnectivityUtils.cpp b/src/platform/Tizen/ConnectivityUtils.cpp index b74a2832b93237..0ceab55fbd3335 100644 --- a/src/platform/Tizen/ConnectivityUtils.cpp +++ b/src/platform/Tizen/ConnectivityUtils.cpp @@ -447,34 +447,34 @@ CHIP_ERROR ConnectivityUtils::GetEthPHYRate(const char * ifname, PHYRateEnum & p switch (speed) { case 10: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_M; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10M; break; case 100: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_M; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate100M; break; case 1000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE1_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate1G; break; case 25000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE2_5_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate25g; break; case 5000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE5_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate5G; break; case 10000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10G; break; case 40000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE40_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate40G; break; case 100000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate100G; break; case 200000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE200_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate200G; break; case 400000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE400_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate400G; break; default: ChipLogError(DeviceLayer, "Undefined speed! (%d)\n", speed); diff --git a/src/platform/webos/ConnectivityUtils.cpp b/src/platform/webos/ConnectivityUtils.cpp index ff4ea526a0e6f0..646dc209c36ff2 100644 --- a/src/platform/webos/ConnectivityUtils.cpp +++ b/src/platform/webos/ConnectivityUtils.cpp @@ -566,34 +566,34 @@ CHIP_ERROR ConnectivityUtils::GetEthPHYRate(const char * ifname, app::Clusters:: switch (speed) { case 10: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_M; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10M; break; case 100: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_M; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate100M; break; case 1000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE1_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate1G; break; case 25000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE2_5_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate25g; break; case 5000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE5_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate5G; break; case 10000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate10G; break; case 40000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE40_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate40G; break; case 100000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate100G; break; case 200000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE200_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate200G; break; case 400000: - pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE400_G; + pHYRate = app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum::kRate400G; break; default: ChipLogError(DeviceLayer, "Undefined speed! (%d)\n", speed); 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 68ce8065910c47..4b287c6e70abc8 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 @@ -982,9 +982,6 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EthernetNetworkDiagnost using EnumType = EthernetNetworkDiagnostics::PHYRateEnum; 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::kRate10M: case EnumType::kRate100M: case EnumType::kRate1G: @@ -995,18 +992,6 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(EthernetNetworkDiagnost case EnumType::kRate100G: case EnumType::kRate200G: case EnumType::kRate400G: -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM - case EMBER_ZCL_PHY_RATE_ENUM_RATE10_M: - case EMBER_ZCL_PHY_RATE_ENUM_RATE100_M: - case EMBER_ZCL_PHY_RATE_ENUM_RATE1_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE2_5_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE5_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE10_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE40_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE100_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE200_G: - case EMBER_ZCL_PHY_RATE_ENUM_RATE400_G: -#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM return val; default: return static_cast(10); 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 e66dcfffcab9d4..7712c63d297961 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 @@ -1198,9 +1198,6 @@ enum class Feature : uint32_t namespace EthernetNetworkDiagnostics { -// 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 PHYRateEnum enum class PHYRateEnum : uint8_t { @@ -1220,10 +1217,6 @@ enum class PHYRateEnum : uint8_t // enum value. This specific should never be transmitted. kUnknownEnumValue = 10, }; -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using PHYRateEnum = EmberAfPHYRateEnum; -static PHYRateEnum __attribute__((unused)) kPHYRateEnumkUnknownEnumValue = static_cast(10); -#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Bitmap for Feature enum class Feature : uint32_t 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 03d4cfb434f07d..3ab43ae116a662 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -62,18 +62,3 @@ enum EmberAfEnhancedColorMode : uint8_t EMBER_ZCL_ENHANCED_COLOR_MODE_COLOR_TEMPERATURE = 2, EMBER_ZCL_ENHANCED_COLOR_MODE_ENHANCED_CURRENT_HUE_AND_CURRENT_SATURATION = 3, }; - -// Enum for PHYRateEnum -enum EmberAfPHYRateEnum : uint8_t -{ - EMBER_ZCL_PHY_RATE_ENUM_RATE10_M = 0, - EMBER_ZCL_PHY_RATE_ENUM_RATE100_M = 1, - EMBER_ZCL_PHY_RATE_ENUM_RATE1_G = 2, - EMBER_ZCL_PHY_RATE_ENUM_RATE2_5_G = 3, - EMBER_ZCL_PHY_RATE_ENUM_RATE5_G = 4, - EMBER_ZCL_PHY_RATE_ENUM_RATE10_G = 5, - EMBER_ZCL_PHY_RATE_ENUM_RATE40_G = 6, - EMBER_ZCL_PHY_RATE_ENUM_RATE100_G = 7, - EMBER_ZCL_PHY_RATE_ENUM_RATE200_G = 8, - EMBER_ZCL_PHY_RATE_ENUM_RATE400_G = 9, -};