Skip to content

Commit

Permalink
Run codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed May 24, 2021
1 parent 297de82 commit 184aa66
Show file tree
Hide file tree
Showing 5 changed files with 4,446 additions and 2,646 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,71 +33,116 @@ namespace Controller {
// OnOff Cluster Commands
CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
{
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
CHIP_ERROR err = CHIP_NO_ERROR;
app::CommandSender * sender = nullptr;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;

if (mpCommandSender == nullptr)
{
ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&mpCommandSender));
}
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;

VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);

app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kOffCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
ReturnErrorOnFailure(mpCommandSender->PrepareCommand(&cmdParams));

SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender));

SuccessOrExit(err = sender->PrepareCommand(&cmdParams));

// Command takes no arguments.

ReturnErrorOnFailure(mpCommandSender->FinishCommand());
SuccessOrExit(err = sender->FinishCommand());

// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(mpCommandSender, onSuccessCallback, onFailureCallback);
mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback);

err = mDevice->SendCommands(sender);

return mDevice->SendCommands(mpCommandSender);
exit:
// On error, we are responsible to close the sender.
if (err != CHIP_NO_ERROR && sender != nullptr)
{
sender->Shutdown();
}
return err;
}

CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
{
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
CHIP_ERROR err = CHIP_NO_ERROR;
app::CommandSender * sender = nullptr;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;

if (mpCommandSender == nullptr)
{
ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&mpCommandSender));
}
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;

VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);

app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kOnCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
ReturnErrorOnFailure(mpCommandSender->PrepareCommand(&cmdParams));

SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender));

SuccessOrExit(err = sender->PrepareCommand(&cmdParams));

// Command takes no arguments.

ReturnErrorOnFailure(mpCommandSender->FinishCommand());
SuccessOrExit(err = sender->FinishCommand());

// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(mpCommandSender, onSuccessCallback, onFailureCallback);
mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback);

return mDevice->SendCommands(mpCommandSender);
err = mDevice->SendCommands(sender);

exit:
// On error, we are responsible to close the sender.
if (err != CHIP_NO_ERROR && sender != nullptr)
{
sender->Shutdown();
}
return err;
}

CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
{
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
CHIP_ERROR err = CHIP_NO_ERROR;
app::CommandSender * sender = nullptr;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;

if (mpCommandSender == nullptr)
{
ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&mpCommandSender));
}
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;

VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);

app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kToggleCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
ReturnErrorOnFailure(mpCommandSender->PrepareCommand(&cmdParams));

SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender));

SuccessOrExit(err = sender->PrepareCommand(&cmdParams));

// Command takes no arguments.

ReturnErrorOnFailure(mpCommandSender->FinishCommand());
SuccessOrExit(err = sender->FinishCommand());

// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(mpCommandSender, onSuccessCallback, onFailureCallback);
mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback);

return mDevice->SendCommands(mpCommandSender);
err = mDevice->SendCommands(sender);

exit:
// On error, we are responsible to close the sender.
if (err != CHIP_NO_ERROR && sender != nullptr)
{
sender->Shutdown();
}
return err;
}

// OnOff Cluster Attributes
Expand Down
Loading

0 comments on commit 184aa66

Please sign in to comment.