From 489375361dea49d91c5a6f1a936d47205e7be030 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Wed, 23 Feb 2022 08:48:56 -0500 Subject: [PATCH] fix ot-cli shell commissioning issue (#15165) * fix ot-cli shell for not zephyr devices * change zephyr define for chip config define * add defined * fix defines --- examples/shell/shell_common/cmd_otcli.cpp | 11 +++++++++-- .../GenericThreadStackManagerImpl_OpenThread.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/shell/shell_common/cmd_otcli.cpp b/examples/shell/shell_common/cmd_otcli.cpp index dbb8128d265b6e..590fda96e16fae 100644 --- a/examples/shell/shell_common/cmd_otcli.cpp +++ b/examples/shell/shell_common/cmd_otcli.cpp @@ -40,11 +40,13 @@ #include #include #if OPENTHREAD_API_VERSION >= 85 +#if !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI #ifndef SHELL_OTCLI_TX_BUFFER_SIZE #define SHELL_OTCLI_TX_BUFFER_SIZE 1024 #endif static char sTxBuffer[SHELL_OTCLI_TX_BUFFER_SIZE]; static constexpr uint16_t sTxLength = SHELL_OTCLI_TX_BUFFER_SIZE; +#endif // !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI) #endif #else #include @@ -163,6 +165,7 @@ static const shell_command_t cmds_otcli_root = { &cmd_otcli_dispatch, "otcli", " #if CHIP_TARGET_STYLE_EMBEDDED #if OPENTHREAD_API_VERSION >= 85 +#if !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI static int OnOtCliOutput(void * aContext, const char * aFormat, va_list aArguments) { int rval = vsnprintf(sTxBuffer, sTxLength, aFormat, aArguments); @@ -171,7 +174,9 @@ static int OnOtCliOutput(void * aContext, const char * aFormat, va_list aArgumen exit: return rval; } +#endif // !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI #else + static int OnOtCliOutput(const char * aBuf, uint16_t aBufLength, void * aContext) { return streamer_write(streamer_get(), aBuf, aBufLength); @@ -185,12 +190,14 @@ void cmd_otcli_init() { #if CHIP_ENABLE_OPENTHREAD #if CHIP_TARGET_STYLE_EMBEDDED +#if !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI #if OPENTHREAD_API_VERSION >= 85 otCliInit(otInstanceInitSingle(), &OnOtCliOutput, NULL); #else otCliConsoleInit(otInstanceInitSingle(), &OnOtCliOutput, NULL); -#endif -#endif +#endif // OPENTHREAD_API_VERSION >= 85 +#endif // !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI +#endif // CHIP_TARGET_STYLE_EMBEDDED // Register the root otcli command with the top-level shell. Engine::Root().RegisterCommands(&cmds_otcli_root, 1); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 7d88dc5141a484..52d85196b3cb6c 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -1582,7 +1582,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::DoInit(otInstanc VerifyOrExit(otInst != NULL, err = MapOpenThreadError(OT_ERROR_FAILED)); } -#if !defined(__ZEPHYR__) && !defined(ENABLE_CHIP_SHELL) && !defined(PW_RPC_ENABLED) && CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI +#if !defined(PW_RPC_ENABLED) && CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI otAppCliInit(otInst); #endif