diff --git a/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp b/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp index 695e9518e699a0..2a722fb179d25e 100644 --- a/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp +++ b/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp @@ -21,6 +21,8 @@ #include #include +using namespace chip::app::Clusters::OtaSoftwareUpdateProvider; + namespace chip { namespace Shell { namespace { @@ -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) @@ -68,6 +90,9 @@ void OTAProviderCommands::Register() { &DelayedActionTimeHandler, "delay", "Set delayed action time for QueryImageResponse and ApplyUpdateResponse\n" "Usage: OTAProvider delay " }, + { &ApplyUpdateActionHandler, "applyUpdateAction", + "Set apply update action in the apply ApplyUpdateResponse\n" + "Usage: OTAProvider applyUpdateAction " }, }; sSubShell.RegisterCommands(subCommands, ArraySize(subCommands));