Skip to content

Commit

Permalink
Align Time Format Localization cluster XML to spec changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Feb 28, 2023
1 parent 7ce9d78 commit 7598746
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 45 deletions.
24 changes: 12 additions & 12 deletions examples/providers/DeviceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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();

Expand All @@ -121,7 +121,7 @@ bool IsSupportedCalendarType(CalendarType newType, CalendarType & validType)

if (it)
{
CalendarType type;
CalendarTypeEnum type;

while (it->Next(type))
{
Expand All @@ -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))
{
Expand Down Expand Up @@ -184,7 +184,7 @@ Protocols::InteractionModel::Status MatterTimeFormatLocalizationClusterServerPre
if (sizeof(uint8_t) == size)
{
res = emberAfPluginTimeFormatLocalizationOnCalendarTypeChange(attributePath.mEndpointId,
static_cast<CalendarType>(*value));
static_cast<CalendarTypeEnum>(*value));
}
else
{
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ limitations under the License.
-->
<configurator>
<domain name="CHIP" />
<enum name="HourFormat" type="ENUM8">
<enum name="HourFormatEnum" type="ENUM8">
<cluster code="0x002c"/>
<item name="12hr" value="0x00"/>
<item name="24hr" value="0x01"/>
</enum>
<enum name="CalendarType" type="ENUM8">
<enum name="CalendarTypeEnum" type="ENUM8">
<cluster code="0x002c"/>
<item name="Buddhist" value="0x00"/>
<item name="Chinese" value="0x01"/>
Expand All @@ -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.</description>
<!-- Base data types -->
<attribute side="server" code="0x00" define="HOUR_FORMAT" type="HourFormat" min="0x00" max="0x01" writable="true" optional="false">HourFormat</attribute>
<attribute side="server" code="0x01" define="ACTIVE_CALENDAR_TYPE" type="CalendarType" writable="true" optional="true">ActiveCalendarType</attribute>
<attribute side="server" code="0x02" define="SUPPORTED_CALENDAR_TYPES" type="ARRAY" entryType="CalendarType" writable="false" optional="true">SupportedCalendarTypes</attribute>
<attribute side="server" code="0x00" define="HOUR_FORMAT" type="HourFormatEnum" min="0x00" max="0x01" writable="true" optional="false">HourFormat</attribute>
<attribute side="server" code="0x01" define="ACTIVE_CALENDAR_TYPE" type="CalendarTypeEnum" writable="true" optional="true">ActiveCalendarType</attribute>
<attribute side="server" code="0x02" define="SUPPORTED_CALENDAR_TYPES" type="ARRAY" entryType="CalendarTypeEnum" writable="false" optional="true">SupportedCalendarTypes</attribute>
</cluster>
</configurator>
16 changes: 12 additions & 4 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -3337,7 +3345,7 @@
- Korean
- Persian
- Taiwanese
HourFormat:
HourFormatEnum:
- 12hr
- 24hr
UnitLocalization:
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/DeviceInfoProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<FixedLabelType>;
using UserLabelIterator = Iterator<UserLabelType>;
Expand Down
4 changes: 2 additions & 2 deletions src/platform/ESP32/ESP32DeviceInfoProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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))
{
Expand Down
24 changes: 12 additions & 12 deletions src/platform/nxp/mw320/DeviceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7598746

Please sign in to comment.