From fbc53e3c381eeb93af165ad387a803c8d82b1b9e Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 Nov 2023 12:53:35 +0000 Subject: [PATCH] Restyled by clang-format --- .../microwave-oven-control-server.cpp | 102 +++++++++--------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp index a8f9b706e9c007..8477750b38655e 100644 --- a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp +++ b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp @@ -33,8 +33,8 @@ using Status = Protocols::InteractionModel::Status; namespace { -constexpr uint32_t kMaxCookTime = 65535; -constexpr uint32_t kMinCookTime = 1; +constexpr uint32_t kMaxCookTime = 65535; +constexpr uint32_t kMinCookTime = 1; constexpr uint8_t kDefaultCookTime = 30; constexpr uint8_t kDefaultCookPower = 100; @@ -82,7 +82,7 @@ bool CheckCookTimeIsInRange(uint32_t cookTime) return (cookTime < kMinCookTime || cookTime > kMaxCookTime) ? false : true; } -bool CheckPowerSettingIsInRange(uint8_t powerSetting,uint8_t minCookPower,uint8_t maxCookPower) +bool CheckPowerSettingIsInRange(uint8_t powerSetting, uint8_t minCookPower, uint8_t maxCookPower) { return (powerSetting < minCookPower || powerSetting > maxCookPower) ? false : true; } @@ -107,9 +107,9 @@ bool emberAfMicrowaveOvenControlClusterSetCookingParametersCallback( EmberAfStatus emberAfStatus = EMBER_ZCL_STATUS_SUCCESS; Status status = Status::Success; OperationalState::Instance * gOperationalStateInstance = nullptr; - auto & CookMode = commandData.cookMode; - auto & CookTime = commandData.cookTime; - auto & PowerSetting = commandData.powerSetting; + auto & CookMode = commandData.cookMode; + auto & CookTime = commandData.cookTime; + auto & PowerSetting = commandData.powerSetting; uint8_t kMinCookPower; uint8_t kMaxCookPower; @@ -122,93 +122,93 @@ bool emberAfMicrowaveOvenControlClusterSetCookingParametersCallback( goto exit; } - if(CookTime.HasValue() && (!CheckCookTimeIsInRange(CookTime.Value()))) + if (CookTime.HasValue() && (!CheckCookTimeIsInRange(CookTime.Value()))) { status = Status::InvalidCommand; - ChipLogError(Zcl,"Failed to set cookTime, cookTime value is out of range"); + ChipLogError(Zcl, "Failed to set cookTime, cookTime value is out of range"); goto exit; } emberAfStatus = MinPower::Get(endpointId, &kMinCookPower); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = app::ToInteractionModelStatus(emberAfStatus); - ChipLogError(Zcl,"Failed to get MinPower"); + ChipLogError(Zcl, "Failed to get MinPower"); goto exit; } emberAfStatus = MaxPower::Get(endpointId, &kMaxCookPower); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = app::ToInteractionModelStatus(emberAfStatus); - ChipLogError(Zcl,"Failed to get MaxPower"); + ChipLogError(Zcl, "Failed to get MaxPower"); goto exit; } - if(PowerSetting.HasValue() && (!CheckPowerSettingIsInRange(PowerSetting.Value(),kMinCookPower,kMaxCookPower))) + if (PowerSetting.HasValue() && (!CheckPowerSettingIsInRange(PowerSetting.Value(), kMinCookPower, kMaxCookPower))) { status = Status::InvalidCommand; - ChipLogError(Zcl,"Failed to set cookPower, cookPower value is out of range"); + ChipLogError(Zcl, "Failed to set cookPower, cookPower value is out of range"); goto exit; } opState = gOperationalStateInstance->GetCurrentOperationalState(); - if(opState == to_underlying(OperationalStateEnum::kStopped)) + if (opState == to_underlying(OperationalStateEnum::kStopped)) { - if(CookMode.HasValue()) + if (CookMode.HasValue()) { - //TODO: set Microwave Oven cooking mode by CookMode.Value(). + // TODO: set Microwave Oven cooking mode by CookMode.Value(). } else { - //TODO: set Microwave Oven cooking mode to normal mode. + // TODO: set Microwave Oven cooking mode to normal mode. } - if(CookTime.HasValue()) + if (CookTime.HasValue()) { - //set Microwave Oven cooking time by getting input value. + // set Microwave Oven cooking time by getting input value. emberAfStatus = CookTime::Set(endpointId, CookTime.Value()); - ChipLogError(Zcl, "emberAfStatus value = %d",emberAfStatus); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + ChipLogError(Zcl, "emberAfStatus value = %d", emberAfStatus); + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = Status::InvalidCommand; - ChipLogError(Zcl, "Failed to set cookTime with value = %ld",CookTime.Value()); + ChipLogError(Zcl, "Failed to set cookTime with value = %ld", CookTime.Value()); goto exit; } } else { - //set Microwave Oven cooking time to 30 seconds(default). + // set Microwave Oven cooking time to 30 seconds(default). emberAfStatus = CookTime::Set(endpointId, kDefaultCookTime); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = Status::InvalidCommand; - ChipLogError(Zcl, "Failed to set cookTime with value = %d",kDefaultCookTime); + ChipLogError(Zcl, "Failed to set cookTime with value = %d", kDefaultCookTime); goto exit; } } - if(PowerSetting.HasValue()) + if (PowerSetting.HasValue()) { - //set Microwave Oven cooking power by getting input value. + // set Microwave Oven cooking power by getting input value. emberAfStatus = PowerSetting::Set(endpointId, PowerSetting.Value()); - ChipLogError(Zcl, "emberAfStatus value = %d",emberAfStatus); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + ChipLogError(Zcl, "emberAfStatus value = %d", emberAfStatus); + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = Status::InvalidCommand; - ChipLogError(Zcl, "Failed to set cooking power with value = %d",PowerSetting.Value()); + ChipLogError(Zcl, "Failed to set cooking power with value = %d", PowerSetting.Value()); goto exit; } } else { - //set Microwave Oven cooking power to max power(default). + // set Microwave Oven cooking power to max power(default). emberAfStatus = PowerSetting::Set(endpointId, kDefaultCookPower); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = Status::InvalidCommand; - ChipLogError(Zcl, "Failed to set cooking power with value = %d",kDefaultCookPower); + ChipLogError(Zcl, "Failed to set cooking power with value = %d", kDefaultCookPower); goto exit; } } @@ -231,14 +231,14 @@ bool emberAfMicrowaveOvenControlClusterAddMoreTimeCallback( const chip::app::Clusters::MicrowaveOvenControl::Commands::AddMoreTime::DecodableType & commandData) { uint8_t opState; - EndpointId endpointId = commandPath.mEndpointId; - EmberAfStatus emberAfStatus = EMBER_ZCL_STATUS_SUCCESS; - Status status = Status::Success; + EndpointId endpointId = commandPath.mEndpointId; + EmberAfStatus emberAfStatus = EMBER_ZCL_STATUS_SUCCESS; + Status status = Status::Success; OperationalState::Instance * gOperationalStateInstance = nullptr; - //get Operational State instance and current state + // get Operational State instance and current state gOperationalStateInstance = GetOPInstance(endpointId); - if(gOperationalStateInstance == nullptr) + if (gOperationalStateInstance == nullptr) { ChipLogProgress(Zcl, "Server didn't create instance of Operational State"); status = Status::InvalidInState; @@ -246,42 +246,41 @@ bool emberAfMicrowaveOvenControlClusterAddMoreTimeCallback( } opState = gOperationalStateInstance->GetCurrentOperationalState(); - if(opState == to_underlying(OperationalStateEnum::kStopped) || - opState == to_underlying(OperationalStateEnum::kRunning) || - opState == to_underlying(OperationalStateEnum::kPaused)) + if (opState == to_underlying(OperationalStateEnum::kStopped) || opState == to_underlying(OperationalStateEnum::kRunning) || + opState == to_underlying(OperationalStateEnum::kPaused)) { - //add cooking time by TimeToAdd command + // add cooking time by TimeToAdd command auto & TimeToAdd = commandData.timeToAdd; uint32_t currentCookTime; uint32_t addedCookTime; emberAfStatus = CookTime::Get(endpointId, ¤tCookTime); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = app::ToInteractionModelStatus(emberAfStatus); - ChipLogError(Zcl,"Failed to get cuurent cooking time"); + ChipLogError(Zcl, "Failed to get cuurent cooking time"); goto exit; } addedCookTime = currentCookTime + TimeToAdd; - //if the added cooking time is greater than the max cooking time, the cooking time stay unchanged. - if(addedCookTime < kMaxCookTime) + // if the added cooking time is greater than the max cooking time, the cooking time stay unchanged. + if (addedCookTime < kMaxCookTime) { emberAfStatus = CookTime::Set(endpointId, addedCookTime); - if(emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) + if (emberAfStatus != EMBER_ZCL_STATUS_SUCCESS) { status = Status::InvalidInState; - ChipLogError(Zcl, "Failed to set cookTime with value = %ld",addedCookTime); + ChipLogError(Zcl, "Failed to set cookTime with value = %ld", addedCookTime); goto exit; } } else { status = Status::ConstraintError; - ChipLogError(Zcl,"Failed to set cookTime, cookTime value is out of range"); + ChipLogError(Zcl, "Failed to set cookTime, cookTime value is out of range"); goto exit; } } - else // operational state is in error + else // operational state is in error { status = Status::InvalidInState; goto exit; @@ -291,7 +290,6 @@ bool emberAfMicrowaveOvenControlClusterAddMoreTimeCallback( commandObj->AddStatus(commandPath, status); return true; - } /** @brief Microwave Oven Control Cluster Server Init