Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define the unknown enum value for cluster enums. #20937

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/lock-app/cyw30739/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ const char * LockManager::lockStateToString(DlLockState lockState) const
return "Locked";
case DlLockState::kUnlocked:
return "Unlocked";
case DlLockState::kUnknownEnumValue:
break;
}

return "Unknown";
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/efr32/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ const char * LockManager::lockStateToString(DlLockState lockState) const
return "Locked";
case DlLockState::kUnlocked:
return "Unlocked";
case DlLockState::kUnknownEnumValue:
break;
}

return "Unknown";
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/linux/src/LockEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ const char * LockEndpoint::lockStateToString(DlLockState lockState) const
return "Locked";
case DlLockState::kUnlocked:
return "Unlocked";
case DlLockState::kUnknownEnumValue:
break;
}

return "Unknown";
Expand Down
13 changes: 13 additions & 0 deletions src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ void DiagnosticLogsCommandHandler::InvokeCommand(HandlerContext & handlerContext
{
HandleCommand<chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::DecodableType>(
handlerContext, [&](auto & _u, auto & payload) {
if (payload.requestedProtocol == chip::app::Clusters::DiagnosticLogs::LogsTransferProtocol::kUnknownEnumValue)
{
handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath,
chip::Protocols::InteractionModel::Status::InvalidCommand);
return;
}

switch (payload.intent)
{
case chip::app::Clusters::DiagnosticLogs::LogsIntent::kEndUserSupport: {
Expand Down Expand Up @@ -86,6 +93,11 @@ void DiagnosticLogsCommandHandler::InvokeCommand(HandlerContext & handlerContext
handlerContext.mCommandHandler.AddResponse(handlerContext.mRequestPath, response);
}
break;
case chip::app::Clusters::DiagnosticLogs::LogsIntent::kUnknownEnumValue: {
handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath,
chip::Protocols::InteractionModel::Status::InvalidCommand);
break;
}
}
});
}
Expand All @@ -94,6 +106,7 @@ bool emberAfDiagnosticLogsClusterRetrieveLogsRequestCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::DecodableType & commandData)
{
// TODO: Shouldn't the default "no-op" impl return some sort of error?
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
emberAfSendImmediateDefaultResponse(status);
return true;
Expand Down
2 changes: 2 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2944,6 +2944,8 @@ DlLockDataType DoorLockServer::credentialTypeToLockDataType(DlCredentialType cre
case DlCredentialType::kFace:
// So far there's no distinct data type for face credentials
return DlLockDataType::kUnspecified;
case DlCredentialType::kUnknownEnumValue:
return DlLockDataType::kUnspecified;
}

return DlLockDataType::kUnspecified;
Expand Down
3 changes: 3 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ void DefaultOTARequestor::OnApplyUpdateResponse(void * context, const ApplyUpdat
requestorCore->mOtaRequestorDriver->UpdateDiscontinued();
requestorCore->RecordNewUpdateState(OTAUpdateStateEnum::kIdle, OTAChangeReasonEnum::kSuccess);
break;
case OTAApplyUpdateAction::kUnknownEnumValue:
OnApplyUpdateFailure(context, CHIP_ERROR_INVALID_ARGUMENT);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ static void updateAttributeLinks(EndpointId endpoint)
}
}
break;

case PumpOperationMode::kUnknownEnumValue: {
// Not expected; see check in MatterPumpConfigurationAndControlClusterServerPreAttributeChangedCallback.
break;
}
}

if (isPumpStatusAvailable)
Expand Down Expand Up @@ -384,8 +389,18 @@ chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClust
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
default:
case PumpControlMode::kProportionalPressure:
if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinCompPressure::Get, Attributes::MaxCompPressure::Get))
{
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
case PumpControlMode::kAutomatic:
status = Protocols::InteractionModel::Status::Success;
break;
case PumpControlMode::kUnknownEnumValue:
status = Protocols::InteractionModel::Status::ConstraintError;
break;
}
}
break;
Expand All @@ -410,8 +425,13 @@ chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClust
status = Protocols::InteractionModel::Status::ConstraintError;
}
break;
default:
case PumpOperationMode::kLocal:
case PumpOperationMode::kNormal:
status = Protocols::InteractionModel::Status::Success;
break;
case PumpOperationMode::kUnknownEnumValue:
status = Protocols::InteractionModel::Status::ConstraintError;
break;
}

break;
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap-templates/templates/app/cluster-enums.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum class {{asType label}} : {{asUnderlyingZclType name}} {
{{#zcl_enum_items}}
k{{asUpperCamelCase label}} = {{asHex value 2}},
{{/zcl_enum_items}}
// kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}},
kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}},
};
{{#if (isWeaklyTypedEnum label)}}
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
Expand Down
3 changes: 3 additions & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,9 @@ CHIP_ERROR DeviceCommissioner::ConvertFromOperationalCertStatus(OperationalCrede
return CHIP_ERROR_INVALID_ARGUMENT;
case OperationalCertStatus::kInvalidFabricIndex:
return CHIP_ERROR_INVALID_FABRIC_INDEX;
case OperationalCertStatus::kUnknownEnumValue:
// Is this a reasonable value?
return CHIP_ERROR_CERT_LOAD_FAILED;
}

return CHIP_ERROR_CERT_LOAD_FAILED;
Expand Down
Loading