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

[ESP32] Added cli for change and populate action field in runTime #19552

Merged
merged 1 commit into from
Jun 15, 2022
Merged
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
25 changes: 25 additions & 0 deletions examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <lib/shell/commands/Help.h>
#include <lib/support/logging/CHIPLogging.h>

using namespace chip::app::Clusters::OtaSoftwareUpdateProvider;

namespace chip {
namespace Shell {
namespace {
Expand All @@ -39,6 +41,26 @@ CHIP_ERROR DelayedActionTimeHandler(int argc, char ** argv)
return CHIP_NO_ERROR;
}

CHIP_ERROR ApplyUpdateActionHandler(int argc, char ** argv)
{
VerifyOrReturnError(argc == 1, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(exampleOTAProvider != nullptr, CHIP_ERROR_INCORRECT_STATE);

if (strcmp(argv[0], "proceed") == 0)
{
exampleOTAProvider->SetApplyUpdateAction(OTAApplyUpdateAction::kProceed);
}
else if (strcmp(argv[0], "awaitNextAction") == 0)
{
exampleOTAProvider->SetApplyUpdateAction(OTAApplyUpdateAction::kAwaitNextAction);
}
else if (strcmp(argv[0], "discontinue") == 0)
{
exampleOTAProvider->SetApplyUpdateAction(OTAApplyUpdateAction::kDiscontinue);
}
return CHIP_NO_ERROR;
}

CHIP_ERROR OTAProviderHandler(int argc, char ** argv)
{
if (argc == 0)
Expand Down Expand Up @@ -68,6 +90,9 @@ void OTAProviderCommands::Register()
{ &DelayedActionTimeHandler, "delay",
"Set delayed action time for QueryImageResponse and ApplyUpdateResponse\n"
"Usage: OTAProvider delay <delay in seconds>" },
{ &ApplyUpdateActionHandler, "applyUpdateAction",
"Set apply update action in the apply ApplyUpdateResponse\n"
"Usage: OTAProvider applyUpdateAction <proceed/awaitNextAction/discontinue>" },
};

sSubShell.RegisterCommands(subCommands, ArraySize(subCommands));
Expand Down