From 8ac11b9b6f64c1fe9d86826d66b5c322c286a67d Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Thu, 4 Nov 2021 16:27:42 +0100 Subject: [PATCH] net: openthread: Fix for OT prompt in the Zephyr shell OpenThread has changed it's behaviour in terms of prompt printing in the CLI module. Previously it was only printed on the UART CLI backend, now it's printed on every CLI backend. This results in a double prompt being printed when combined with Zephyr shell (one from OT and other form Zephyr). This commit adds a temporary fix to prevent OT prompt from being printed in Zehpyr shell. As a long term solution we should add an option to OpenThread to allow to disable prompt on the output. Signed-off-by: Robert Lubos --- subsys/net/lib/openthread/platform/shell.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/subsys/net/lib/openthread/platform/shell.c b/subsys/net/lib/openthread/platform/shell.c index e72fd34a6e6..cf34887a778 100644 --- a/subsys/net/lib/openthread/platform/shell.c +++ b/subsys/net/lib/openthread/platform/shell.c @@ -25,8 +25,19 @@ static bool is_shell_initialized; static int ot_console_cb(void *context, const char *format, va_list arg) { + char prompt_check[4]; + ARG_UNUSED(context); + /* A temporary workaround to avoid printing OT prompt in Zehyr shell. + * Eventually, OT should add an option which would allow to disable + * prompt on the CLI output. + */ + vsnprintf(prompt_check, sizeof(prompt_check), format, arg); + if (strcmp(prompt_check, "> ") == 0) { + return 0; + } + if (shell_p == NULL) { return 0; }