Skip to content

Commit

Permalink
[ESP32] Added cli for change and populate action field in runTime (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 authored and pull[bot] committed Oct 12, 2023
1 parent 1855c09 commit 1525356
Showing 1 changed file with 25 additions and 0 deletions.
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

0 comments on commit 1525356

Please sign in to comment.