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 <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2022-03-11 20:45:06 +00:00 committed by Carles Cufí
parent a282e93079
commit 7dea9134a9
3 changed files with 23 additions and 36 deletions

View File

@ -9,6 +9,5 @@ target_include_directories(MCUMGR INTERFACE
)
zephyr_library_sources(
src/zephyr_shell_mgmt.c
src/shell_mgmt.c
)

View File

@ -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 <shell/shell_dummy.h>
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);

View File

@ -1,31 +0,0 @@
/*
* Copyright (c) 2018-2021 mcumgr authors
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/util.h>
#include <shell/shell.h>
#include <mgmt/mgmt.h>
#include <shell_mgmt/shell_mgmt.h>
#include <shell/shell_dummy.h>
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
);
}