From 7598746fcfba95b71a350d32bb8eff4360144d98 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 23 Feb 2023 15:49:16 -0500 Subject: [PATCH] Align Time Format Localization cluster XML to spec changes. Spec changes happened in https://github.com/CHIP-Specifications/connectedhomeip-spec/pull/6184. Fixes https://github.com/project-chip/connectedhomeip/issues/24999 --- examples/providers/DeviceInfoProviderImpl.cpp | 24 +++++++++---------- .../time-format-localization-server.cpp | 18 +++++++------- .../chip/time-format-localization-cluster.xml | 10 ++++---- .../CHIP/templates/availability.yaml | 16 +++++++++---- src/include/platform/DeviceInfoProvider.h | 2 +- .../ESP32/ESP32DeviceInfoProvider.cpp | 4 ++-- .../nxp/mw320/DeviceInfoProviderImpl.cpp | 24 +++++++++---------- 7 files changed, 53 insertions(+), 45 deletions(-) diff --git a/examples/providers/DeviceInfoProviderImpl.cpp b/examples/providers/DeviceInfoProviderImpl.cpp index 0e731492a91ba2..5524b770c0585a 100644 --- a/examples/providers/DeviceInfoProviderImpl.cpp +++ b/examples/providers/DeviceInfoProviderImpl.cpp @@ -317,40 +317,40 @@ bool DeviceInfoProviderImpl::SupportedCalendarTypesIteratorImpl::Next(CalendarTy switch (mIndex) { case 0: - output = app::Clusters::TimeFormatLocalization::CalendarType::kBuddhist; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kBuddhist; break; case 1: - output = app::Clusters::TimeFormatLocalization::CalendarType::kChinese; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kChinese; break; case 2: - output = app::Clusters::TimeFormatLocalization::CalendarType::kCoptic; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kCoptic; break; case 3: - output = app::Clusters::TimeFormatLocalization::CalendarType::kEthiopian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kEthiopian; break; case 4: - output = app::Clusters::TimeFormatLocalization::CalendarType::kGregorian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kGregorian; break; case 5: - output = app::Clusters::TimeFormatLocalization::CalendarType::kHebrew; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kHebrew; break; case 6: - output = app::Clusters::TimeFormatLocalization::CalendarType::kIndian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kIndian; break; case 7: - output = app::Clusters::TimeFormatLocalization::CalendarType::kJapanese; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kJapanese; break; case 8: - output = app::Clusters::TimeFormatLocalization::CalendarType::kKorean; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kKorean; break; case 9: - output = app::Clusters::TimeFormatLocalization::CalendarType::kPersian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kPersian; break; case 10: - output = app::Clusters::TimeFormatLocalization::CalendarType::kTaiwanese; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kTaiwanese; break; case 11: - output = app::Clusters::TimeFormatLocalization::CalendarType::kIslamic; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kIslamic; break; default: err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; diff --git a/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp b/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp index 6f792a16d8be21..f4eb458a0a8313 100644 --- a/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp +++ b/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp @@ -67,7 +67,7 @@ CHIP_ERROR TimeFormatLocalizationAttrAccess::ReadSupportedCalendarTypes(Attribut if (it) { err = aEncoder.EncodeList([&it](const auto & encoder) -> CHIP_ERROR { - CalendarType type; + CalendarTypeEnum type; while (it->Next(type)) { @@ -108,10 +108,10 @@ CHIP_ERROR TimeFormatLocalizationAttrAccess::Read(const ConcreteReadAttributePat // Returns whether newType is a valid calendar type. If it's not, validType is set to a valid calendar type, // if there are any, and to kBuddhist if there are not. -bool IsSupportedCalendarType(CalendarType newType, CalendarType & validType) +bool IsSupportedCalendarType(CalendarTypeEnum newType, CalendarTypeEnum & validType) { // Reset valid type if no supported calendar types found. - validType = CalendarType::kBuddhist; + validType = CalendarTypeEnum::kBuddhist; DeviceLayer::DeviceInfoProvider * provider = DeviceLayer::GetDeviceInfoProvider(); @@ -121,7 +121,7 @@ bool IsSupportedCalendarType(CalendarType newType, CalendarType & validType) if (it) { - CalendarType type; + CalendarTypeEnum type; while (it->Next(type)) { @@ -148,10 +148,10 @@ bool IsSupportedCalendarType(CalendarType newType, CalendarType & validType) // ============================================================================= static Protocols::InteractionModel::Status emberAfPluginTimeFormatLocalizationOnCalendarTypeChange(EndpointId EndpointId, - CalendarType newType) + CalendarTypeEnum newType) { Protocols::InteractionModel::Status res; - CalendarType validType = CalendarType::kBuddhist; + CalendarTypeEnum validType = CalendarTypeEnum::kBuddhist; if (IsSupportedCalendarType(newType, validType)) { @@ -184,7 +184,7 @@ Protocols::InteractionModel::Status MatterTimeFormatLocalizationClusterServerPre if (sizeof(uint8_t) == size) { res = emberAfPluginTimeFormatLocalizationOnCalendarTypeChange(attributePath.mEndpointId, - static_cast(*value)); + static_cast(*value)); } else { @@ -202,8 +202,8 @@ Protocols::InteractionModel::Status MatterTimeFormatLocalizationClusterServerPre void emberAfTimeFormatLocalizationClusterServerInitCallback(EndpointId endpoint) { - CalendarType calendarType; - CalendarType validType; + CalendarTypeEnum calendarType; + CalendarTypeEnum validType; EmberAfStatus status = ActiveCalendarType::Get(endpoint, &calendarType); VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, diff --git a/src/app/zap-templates/zcl/data-model/chip/time-format-localization-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/time-format-localization-cluster.xml index 5692f9b8ff241d..323c486d9fbeaa 100644 --- a/src/app/zap-templates/zcl/data-model/chip/time-format-localization-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/time-format-localization-cluster.xml @@ -16,12 +16,12 @@ limitations under the License. --> - + - + @@ -48,8 +48,8 @@ limitations under the License. or audibly convey time information need a mechanism by which they can be configured to use a user’s preferred format. - HourFormat - ActiveCalendarType - SupportedCalendarTypes + HourFormat + ActiveCalendarType + SupportedCalendarTypes diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index f0b8f781aeec14..eb5db2f33878fb 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -3063,8 +3063,12 @@ - OTAChangeReasonEnum - OTAUpdateStateEnum TimeFormatLocalization: - - CalendarType - - HourFormat + # CalendarTypeEnum and HourFormatEnum were originally just named + # CalendarType and HourFormat, but we generate the same API for + # the names with/without "Enum" at the end, so the name can just + # change here. + - CalendarTypeEnum + - HourFormatEnum UnitLocalization: # TempUnitEnum was originally just named TempUnit, but # we generate the same API for both of those names, so the name @@ -3324,7 +3328,11 @@ - RollingBack - DelayedOnUserConsent TimeFormatLocalization: - CalendarType: + # CalendarTypeEnum and HourFormatEnum were originally just named + # CalendarType and HourFormat, but we generate the same API for + # the names with/without "Enum" at the end, so the name can just + # change here. + CalendarTypeEnum: - Buddhist - Chinese - Coptic @@ -3337,7 +3345,7 @@ - Korean - Persian - Taiwanese - HourFormat: + HourFormatEnum: - 12hr - 24hr UnitLocalization: diff --git a/src/include/platform/DeviceInfoProvider.h b/src/include/platform/DeviceInfoProvider.h index b16ab39c91b36e..7b3206eb5c5aad 100644 --- a/src/include/platform/DeviceInfoProvider.h +++ b/src/include/platform/DeviceInfoProvider.h @@ -67,7 +67,7 @@ class DeviceInfoProvider using FixedLabelType = app::Clusters::FixedLabel::Structs::LabelStruct::Type; using UserLabelType = app::Clusters::UserLabel::Structs::LabelStruct::Type; - using CalendarType = app::Clusters::TimeFormatLocalization::CalendarType; + using CalendarType = app::Clusters::TimeFormatLocalization::CalendarTypeEnum; using FixedLabelIterator = Iterator; using UserLabelIterator = Iterator; diff --git a/src/platform/ESP32/ESP32DeviceInfoProvider.cpp b/src/platform/ESP32/ESP32DeviceInfoProvider.cpp index bacae0f9449395..6cc130b8aa21c9 100644 --- a/src/platform/ESP32/ESP32DeviceInfoProvider.cpp +++ b/src/platform/ESP32/ESP32DeviceInfoProvider.cpp @@ -241,7 +241,7 @@ ESP32DeviceInfoProvider::SupportedCalendarTypesIteratorImpl::SupportedCalendarTy size_t ESP32DeviceInfoProvider::SupportedCalendarTypesIteratorImpl::Count() { size_t count = 0; - for (uint8_t i = 0; i < to_underlying(CalendarType::kUnknownEnumValue); i++) + for (uint8_t i = 0; i < to_underlying(CalendarTypeEnum::kUnknownEnumValue); i++) { if (mSupportedCalendarTypes & (1 << i)) { @@ -254,7 +254,7 @@ size_t ESP32DeviceInfoProvider::SupportedCalendarTypesIteratorImpl::Count() bool ESP32DeviceInfoProvider::SupportedCalendarTypesIteratorImpl::Next(CalendarType & output) { - while (mIndex < to_underlying(CalendarType::kUnknownEnumValue)) + while (mIndex < to_underlying(CalendarTypeEnum::kUnknownEnumValue)) { if (mSupportedCalendarTypes & (1 << mIndex)) { diff --git a/src/platform/nxp/mw320/DeviceInfoProviderImpl.cpp b/src/platform/nxp/mw320/DeviceInfoProviderImpl.cpp index 0c8731b6782e9f..0fb5570b294e82 100644 --- a/src/platform/nxp/mw320/DeviceInfoProviderImpl.cpp +++ b/src/platform/nxp/mw320/DeviceInfoProviderImpl.cpp @@ -321,40 +321,40 @@ bool DeviceInfoProviderImpl::SupportedCalendarTypesIteratorImpl::Next(CalendarTy switch (mIndex) { case 0: - output = app::Clusters::TimeFormatLocalization::CalendarType::kBuddhist; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kBuddhist; break; case 1: - output = app::Clusters::TimeFormatLocalization::CalendarType::kChinese; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kChinese; break; case 2: - output = app::Clusters::TimeFormatLocalization::CalendarType::kCoptic; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kCoptic; break; case 3: - output = app::Clusters::TimeFormatLocalization::CalendarType::kEthiopian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kEthiopian; break; case 4: - output = app::Clusters::TimeFormatLocalization::CalendarType::kGregorian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kGregorian; break; case 5: - output = app::Clusters::TimeFormatLocalization::CalendarType::kHebrew; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kHebrew; break; case 6: - output = app::Clusters::TimeFormatLocalization::CalendarType::kIndian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kIndian; break; case 7: - output = app::Clusters::TimeFormatLocalization::CalendarType::kJapanese; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kJapanese; break; case 8: - output = app::Clusters::TimeFormatLocalization::CalendarType::kKorean; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kKorean; break; case 9: - output = app::Clusters::TimeFormatLocalization::CalendarType::kPersian; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kPersian; break; case 10: - output = app::Clusters::TimeFormatLocalization::CalendarType::kTaiwanese; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kTaiwanese; break; case 11: - output = app::Clusters::TimeFormatLocalization::CalendarType::kIslamic; + output = app::Clusters::TimeFormatLocalization::CalendarTypeEnum::kIslamic; break; default: err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;