Skip to content

Commit

Permalink
Undo refactor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Nov 17, 2023
1 parent 176064b commit 2d0e4b3
Showing 1 changed file with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static Protocols::InteractionModel::Status emberAfPluginTimeFormatLocalizationOn
CalendarTypeEnum newType)
{
Protocols::InteractionModel::Status res;
CalendarTypeEnum validType = CalendarTypeEnum::kUseActiveLocale;
CalendarTypeEnum validType = CalendarTypeEnum::kBuddhist;

if (IsSupportedCalendarType(newType, validType))
{
Expand All @@ -164,40 +164,38 @@ static Protocols::InteractionModel::Status emberAfPluginTimeFormatLocalizationOn
return res;
}

static Protocols::InteractionModel::Status
emberAfPluginTimeFormatLocalizationOnUnhandledAttributeChange(EndpointId EndpointId, EmberAfAttributeType attrType,
uint16_t attrSize, uint8_t * attrValue)
{
return Protocols::InteractionModel::Status::Success;
}

Protocols::InteractionModel::Status MatterTimeFormatLocalizationClusterServerPreAttributeChangedCallback(
const ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
{
Protocols::InteractionModel::Status res;

switch (attributePath.mAttributeId)
{
case ActiveCalendarType::Id: {
VerifyOrReturnValue(sizeof(uint8_t) == size, Protocols::InteractionModel::Status::InvalidValue);

CalendarTypeEnum calendarType = static_cast<CalendarTypeEnum>(*value);

// Valid range is from 0 to unknown. This relies that unknown value is
// the first unused value and values increase over time
VerifyOrReturnValue(((calendarType == CalendarTypeEnum::kUseActiveLocale) ||
(to_underlying(calendarType) < to_underlying(CalendarTypeEnum::kUnknownEnumValue))),
Protocols::InteractionModel::Status::ConstraintError);

return emberAfPluginTimeFormatLocalizationOnCalendarTypeChange(attributePath.mEndpointId, calendarType);
}
case HourFormat::Id: {
VerifyOrReturnValue(sizeof(uint8_t) == size, Protocols::InteractionModel::Status::InvalidValue);

HourFormatEnum hourFormat = static_cast<HourFormatEnum>(*value);

// Valid range is from 0 to unknown. This relies that unknown value is
// the first unused value and values increase over time
VerifyOrReturnValue(((hourFormat == HourFormatEnum::kUseActiveLocale) ||
(to_underlying(hourFormat) < to_underlying(HourFormatEnum::kUnknownEnumValue))),
Protocols::InteractionModel::Status::ConstraintError);
case ActiveCalendarType::Id:
if (sizeof(uint8_t) == size)
{
res = emberAfPluginTimeFormatLocalizationOnCalendarTypeChange(attributePath.mEndpointId,
static_cast<CalendarTypeEnum>(*value));
}
else
{
res = Protocols::InteractionModel::Status::InvalidValue;
}
break;

return Protocols::InteractionModel::Status::Success;
}
default:
return Protocols::InteractionModel::Status::Success;
res = emberAfPluginTimeFormatLocalizationOnUnhandledAttributeChange(attributePath.mEndpointId, attributeType, size, value);
break;
}

return res;
}

void emberAfTimeFormatLocalizationClusterServerInitCallback(EndpointId endpoint)
Expand Down

0 comments on commit 2d0e4b3

Please sign in to comment.