Skip to content

Commit

Permalink
update add-more-time command function name
Browse files Browse the repository at this point in the history
  • Loading branch information
liangpy4 committed Nov 27, 2023
1 parent 2e4456c commit b7eec4d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ class ExampleMicrowaveOvenControlDelegate : public MicrowaveOvenControl::Delegat
*/
Platform::UniquePtr<std::function<Protocols::InteractionModel::Status(uint8_t, uint32_t, uint8_t)>>
mHandleSetCookingParametersCallback;
Platform::UniquePtr<std::function<Protocols::InteractionModel::Status(uint32_t)>> mHandleAddMoreTimeCallback;
Platform::UniquePtr<std::function<Protocols::InteractionModel::Status(uint32_t)>> mHandleSetCookTimeCallback;

public:
/**
* Handle Command Callback in application: set-cooking-parameters
*/
Protocols::InteractionModel::Status HandleSetCookingParametersCommandCallback(uint8_t cookMode, uint32_t cookTime,
Protocols::InteractionModel::Status HandleSetCookingParametersCallback(uint8_t cookMode, uint32_t cookTime,
uint8_t powerSetting) override;

/**
* Handle Command Callback in application: add-more-time
*/
Protocols::InteractionModel::Status HandleAddMoreTimeCommandCallback(uint32_t finalCookTime) override;
Protocols::InteractionModel::Status HandleSetCookTimeCallback(uint32_t finalCookTime) override;

/**
* Get the value of MinPower.
Expand All @@ -78,7 +78,7 @@ class ExampleMicrowaveOvenControlDelegate : public MicrowaveOvenControl::Delegat
/**
* Set callback function for add more time
*/
void SetMicrowaveOvenControlAddMoreTimeCallback(std::function<Protocols::InteractionModel::Status(uint32_t)> aCallback);
void SetMicrowaveOvenControlSetCookTimeCallback(std::function<Protocols::InteractionModel::Status(uint32_t)> aCallback);
};

} // namespace MicrowaveOvenControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class MicrowaveOvenDevice
mMicrowaveOvenControlDelegate.SetMicrowaveOvenControlSetCookingParametersCallback(
std::bind(&MicrowaveOvenDevice::HandleMicrowaveOvenSetCookingParametersCommandCallback, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3));
mMicrowaveOvenControlDelegate.SetMicrowaveOvenControlAddMoreTimeCallback(
std::bind(&MicrowaveOvenDevice::HandleMicrowaveOvenAddMoreTimeCommandCallback, this, std::placeholders::_1));
mMicrowaveOvenControlDelegate.SetMicrowaveOvenControlSetCookTimeCallback(
std::bind(&MicrowaveOvenDevice::HandleMicrowaveOvenSetCookTimeCommandCallback, this, std::placeholders::_1));
mOperationalStateDelegate.SetOpStatePauseCallback(
std::bind(&MicrowaveOvenDevice::HandleMicrowaveOvenOpStatePauseCallback, this, std::placeholders::_1));
mOperationalStateDelegate.SetOpStateResumeCallback(
Expand All @@ -61,7 +61,7 @@ class MicrowaveOvenDevice
/**
* handle command for microwave oven control: add more time
*/
Protocols::InteractionModel::Status HandleMicrowaveOvenAddMoreTimeCommandCallback(uint32_t finalCookTime);
Protocols::InteractionModel::Status HandleMicrowaveOvenSetCookTimeCommandCallback(uint32_t finalCookTime);

/**
* handle command for operational state: pause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ using namespace chip::app::Clusters::MicrowaveOvenControl;

// Microwave Oven Control command callbacks
Protocols::InteractionModel::Status
ExampleMicrowaveOvenControlDelegate::HandleSetCookingParametersCommandCallback(uint8_t cookMode, uint32_t cookTime,
ExampleMicrowaveOvenControlDelegate::HandleSetCookingParametersCallback(uint8_t cookMode, uint32_t cookTime,
uint8_t powerSetting)
{
return (*mHandleSetCookingParametersCallback.get())(cookMode, cookTime, powerSetting);
}

Protocols::InteractionModel::Status ExampleMicrowaveOvenControlDelegate::HandleAddMoreTimeCommandCallback(uint32_t finalCookTime)
Protocols::InteractionModel::Status ExampleMicrowaveOvenControlDelegate::HandleSetCookTimeCallback(uint32_t finalCookTime)
{
return (*mHandleAddMoreTimeCallback.get())(finalCookTime);
return (*mHandleSetCookTimeCallback.get())(finalCookTime);
}

void ExampleMicrowaveOvenControlDelegate::SetMicrowaveOvenControlSetCookingParametersCallback(
Expand All @@ -42,8 +42,8 @@ void ExampleMicrowaveOvenControlDelegate::SetMicrowaveOvenControlSetCookingParam
Platform::MakeUnique<std::function<Protocols::InteractionModel::Status(uint8_t, uint32_t, uint8_t)>>(aCallback);
}

void ExampleMicrowaveOvenControlDelegate::SetMicrowaveOvenControlAddMoreTimeCallback(
void ExampleMicrowaveOvenControlDelegate::SetMicrowaveOvenControlSetCookTimeCallback(
std::function<Protocols::InteractionModel::Status(uint32_t)> aCallback)
{
mHandleAddMoreTimeCallback = Platform::MakeUnique<std::function<Protocols::InteractionModel::Status(uint32_t)>>(aCallback);
mHandleSetCookTimeCallback = Platform::MakeUnique<std::function<Protocols::InteractionModel::Status(uint32_t)>>(aCallback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ MicrowaveOvenDevice::HandleMicrowaveOvenSetCookingParametersCommandCallback(uint
return Status::Success;
}

Protocols::InteractionModel::Status MicrowaveOvenDevice::HandleMicrowaveOvenAddMoreTimeCommandCallback(uint32_t finalCookTime)
Protocols::InteractionModel::Status MicrowaveOvenDevice::HandleMicrowaveOvenSetCookTimeCommandCallback(uint32_t finalCookTime)
{
// placeholder implementation
mMicrowaveOvenControlInstance.SetCookTime(finalCookTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands::
if (CookMode.HasValue())
{
// TODO: set Microwave Oven cooking mode by CookMode.Value().
reqCookMode = CookMode.Value();
}
else
{
// TODO: set Microwave Oven cooking mode to normal mode.
reqCookMode = 0;
}

if (CookTime.HasValue())
Expand All @@ -230,7 +232,7 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands::
// set Microwave Oven cooking power to max power(default).
reqPowerSetting = mDelegate->GetMaxPower();
}
status = mDelegate->HandleSetCookingParametersCommandCallback(reqCookMode, reqCookTime, reqPowerSetting);
status = mDelegate->HandleSetCookingParametersCallback(reqCookMode, reqCookTime, reqPowerSetting);
goto exit;
}
else
Expand Down Expand Up @@ -268,7 +270,7 @@ void Instance::HandleAddMoreTime(HandlerContext & ctx, const Commands::AddMoreTi
// if the added cooking time is greater than the max cooking time, the cooking time stay unchanged.
if (finalCookTime < kMaxCookTime)
{
status = mDelegate->HandleAddMoreTimeCommandCallback(finalCookTime);
status = mDelegate->HandleSetCookTimeCallback(finalCookTime);
goto exit;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ class Delegate
* @brief Handle Command Callback in application: SetCookingParameters
* @return Returns the Interaction Model status code which was user determined in the business logic
*/
virtual Protocols::InteractionModel::Status HandleSetCookingParametersCommandCallback(uint8_t cookMode, uint32_t cookTime,
virtual Protocols::InteractionModel::Status HandleSetCookingParametersCallback(uint8_t cookMode, uint32_t cookTime,
uint8_t powerSetting) = 0;

/**
* @brief Handle Command Callback in application: AddMoreTime
* @return Returns the Interaction Model status code which was user determined in the business logic
*/
virtual Protocols::InteractionModel::Status HandleAddMoreTimeCommandCallback(uint32_t finalCookTime) = 0;
virtual Protocols::InteractionModel::Status HandleSetCookTimeCallback(uint32_t finalCookTime) = 0;

/**
* @brief get the MinPower
Expand Down

0 comments on commit b7eec4d

Please sign in to comment.