Skip to content

Commit

Permalink
fix ot-cli shell commissioning issue (#15165)
Browse files Browse the repository at this point in the history
* fix ot-cli shell for not zephyr devices

* change zephyr define for chip config define

* add defined

* fix defines
  • Loading branch information
mkardous-silabs authored and pull[bot] committed Jul 28, 2023
1 parent e69d0bf commit 4893753
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions examples/shell/shell_common/cmd_otcli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
#include <openthread/link.h>
#include <openthread/thread.h>
#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 <sys/types.h>
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::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

Expand Down

0 comments on commit 4893753

Please sign in to comment.