From 0ee0dafec344e2d5b56fa6d07f959d55236604b0 Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Tue, 10 Oct 2023 17:03:54 -0400 Subject: [PATCH] Add `reset bootloader` CLI command --- src/cli/cli.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index e2c66ae7726b..cdb140180282 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -276,11 +276,34 @@ template <> otError Interpreter::Process(Arg aArgs[]) template <> otError Interpreter::Process(Arg aArgs[]) { - OT_UNUSED_VARIABLE(aArgs); + otError error = OT_ERROR_NONE; - otInstanceReset(GetInstancePtr()); + if (aArgs[0].IsEmpty()) + { + otInstanceReset(GetInstancePtr()); + } - return OT_ERROR_NONE; +#if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE + /** + * @cli reset bootloader + * @code + * reset bootloader + * @endcode + * @par + * Resets platform to bootloader mode, if supported. + */ + else if (aArgs[0] == "bootloader") + { + otInstanceResetToBootloader(GetInstancePtr()); + } +#endif + else + { + ExitNow(error = OT_ERROR_INVALID_COMMAND); + } + +exit: + return error; } void Interpreter::ProcessLine(char *aBuf)