From 7dea9134a9ff4f306ca8feafbd4e87f8fa1e7a41 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Fri, 11 Mar 2022 20:45:06 +0000 Subject: [PATCH] mgmt/mcumgr/lib: Unify source code for SHELL mgmt group Moves Zephyr specific code to common source file and removes no longer needed interface headers. Signed-off-by: Dominik Ermel --- .../mcumgr/lib/cmd/shell_mgmt/CMakeLists.txt | 1 - .../lib/cmd/shell_mgmt/src/shell_mgmt.c | 27 +++++++++++++--- .../cmd/shell_mgmt/src/zephyr_shell_mgmt.c | 31 ------------------- 3 files changed, 23 insertions(+), 36 deletions(-) delete mode 100644 subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/zephyr_shell_mgmt.c diff --git a/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/CMakeLists.txt b/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/CMakeLists.txt index 172d52d2196..bbb26a170dd 100644 --- a/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/CMakeLists.txt +++ b/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/CMakeLists.txt @@ -9,6 +9,5 @@ target_include_directories(MCUMGR INTERFACE ) zephyr_library_sources( - src/zephyr_shell_mgmt.c src/shell_mgmt.c ) diff --git a/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/shell_mgmt.c b/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/shell_mgmt.c index 377b15a9b9e..1596ac45b05 100644 --- a/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/shell_mgmt.c +++ b/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/shell_mgmt.c @@ -10,8 +10,28 @@ #include "mgmt/mgmt.h" #include "cborattr/cborattr.h" #include "shell_mgmt/shell_mgmt.h" -#include "shell_mgmt/shell_mgmt_impl.h" #include "shell_mgmt/shell_mgmt_config.h" +#include + +static int +shell_exec(const char *line) +{ + const struct shell *shell = shell_backend_dummy_get_ptr(); + + shell_backend_dummy_clear_output(shell); + return shell_execute_cmd(shell, line); +} + +const char * +shell_get_output() +{ + size_t len; + + return shell_backend_dummy_get_output( + shell_backend_dummy_get_ptr(), + &len + ); +} /** * Command handler: shell exec @@ -51,10 +71,9 @@ shell_mgmt_exec(struct mgmt_ctxt *cb) err |= cbor_encode_text_stringz(&cb->encoder, "o"); err |= cbor_encoder_create_indef_text_string(&cb->encoder, &str_encoder); - rc = shell_mgmt_impl_exec(line); + rc = shell_exec(line); - err |= cbor_encode_text_stringz(&str_encoder, - shell_mgmt_impl_get_output()); + err |= cbor_encode_text_stringz(&str_encoder, shell_get_output()); err |= cbor_encoder_close_container(&cb->encoder, &str_encoder); diff --git a/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/zephyr_shell_mgmt.c b/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/zephyr_shell_mgmt.c deleted file mode 100644 index 019d4db6c46..00000000000 --- a/subsys/mgmt/mcumgr/lib/cmd/shell_mgmt/src/zephyr_shell_mgmt.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2021 mcumgr authors - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include - -int -shell_mgmt_impl_exec(const char *line) -{ - const struct shell *shell = shell_backend_dummy_get_ptr(); - - shell_backend_dummy_clear_output(shell); - return shell_execute_cmd(shell, line); -} - -const char * -shell_mgmt_impl_get_output() -{ - size_t len; - - return shell_backend_dummy_get_output( - shell_backend_dummy_get_ptr(), - &len - ); -}